 Top 33 Data Structure Interview Questions: Here are the top interview questions of Data Structure. Be prepared for the interview. You can download the entire questions in a pdf format. so guys All the best for your interview.

#### 1) What is Data Structure? Explain.

The data structure is a way that specifies how to organize and manipulate the data. It also defines the relationship between them. Some examples of Data Structures are arrays, Linked List, Stack, Queue, etc. Data Structures are the central part of many computer science algorithms as they enable the programmers to handle the data in an efficient way

#### 2) Describe the types of Data Structures?

Data Structures are mainly classified into two types:

Linear Data Structure: A data structure is called linear if all of its elements are arranged in the sequential order. In linear data structures, the elements are stored in a non-hierarchical way where each item has the successors and predecessors except the first and last element.

Non-Linear Data Structure: The Non-linear data structure does not form a sequence i.e. each item or element is connected with two or more other items in a non-linear arrangement. The data elements are not arranged in the sequential structure.

#### 3) List the area of applications of Data Structure.

Top 33 Data Structure Interview Questions Data structures are applied extensively in the following areas of computer science:

• Compiler Design,
• Operating System,
• Database Management System,
• Statistical analysis package,
• Numerical Analysis,
• Graphics,
• Artificial Intelligence,
• Simulation

#### 4) What is the difference between file structure and storage structure?

Difference between file structure and storage structure:

The main difference between file structure and storage structure is based on memory area that is being accessed.

Storage structure: It is the representation of the data structure in the computer memory.

File structure: It is the representation of the storage structure in the auxiliary memory.

#### 5) List the data structures which are used in RDBMS, Network Data Modal, and Hierarchical Data Model.

• RDBMS uses Array data structure
• The network data model uses Graph
• The hierarchal data model uses Trees

#### 6) In what areas do data structures are applied?

Data structures are essential in almost every aspect where data is involved. In general, algorithms that involve efficient data structure is applied in the following areas: numerical analysis, operating system, A.I., compiler design, database management, graphics, and statistical analysis, to name a few…

#### 7) What is LIFO?

Top 33 Data Structure Interview Questions LIFO is a short form of Last In First Out. It refers to how data is accessed, stored and retrieved. Using this scheme, data that was stored last should be the one to be extracted first. This also means that in order to gain access to the first data, all the other data that was stored before this first data must first be retrieved and extracted.

#### 8 ) What is a queue?

A queue is a data structure that can simulate a list or stream of data. In this structure, new elements are inserted at one end, and existing elements are removed from the other end.

#### 9) What are binary trees?

A binary tree is one type of data structure that has two nodes, a left node, and a right node. In programming, binary trees are an extension of the linked list structures.

#### 10) Which data structures are applied when dealing with a recursive function?

Recursion, is a function that calls itself based on a terminating condition, makes use of the stack. Using LIFO, a call to a recursive function saves the return address so that it knows how to return to the calling function after the call terminates.

#### 11) What is a string?

A sequential array of characters is called a string.

#### 12) What is Brute Force algorithm?

Algorithm used to search the contents by comparing each element of array is called Brute Force algorithm.

#### 13) What are the limitations of arrays?

i)Arrays are of fixed size.
ii)Data elements are stored in contiguous memory locations which may not be available always.
iii)Adding and removing elements is problematic because of shifting the locations.

#### 14) How can you overcome the limitations of arrays?

Limitations of arrays can be solved by using the linked list.

#### 15) What is a linked list?

Top 33 Data Structure Interview Questions Linked list is a data structure which store the same kind of data elements but not in continuous memory locations and size is not fixed. The linked lists are related logically.

#### 16)What is an array?

Arrays are defined as the collection of similar types of data items stored at contiguous memory locations. It is the simplest data structure in which each data element can be randomly accessed by using its index number.

#### 17) How to reference all the elements in a one-dimension array?

It can be done by using an indexed loop such that the counter runs from 0 to the array size minus one. In this manner, you can reference all the elements in sequence by using the loop counter as the array subscript.

#### 18) What is a multidimensional array?

The multidimensional array can be defined as the array of arrays in which, the data is stored in tabular form consists of rows and columns. 2D arrays are created to implement a relational database lookalike data structure. It provides ease of holding the bulk of data at once which can be passed to any number of functions wherever required.

#### 19) How are the elements of a 2D array are stored in the memory?

There are two techniques by using which, the elements of a 2D array can be stored in the memory.

• Row-Major Order: In row-major ordering, all the rows of the 2D array are stored into the memory contiguously. First, the 1st row of the array is stored into the memory completely, then the 2nd row of the array is stored into the memory completely and so on till the last row.
• Column-Major Order: In column-major ordering, all the columns of the 2D array are stored into the memory contiguously. first, the 1st column of the array is stored into the memory completely, then the 2nd row of the array is stored into the memory completely and so on till the last column of the array.

#### 20) Calculate the address of a random element present in a 2D array, given base address as BA.

Row-Major Order: If an array is declared as a[m][n] where m is the number of rows while n is the number of columns, then address of an element a[i][j] of the array stored in row-major order is calculated as,

Address(a[i][j]) = B. A. + (i * n + j) * size

Column-Major Order: If an array is declared as a[m][n] where m is the number of rows while n is the number of columns, then address of an element a[i][j] of the array stored in column major order is calculated as

#### 21) What is the difference between a PUSH and a POP?

Top 33 Data Structure Interview Questions Pushing and popping applies to the way data is stored and retrieved in a stack. A push denotes data being added to it, meaning data is being “pushed” into the stack. On the other hand, a pop denotes data retrieval, and in particular, refers to the topmost data being accessed.

#### 22) What is a linear search?

A linear search refers to the way a target key is being searched in a sequential data structure. In this method, each element in the list is checked and compared against the target key. The process is repeated until found or if the end of the file has been reached.

#### 23) How does variable declaration affect memory allocation?

The amount of memory to be allocated or reserved would depend on the data type of the variable being declared. For example, if a variable is declared to be of integer type, then 32 bits of memory storage will be reserved for that variable.

#### 24) What is the advantage of the heap over a stack?

The heap is more flexible than the stack. That’s because memory space for the heap can be dynamically allocated and de-allocated as needed. However, the memory of the heap can at times be slower when compared to that stack.

#### 25) What is a postfix expression?

Top 33 Data Structure Interview Questions A postfix expression is an expression in which each operator follows its operands. The advantage of this form is that there is no need to group sub-expressions in parentheses or to consider operator precedence.

#### 26) What are the different types of traversing?

The different types of traversing are
i)Pre-order traversal-yields prefix form of expression.
ii)In-order traversal-yields infix form of expression.
iii)Post-order traversal-yields postfix form of expression.

#### 27) Define pre-order traversal?

i)Process the root node
ii)Process the left subtree
iii)Process the right subtree

#### 28) Define post-order traversal?

i)Process the left subtree
ii)Process the right subtree
iii)Process the root node

#### 29) Define in -order traversal?

i)Process the left subtree
ii)Process the root node
iii)Process the right subtree

#### 30. What is meant by sorting?

Ordering the data in an increasing or decreasing fashion according to some relationship among the data item is called sorting.

#### 31) What are the scenarios in which an element can be inserted into the circular queue?

• If (rear + 1)%maxsize = front, the queue is full. In that case, overflow occurs and therefore, insertion cannot be performed in the queue.
• If rear != max – 1, the rear will be incremented to the mod(max-size) and the new value will be inserted at the rear end of the queue.
• If front != 0 and rear = max – 1, it means that queue is not full, therefore, set the value of rear to 0 and insert the new element there.

#### 32) What is a dequeue?

Dequeue (also known as a double-ended queue) can be defined as an ordered set of elements in which the insertion and deletion can be performed at both the ends, i.e. front and rear.

#### 33) What is the minimum number of queues that can be used to implement a priority queue?

Two queues are needed. One queue is used to store the data elements, and another is used for storing priorities.