Data structure

Data structure questions for GATE aspirants

25 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

How many null branches are there in a binary tree with 20 nodes?

  1. 5
  2. 21
  3. 18
  4. 22
Question 2 Multiple Choice (Single Answer)

The total number of binary trees possible with three unlabelled nodes is

  1. 5
  2. 6
  3. 7
  4. 8
Question 3 Multiple Choice (Single Answer)

Which one of the following sorting algorithms is using divide and conquer method?

  1. Bubble sort
  2. Selection sort
  3. Quick sort
  4. All of the above
Question 4 Multiple Choice (Single Answer)

For height H and root at level 0, how many number of nodes will be there in a binary tree?

  1. 2H+1 - 1
  2. 2H-1
  3. 2H+1 + 1
  4. 2H+1
Question 5 Multiple Choice (Single Answer)

For static memory location which of the following data structures is used?

  1. Stack
  2. Link list
  3. Tree
  4. Graph
Question 6 Multiple Choice (Single Answer)

Insert the following elements as binary search tree, 10, 11, 12, 13, 14, 15, 16, 17 and build AVL tree.

  1. 15
  2. 14
  3. 13
  4. 16
Question 7 Multiple Choice (Single Answer)

Which of the following data structures allows deletion of element from both the ends and insertion at only one end?

  1. Stack
  2. Priority queue
  3. Input restricted queue
  4. Output restricted queue
Question 8 Multiple Choice (Single Answer)

In-order traversal of a tree will yield a sorted list of elements of tree in

  1. binary trees
  2. binary search trees
  3. heaps
  4. None of the above
Question 9 Multiple Choice (Single Answer)

For height H and root at level 1, how many number of nodes will be there in a binary tree?

  1. 2H - 1
  2. 2H+1
  3. 2H+1 - 1
  4. None of the above
Question 10 Multiple Choice (Single Answer)

Which of the following data structures is used to perform recursion?

  1. Queue
  2. Stack
  3. Tree
  4. Linked list
Question 11 Multiple Choice (Single Answer)

Identify the correct sequence for stack, if the input sequence is 1, 2, 3, 4 and 5.

  1. 4, 3, 5, 1 and 2
  2. 4, 3, 5, 2 and 1
  3. 5, 4, 1, 2 and 3
  4. 5, 4, 3, 1 and 2
Question 12 Multiple Choice (Single Answer)

Which of the following data structures is used for locating memory at run time?

  1. Stack
  2. Queue
  3. Heap
  4. Link list
Question 13 Multiple Choice (Single Answer)

Calculate the number of distinct trees possible for 5 unlabelled NODE.

  1. 34
  2. 39
  3. 42
  4. 45
Question 14 Multiple Choice (Single Answer)

Which of the following is not self referential structure?

  1. Link list
  2. Graph
  3. Tree
  4. Stack
Question 15 Multiple Choice (Single Answer)

A link list contains following items:

The first item in link list is A, second is B, third is C, fourth is D and fifth is E. Here, A is pointing to B, B is pointing to C, C is pointing to D and D is pointing to E and E is the last item. Its link part contains NULL. What will be the output after the following sequence of steps? (First is the pointer pointing to first element)

  1. struct NODE*P;
  2. P=First->next->next;
  3. First->next->next=P->next;
  4. P->next->next=P;
  5. printf(%d,First->next->next->next->info);
  1. C
  2. A
  3. D
  4. E
Question 16 Multiple Choice (Single Answer)

Calculate the minimum number of nodes in AVL tree where height (H) is 8 and root at level 1.

  1. 56
  2. 54
  3. 58
  4. 64
Question 17 Multiple Choice (Single Answer)

If A [2] [2] [2] contains element 1 2 3 4 5 6 7 8. Then A [0] [0] [1] contains which element?

  1. 1
  2. 2
  3. 4
  4. 7
Question 18 Multiple Choice (Single Answer)

From which end of queue, elements are deleted?

  1. Front
  2. Rear
  3. Top
  4. None of the above
Question 19 Multiple Choice (Single Answer)

In stack, insertion of element takes place from which end?

  1. Front
  2. Rear
  3. Top
  4. None of the above
Question 20 Multiple Choice (Single Answer)

The In-order traversal of a tree is given as B C A E D F and pre-order traversal of tree is given as A B C D E F. What will be the post order traversal order?

  1. C B F E D A
  2. C B E F A D
  3. B C F E D A
  4. C B E F D A
Question 21 Multiple Choice (Single Answer)

In queue, from which end elements are inserted?

  1. Front
  2. Rear
  3. Top
  4. None of the above
Question 22 Multiple Choice (Single Answer)

If a binary search tree contains numbers and tree is traversed in order then in which order, numbers will be printed?

  1. Ascending order
  2. Random order
  3. Descending order
  4. None of the above
Question 23 Multiple Choice (Single Answer)

If a binary tree contains either two or zero children, then it is called as

  1. strictly binary tree
  2. binary tree
  3. AVL tree
  4. none of the above
Question 24 Multiple Choice (Single Answer)

Fill in the blank. Where 'i' is the stack no. and 'x' is the item to be inserted.
void Push( int i, int x ) {
if(-------) printf(Stackoverflow); elseS[++Top]=x;
}

  1. Top[i]=Top[i+1]
  2. Top[i]=Bottom[i+1]
  3. Top[i]=Bottom[i]
  4. Top[i]=Bottom[i-1]
Question 25 Multiple Choice (Single Answer)

Fill in the blank in the following code, where DOM is counting the number of nodes in link list.
int DOM() {
struct NODE *M= First;
int count=0;
while( _____ ) {
++count;
P=P->next; }
return count;
}

  1. P
  2. !P
  3. P->next
  4. !P->next