# Interview Data Structures Questions and Answers

Oct 18 • Engineering Sample Papers • 8081 Views • 2 Comments on Interview Data Structures Questions and Answers

Data Structures and Algorithm is considered as one of the important subject for the preparation of any technical interview. Candidates preparing for different technical interviews, find the latest and most asked Data structures questions and answers  in a interview with all the fundamental concepts. Questions has been listed after consulting from different technical recruiters and successful candidates. Still if it need any  improvement please do let us know through the comment section. You can give your valuable feedback through the comments. Any type of suggestions will be highly appreciated.

Introduction : Data structure is the way or concept of  storing and organizing data inside a computer. Different applications used different methodology of arranging or storing data using the Data structures techniques. Some data structures are used for some highly specialized application. Data structures are the main technique or concept  for designing an efficient algorithm. In this section, there are lots of  Data Structure questions and answers  which will surely help to build some basic concepts related to Data Structure.

Types of Data Structures

• Linear Data Structure
• Non- Linear Data Structure

Important  Data Structures Questions and Answers

1.(a) List out the areas in which data structures are applied extensively?

The areas where data structures are applied extensively are

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

(b) What are the major data structures used in the following areas : RDBMS, Network data model & Hierarchical data model. ?

These are the major data structure used:

• In RDBMS – Array (i.e. Array of structures)
• In Network Data model – Graph
• In Hierarchical Data model – Trees

(c)If you are using C language to implement the heterogeneous linked list, what pointer type will you use?

The heterogeneous linked list includes different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we use void pointer. Void pointer has the ability of storing pointer to any type as it is a generic pointer type.

(d) Minimum number of queues needed to implement the priority queue?

Two. ( One queue is used for actual storing of data and another for storing priorities.)

(e)What is the data structures used to perform recursion?

Stack. Because of its LIFO (Last In First Out) property it remembers its ‘caller’ so knows whom to return when the function has to return. Recursion uses system stack for storing the return addresses of the function calls. Each and every recursive function has its equivalent iterative function. Even when such equivalent iterative procedures are written, explicit stack is to be used.

(f)What are the methods available in storing sequential files?

The methods available in storing sequential files are:

• Straight Merging
• Natural Merging
• Polyphase Sort
• Distribution of Initial runs

(g)List out few of the Application of tree data-structure?

The list is as follows:

• The manipulation of Arithmetic expression
• Symbol Table construction
• Syntax analysis

(h) Differentiate the Hashing Functions based on the various methods by which the key value is found.

The list is as follows:

• Direct method
• Subtraction method
• Modulo-Division method
• Digit-Extraction method
• Mid-Square method
• Folding method
• Pseudo-random method

(i)Write the types of Collision Resolution Techniques and the methods used in each of the type?

The types are:

• The methods used include:
• Overflow block
• The methods used include:
• Binary tree

(j)In RDBMS, what is the efficient data structure used in the internal storage representation?

B+ tree.  As in B+ tree, leaf node stores all the data, that’s why the Searching is easier. This corresponds to the records that shall be stored in leaf nodes.

2. What is a spanning Tree?

It is a tree associated with a network. All the nodes of the graph appear on the tree for one time. A minimum spanning tree is a spanning tree organized so that the total edge weight between nodes is minimized.

3. Does the minimum spanning tree of a graph give the shortest distance between any 2 specified nodes?

No. Minimal spanning tree assures that the total weight of the tree is kept at its minimum. But the distance between any two nodes involved in the minimum-spanning tree is not minimum.

4. What is the difference between a queue and a stack?

A queue is FIFO while a stack Is typically  LIFO. Elements get inserted at one end of a queue and retrieved from the other end of the queue, while the removal and insertion  operations for a stack are done at the same end.

5.What is the difference between storing data on the heap vs. on the stack?

The stack is smaller, but faster for creating variables, while the heap is limited in size only by how much memory can be allocated. Stack would contain most compile time variables, while heap would contain anything created with malloc or new.

6. Consider the linear arrays AAA(5:50), BBB (-5:10) and CCC(18).

(a) Find the number of elements in each array

(b) Suppose Base(AAA) = 300 and w=4 words per memory cell for AAA. Find the address of AAA ,AAA, and AAA

(a) Length = Upper Bound  – Lower Bound  +1
Length(AAA) = 50-5+1 = 46
Length(BBB) = 10-(-5)+1 = 16
Length(CCC) = 18-1+1 = 18

(b) Using the formula: LOC(AAA[k]) = Base(AAA)+w(K-LB)
LOC(AAA )= 300+4(15-5) = 340
LOC(AAA )= 300+4(35-5) = 420
AAA is not an element of AAA since 55 exceeds UB = 50.

7. Determining the following stack of characters, where STACK is allocated N = 8 memory cells

STACK : A,C,D,F,K,_,_,_. ( _ means empty allocated cell)
Describe the stack as the following operations takes place:

(a) POP(STACK, ITEM)
(b) POP(STACK, ITEM)
(c) POP(STACK, ITEM)
(d) PUSH(STACK, R)
(e) PUSH(STACK,L)
(f) PUSH(STACK, S)
(g) PUSH(STACK,P)
(h) POP(STACK, ITEM)

(a) STACK: A,C,D,F,_,_,_,_
(b) STACK: A,C,D,_,_,_,_,_
(c) STACK: A,C,_,_,_,_,_,_
(d) STACK: A,C,R,_,_,_,_,_
(e) STACK:A,C,R,L,_,_,_,_
(f) STACK:A,C,R,L,S, _ ,_,_
(g) STACK: A,C,R,L,S,P,_,_
(h) STACK: A,C,R,L,S,_,_,_

8. List out few of the Application of tree data-structure?

The list is as follows:

• Manipulation of Arithmetic expression,
• The symbol Table construction,
• The syntax analysis.

9. What are priority queues?

It is a collection of elements such that each and every element has been assigned a priority

10. Write the syntax for multiplication of matrices?

for (=0; < value;++)
{
for (=0; < value;++)
{
for (=0; < value;++)
{
arr[var1][var2] += arr[var1][var3] * arr[var3][arr2];
}
}
}

Related posts

### 2 Responses to Interview Data Structures Questions and Answers

1. Anonymous says:
2. victor shalom says:

consider the linear array AAA(5:50),BBB(-5:10) and CCC(18). fInd the number of elements in each array