Technical Question Bank: Computer Science
Technical Question Bank: Computer Science
COMPUTER SCIENCE
DATA STRUCTURE INTERVIEW QUESTIONS Q1.What pointer type is used to implement the heterogeneous linked list in C? The answer is the void pointer. The heterogeneous linked list contains different data types in it's nodes and we need a link, pointer, to connect them. Since we can't use ordinary pointers for this, we use the void pointer. Void pointer is a generic pointer type, and capable of storing pointer to any type. Q2.What is the minimum number of queues needed to implement the priority queue? Two. One queue is used for the actual storing of data, and the other one is used for storing the priorities. Q3.Which data structure is used to perform recursion? The answer is Stack. Stack has the LIFO (Last In First Out) property; it remembers it's caller. Therefore, it knows to whom it should return when the function has to return. On the other hand, recursion makes use of the 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. Q4.What are some of the applications for the tree data structure? 1- Manipulation of the arithmetic expressions. 2- Symbol table construction. 3- Syntax analysis. Q5. Which data strucutres algorithm used in solving the eight Queens problem? Backtracking Q6. n an AVL tree, at what condition the balancing is to be done? If the "pivotal value", or the "height factor", is greater than one or less than minus one. Q7.What is the bucket size, when the overlapping and collision occur at the same time? The answer is one. If there is only one entry possible in the bucket, when the collision occurs, there is no way to accommodate the colliding value. This results in the overlapping of values. Q8.There are 8, 15, 13, and 14 nodes in four different trees. Which one of them can form a full binary tree? The answer is the tree with 15 nodes. In general, there are 2^n-1 nodes in a full binary tree. By the method of elimination: Full binary trees contain odd number of nodes, so there cannot be full binary trees with 8 or 14 nodes. Moreover, with 13 nodes you can form a complete binary tree but not a full
Q16 Given 2 sorted lists of size m and n respectively. The number of comparisons needed in the worst case by merge sort will be A) m*n B) Max ( m, n) C) Min (m, n) D) m + n 1 Q17 A complete binary tree with 10 leaves A) cannot have more than 19 nodes B) has exactly19 nodes C) has exactly 17 nodes D) cannot have more than 17 nodes Q18 What is Linked List ? Linked List is one of the fundamental data structures. It consists of a sequence of? nodes, each containing arbitrary data fields and one or two (?links?) pointing to the next and/or previous nodes. A linked list is a self-referential data type because it contains a pointer or link to another data of the same type. Linked lists permit insertion and removal of nodes at any point in the list in constant time, but do not allow random access. Q19 .What is Heap data structure? Heap is a binary tree with a property that parent node is largest or smallest of its subtree. It is balanced and almost complete binary tree. It is mostly implemented using array reprentation of binary tree. It is used for sorting arrays. It has order of N*logN. It have consistant performance unlike quick short. It is slower than quick short by twice in normal case. Q20. Define an addressing function for a data structure? An addressing function for a data structure consisting of n elements is a function which maps the ith element of the data structure onto an integer between one and n. In the case of a vector, the addressing function f maps the ith element onto the integer (i). Q21 . How do you define a vector for a data structure?. The simplest data structure that makes use of computed address to locate its elements is