Wednesday, April 1, 2009

Data structure interview questions Part 2

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

Data structure interview question: 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 + ^

Data structure interview question: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.

Q: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.

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

1 comment: