Wednesday, August 3, 2011

Data structure interview question Series 2


7. What are the notations used in Evaluation of Arithmetic Expressions using prefix and postfix forms?
Answer:Polish and Reverse Polish notations.

8. Convert the expression ((A + B) * C – (D – E) ^ (F + G)) to equivalent Prefix and Postfix notations.
Answer:Prefix Notation: ^ - * +ABC - DE + FG
Postfix Notation: AB + C * DE - - FG + ^

9. Sorting is not possible by using which of the following methods?
Answer:(a) Insertion
(b) Selection
(c) Exchange (bubble sort)
(d) Deletion
(d) Deletion.
Using insertion we can perform insertion sort, using selection we can perform selection sort, using exchange we can perform the bubble sort (and other similar sorting methods). But no sorting method can be done just using deletion.

10. 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,5+1) null branches. In general, a binary tree with n nodes has exactly n+1 null nodes.

11. What are the methods available in storing sequential files ?
Answer:Ø Straight merging,
Ø Natural merging,
Ø Polyphase sort,
Ø Distribution of Initial runs.

12.How many different trees are possible with 10 nodes ?
Answer: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.


i ii iii iv v

In general:
If there are n nodes, there exist 2n-n different trees.

13. List out few of the Application of tree data-structure?
Answer:
Ø The manipulation of Arithmetic expression,
Ø Symbol Table construction,
Ø Syntax analysis.

14. List out few of the applications that make use of Multilinked Structures?
Answer:Ø Sparse matrix,
Ø Index generation.

15. In tree construction which is the suitable efficient data structure?
Answer:(a) Array (b) Linked list (c) Stack (d) Queue (e) none
Answer:
(b) Linked list

16. What is the type of the algorithm used in solving the 8 Queens problem?
Answer:Backtracking

17. In an AVL tree, 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.

No comments:

Post a Comment