# Data structure interview questions Part 1 1. What is data structure?

11. using selection we can perform selection sort. In general. a binary tree with n nodes has exactly n+1 null nodes.DE + FG Postfix Notation: AB + C * DE . Using insertion we can perform insertion sort. Ans Answer. Draw a binary tree with 20 nodes has 21 null branches? Answer:Let us take a tree with 5 nodes (n=5) It will have only 6 (ie. What are the methods available in storing sequential files ? Answer:Ø Straight merging. Sorting is not possible by using which of the following methods? (a)Insertion (b)Selection (c)Exchange(bubblesort) (d)Deletion. using exchange we can perform the bubble sort (and other similar sorting methods). Ø Polyphase sort.5+1) null branches. Convert the expression ((A + B) * C ± (D ± E) ^ (F + G)) to equivalent Prefix and Postfix notations. But no sorting method can be done just using deletion.7. 8. 12. Answer:Prefix Notation: ^ .FG + ^ 9. 10. Ø Distribution of Initial runs. How many different trees are possible with 10 nodes ? Answer: 10 ..* +ABC . What are the notations used in Evaluation of Arithmetic Expressions using prefix and postfix forms? Answer:Polish and Reverse Polish notations. Ø Natural merging.

In tree construction which is the suitable efficient data structure? (a) Array (b) Linked list (c) Stack (d) Queue (e) none Answer: (b) Linked list 16. when the overlapping and collision occur at same time? Answer:One. at what condition the balancing is to be done? Answer:If the µpivotal value¶ (or the µHeight factor¶) is greater than 1 or less than ±1. List out few of the applications that make use of Multilinked Structures? Answer:Ø Sparse matrix. 18. there is no way to accommodate the colliding value. 2*3 . Ø Index generation. there exist 2n-n different trees. What is the bucket size.3 = 5) trees. Ø Syntax analysis. 15. i ii iii iv v In general: If there are n nodes. List out few of the Application of tree data-structure? Answer: Ø The manipulation of Arithmetic expression. it will have the maximum combination of 5 different (ie. In an AVL tree. 14. 13.For example. . Ø Symbol Table construction. when the collision occurs. This results in the overlapping of values. If there is only one entry possible in the bucket. What is the type of the algorithm used in solving the 8 Queens problem? Answer:Backtracking 17. consider a tree with 3 nodes(n=3).

In general: There are 2n-1 nodes in a full binary tree. using array you can store the node 4 at which location? Answer:Left: 2i Right:2i+1 i=location At location 6 . Traverse the given tree using Inorder. so rejected. 14 nodes were there in 4 different trees. So the correct answer is 15. In the given binary tree. Answer: Ø Inorder : D H B E A F C I G J Ø Preorder: A B D H E C F G I J Ø Postorder: H D E B F I J G C A 20. All full binary trees are complete binary trees but not vice versa. 13. With 13 nodes you can form a complete binary tree but not a full binary tree. So there cannot be full binary trees with 8 or 14 nodes. 15. Note: Full and Complete binary trees are different. There are 8. By the method of elimination: Full binary trees contain odd number of nodes. 21. Which of them could have formed a full binary tree? Answer: 15. Preorder and Postorder traversals.19.

So complete binary tree is the better one since the property of complete binary tree is maintained even after operations like additions and deletions are done on it. efficient considering space and time complexities? (a) Incomplete Binary Tree (b) Complete Binary Tree (c) Full Binary Tree (d) Complete Binary Tree. Of the following tree structure. All the nodes of the graph appear on the tree once. 23.1 Root 2 LC1 3 RC1 LC2 RC2 4 LC3 RC3 LC4 5 RC4 where LCn means Left Child of node n and RCn means Right Child of node n. 24. For incomplete binary trees.What is a spanning Tree? Answer:A spanning tree is a tree associated with a network. extra storage is required and overhead of NULL node checking takes place. A minimum spanning tree is a spanning tree organized so that the total edge weight between nodes is minimized. which is. Does the minimum spanning tree of a graph give the shortest distance between any . 22. Answer: By the method of elimination: Full binary tree loses its nature when operations of insertions and deletions are done.