• +91 9723535972
  • info@interviewmaterial.com

Data structure Interview Questions and Answers

Data structure Interview Questions and Answers

Question - 81 : - What is the max heap in the data structure?

Answer - 81 : -

A max heap in a data structure is a complete binary tree where each internal node's value is greater than or equal to that node's children's values.

Question - 82 : - What is a Jagged array?

Answer - 82 : -

Jagged arrays are a particular type of arrays used for storing rows of data of varying lengths to improve efficiency when working with multidimensional arrays.

Question - 83 : - How do you detect a loop in a linked list?

Answer - 83 : -

  • Using Floyd's cycle-finding Algorithm
  • Using hashing
  • Using the visited nodes method 

Question - 84 : - Name a few graph data structure applications.

Answer - 84 : -

Applications of graph data structures in real-time are:

  • Social graphs
  • Path optimization algorithms
  • Recommendation engines
  • Scientific computations

Question - 85 : - What is the difference between stack and heap?

Answer - 85 : -

Both stack and heap are used for memory needs. The stack is primarily used to save the method execution order and local variables, and always follow the LIFO order.

Whereas heap is used for dynamic allocation and deallocation of memory blocks. It stores objects in Java. Memory allocated to the heap lives until one of the following events occurs:

  • Memory free
  • Program terminated
The size of heap memory is more when using recursion when compared with the stack, as it quickly fill-ups stack memory.

Question - 86 : - List a few queue data structure applications.

Answer - 86 : -

As the name suggests, the queue is used whenever you need to manage a group of objects in the order FIFO. A few of the queue data structure applications are listed below:

  • Serving requests on a single shared resource, like CPU task scheduling, printer, etc.
  • Handling interruptions in real-time systems.
  • Buffers in apps like CD player and MP3 media players
  • In maintaining a playlist in media players, like adding or removing songs.

Question - 87 : - What is a queue in data structure?

Answer - 87 : -

A queue is a linear data structure that supports a specific order in which operations are performed. The order is FIFO (First in First Out) methodology, i.e., data items stored first will be accessed first. Unlike stack, the queue is open at both ends, and one end is always used to insert data and another one to remove data.

The basic operations associated with queues -

  • Dequeue - To remove an item
  • Enqueue - To insert an item
  • isempty() − Confirms whether the queue is empty.
  • isfull() − Confirms whether the queue is full.
  • peek() − Gets the element at the front of the queue without removing it.

Question - 88 : - Are linked lists considered non-linear or linear data structures?

Answer - 88 : -

It depends on where you plan to use Linked lists. You can consider a linked list for both non-linear and linear data structures. When used for data storage, it is regarded as a non-linear data structure. When used for access strategies, it is considered a linear data structure.

Question - 89 : - What operations can be performed on a stack?

Answer - 89 : -

Mainly the following operations are performed on a stack:

  • Push operation: To add an item to the stack. If the stack is complete, then it is in an overflow condition.
  • Pop operation: It is used to remove an item from the stack. If it's an empty stack, then it is in underflow condition.
  • isEmpty operation: If the stack is empty returns true, else false.
  • Peek or Top operation: This returns the top element of the stack.

Question - 90 : - What is the difference between storage structure and file structure?

Answer - 90 : -

The main difference between storage structure and file structure depends on the memory area that is accessed.

  • Storage structure: It's a data structure representation in computer memory. 
  • File structure: It's a storage structure representation in the auxiliary memory.


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners