• +91 9971497814
  • info@interviewmaterial.com

Data structure Interview Questions Answers

Question 1 : ARRAY and STACK?

Answer 1 : STACK follows LIFO. Thus the item that is first entered would be the last removed. In array the items can be entered or removed in any order. Basically each member access is done using index. No strict order is to be followed here to remove a particular element.

Question 2 : Difference between calloc and malloc ?

Answer 2 : malloc: allocate n bytes calloc: allocate m times n bytes initialized to 0

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

Answer 3 : Minimal spanning tree assures that the total weight of the tree is kept at its minimum. But it doesn't mean that the distance between any two nodes involved in the minimum-spanning tree is minimum.

Question 4 : How can I search for data in a linked list?

Answer 4 : Unfortunately, the only way to search a linked list is with a linear search, because the only way a linked list's members can be accessed is sequentially. Sometimes it is quicker to take the data from a linked list and store it in a different data structure so that searches can be more efficient.

Question 5 : How do you assign an address to an element of a pointer array ?

Answer 5 : We can assign a memory address to an element of a pointer array by using the address operator, which is the ampersand (&), in an assignment statement such as ptemployee[0] = &projects[2];

Question 6 : How is any Data Structure application is classified among files?

Answer 6 : A linked list application can be organized into a header file, source file and main application file. The first file is the header file that contains the definition of the NODE structure and the LinkedList class definition. The second file is a source code file containing the implementation of member functions of the LinkedList class. The last file is the application file that contains code that creates and uses the LinkedList class.

Question 7 : How is the front of the queue calculated ?

Answer 7 : The front of the queue is calculated by front = (front+1) % size.

Question 8 : How many different trees are possible with 10 nodes ?

Answer 8 : 1014 - For example, consider a tree with 3 nodes(n=3), it will have the maximum combination of 5 different (ie, 23 - 3 =? 5) trees.

Question 9 : How many parts are there in a declaration statement?

Answer 9 : There are two main parts, variable identifier and data type and the third type is optional which is type qualifier like signed/unsigned.

Question 10 : How memory is reserved using a declaration statement ?

Answer 10 : Memory is reserved using data type in the variable declaration. A programming language implementation has predefined sizes for its data types. For example, in C# the declaration int i; will reserve 32 bits for variable i. A pointer declaration reserves memory for the address or the pointer variable, but not for the data that it will point to. The memory for the data pointed by a pointer has to be allocated at runtime. The memory reserved by the compiler for simple variables and for storing pointer address is allocated on the stack, while the memory allocated for pointer referenced data at runtime is allocated on the heap.

Data structure Contributors


Share your email for latest updates


Our partners