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

Answer:A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data. 2. List out the areas in which data structures are applied extensively? Answer: Ø Compiler Design, Ø Operating System, Ø Database Management System, Ø Statistical analysis package, Ø Numerical Analysis, Ø Graphics, Ø Artificial Intelligence, Ø Simulation 3. What are the major data structures used in the following areas of RDBMS, Network data model & Hierarchical data model? Answer: Ø RDBMS ± Array (i.e. Array of structures) Ø Network data model ± Graph Ø Hierarchical data model ± Trees 4. If you are using C language to implement the heterogeneous linked list, what pointer type will you use? Answer: The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type. 5. Minimum number of queues needed to implement the priority queue? Answer: Two. One queue is used for actual storing of data and another for storing priorities. 6. What is the data structures used to perform recursion? Answer: Stack. Because of its LIFO (Last In First Out) property it remembers its µcaller¶ so knows whom to return when the function has to return. Recursion makes use of system stack for storing the return addresses of the function calls. Every recursive function has its equivalent iterative (non-recursive) function. Even when such equivalent iterative procedures are written, explicit stack is to be used.

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.

Which is the simplest file structure? (a) Sequential (b) Indexed (c) Random Answer: Sequential 26. Whether Linked List is linear or Non-linear data structure? Answer:According to Access strategies Linked list is a linear one. Trees.3 = 5. Arrays. an almost complete binary tree is a tree where for a right child. What is mean by d-queue? Answer:D-queue stands for double ended queue.Linked Lists.Ex. 25. According to Storage Linked List is a Non-linear one. But it doesn¶t mean that the distance between any two nodes involved in the minimum-spanning tree is minimum. Stated alternately.n. BST(Binary Search Trees) etc. Data structure interview question:How to find the number of possible tree in the given tree. If the elements of data structure do not form a sequence or a linear list then that type of data structure is called as Non-Linear data structure.2 specified nodes? Answer:No.digit analysis)and also records are retrieved using same hash function. 27. It is a abstract data structure that implements a queue for which elements can be added to front or rear and the elements can be removed from the rear or front. It is also called head-tail linked list 28. Answer: The number of possible tree = (2 power of n) . . Having a left child does not require a node to have a right child. Data structure interview question:What is hashing Answer:Hashing is a way retrieving records from memory in faster way. Stacks.the possible number of trees = 8 . For example:A tree contain three node. Minimal spanning tree assures that the total weight of the tree is kept at its minimum. midsqure. Example of linear and non-linear data structures? Answer:The data structure is said to be a Linear data structure if its elements are in sequence and form a linear list. Record is inserted into memory by using hash function(division.Ex. Data structure interview question:What is almost complete binary tree? Answer:An almost complete binary tree is a tree in which each nodethat has a right child also has a left child. Queues.So if n=3.folding.

Data structure interview question:Which one is faster? A binary search of an orderd set of elements in an array or a sequential search of the elements. Why? Answer:Basically Parenthesis indicate the operations which need to be carried out first ie according to the BODMAS rule. Given a storage system with a block size of b..and the formed prefix/postfix expression is the correct order of expansion of a given mathematical statement. we compare the key element with the approximately center element. but for a left child there may not be a right child. a B+ tree which stores a number of keys equal to a multiple of b will be very efficient when compared to a binary search tree (the corresponding data structure for non-block-oriented storage contexts).The number of nodes in a binary tree can be found using this formula: n = 2^h Where n is the amount of nodes in the tree.SO in case of postfix or prefix expression they are actualy conversions of the orginal standard equation. if it is smaller than it search is applied in the smaller elements only otherwise the search is applied in the larger set of elements. and h is the height of the tree.Where the brackets have already been taken into consideration. Data structure interview question:Parenthesis are never needed in prefix or postfix expressions. its complexity is as we all know is log n as compared to the sequential one whose complexity is n.there is always a left child. Answer:Binary search is faster because we traverse the elements by using the policy of Divide and Conquer.. .. Data structure interview question::What is AVL tree? Answer:Avl tree is self binary tree in which balancing factor l primary value of a B+ tree is in storing data for efficient retrieval in a block-oriented storage context.

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.