Data Structure Interview Questions | Eklavya Online

Data Structure Interview Questions

Which data structure is used to perform recursion?

Stack data structure is used in recursion due to its last in first out nature. Operating system maintains the stack in order to save the iteration variables at each function call

The size of a linked list can be incremented at runtime which is impossible in the case of the array. The List is not required to be contiguously present in the main memory, if the contiguous space is not available, the nodes can be stored anywhere in the memory connected through the links. The List …

Write the recursive C function to count the number of nodes present in a binary tree.

int count (struct node* t) { if(t) { int l, r; l = count(t->left); r=count(t->right); return (1+l+r); } else { return 0; } }

What is a Stack?

Stack is an ordered list in which, insertion and deletion can be performed only at one end that is called the top. It is a recursive data structure having pointer to its top element. The stack is sometimes called as Last-In-First-Out (LIFO) list i.e. the element which is inserted first in the stack will be …

Write the stack overflow condition.

Overflow occurs when top = Maxsize -1

Write the syntax in C to create a node in the singly linked list.

struct node { int data; struct node *next; }; struct node *head, *ptr; ptr = (struct node *)malloc(sizeof(struct node));

Which data structure suits the most in the tree construction?

Queue data structure

List the area of applications where stack data structure can be used?

Expression evaluation Backtracking Memory Management Function calling and return

If you are using C language to implement the heterogeneous linked list, what pointer type should be used?

The heterogeneous linked list contains different data types, so it is not possible to use ordinary pointers for this. For this purpose, you have to use a generic pointer type like void pointer because the void pointer is capable of storing a pointer to any type.

State the properties of B Tree.

A B tree of order m contains all the properties of an M way tree. In addition, it contains the following properties. Every node in a B-Tree contains at most m children. Every node in a B-Tree except the root node and the leaf node contain at least m/2 children. The root nodes must have …