web viewinterview questions. 1. what is data structure? a data structure is a way of organizing data...

24
Interview Questions 1. What is data structure? 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? 1. Compiler Design, 2. Operating System, 3. Database Management System, 4. Statistical analysis package, 5. Numerical Analysis, 6. Graphics, 7. Artificial Intelligence, 8. Simulation 3. What are the major data structures used in the following areas : RDBMS, Network data model and Hierarchical data model. 1. RDBMS = Array (i.e. Array of structures) 2. Network data model = Graph 3. Hierarchical data model = Trees 4. If you are using C language to implement the heterogeneous linked list, what pointer type will you use? 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? 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? 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.

Upload: ngokhue

Post on 03-Feb-2018

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Web viewInterview Questions. 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to

Interview Questions

1. What is data structure?

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?

1. Compiler Design,2. Operating System,3. Database Management System,4. Statistical analysis package,5. Numerical Analysis,6. Graphics,7. Artificial Intelligence,8. Simulation

3. What are the major data structures used in the following areas : RDBMS, Network data model and Hierarchical data model.

1. RDBMS = Array (i.e. Array of structures)2. Network data model = Graph3. Hierarchical data model = Trees

4. If you are using C language to implement the heterogeneous linked list, what pointer type will you use?

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?

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?

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.

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

Page 2: Web viewInterview Questions. 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to

Polish and Reverse Polish notations.

8. Convert the expression ((A + B) * C - (D - E) ^ (F + G)) to equivalent Prefix and Postfix notations.

1. Prefix Notation: - * +ABC ^ - DE + FG2. Postfix Notation: AB + C * DE - FG + ^ -

9. Sorting is not possible by using which of the following methods? (Insertion, Selection, Exchange, Deletion)

Sorting is not possible in 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. What are the methods available in storing sequential files ?

1. Straight merging,2. Natural merging,3. Polyphase sort,4. Distribution of Initial runs.

11. List out few of the Application of tree data-structure?

1. The manipulation of Arithmetic expression,2. Symbol Table construction,3. Syntax analysis.

12. List out few of the applications that make use of Multilinked Structures?

1. Sparse matrix,2. Index generation.

13. In tree construction which is the suitable efficient data structure? (Array, Linked list, Stack, Queue)

Linked list is the suitable efficient data structure.

14. What is the type of the algorithm used in solving the 8 Queens problem?

Backtracking.

15. In an AVL tree, at what condition the balancing is to be done?

If the 'pivotal value' (or the 'Height factor') is greater than 1 or less than -1.

16. What is the bucket size, when the overlapping and collision occur at same time?

Page 3: Web viewInterview Questions. 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to

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.

17. Classify the Hashing Functions based on the various methods by which the key value is found.

1. Direct method,2. Subtraction method,3. Modulo-Division method,4. Digit-Extraction method,5. Mid-Square method,6. Folding method,7. Pseudo-random method.

18. What are the types of Collision Resolution Techniques and the methods used in each of the type?

1. Open addressing (closed hashing), The methods used include: Overflow block.2. Closed addressing (open hashing), The methods used include: Linked list, Binary tree.

3. 19. In RDBMS, what is the efficient data structure used in the internal storage representation?

4. B+ tree. Because in B+ tree, all the data is stored only in leaf nodes, that makes searching easier. This corresponds to the records that shall be stored in leaf nodes.

5. 20. What is a spanning Tree?

6. A spanning tree is a tree associated with a network. All the nodes of the graph appear on the tree once. A minimum spanning tree is a spanning tree organized so that the total edge weight between nodes is minimized.

7. 21. Does the minimum spanning tree of a graph give the shortest distance between any 2 specified nodes?

8. No. The Minimal spanning tree assures that the total weight of the tree is kept at its minimum. But it doesn't mean that the distance between any two nodes involved in the minimum-spanning tree is minimum.

9. 22. Which is the simplest file structure? (Sequential, Indexed, Random)

10. Sequential is the simplest file structure.

11. 23. Whether Linked List is linear or Non-linear data structure?

12. According to Access strategies Linked list is a linear one. According to Storage Linked List is a Non-linear one.

13. 1) What is data structure?

Page 4: Web viewInterview Questions. 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to

14. Data structure refers to the way data is organized and manipulated. It seeks to find ways to make data access more efficient. When dealing with data structure, we not only focus on one piece of data, but rather different set of data and how they can relate to one another in an organized manner.

15. 2) Differentiate file structure from storage structure.16. Basically, the key difference is the memory area that is being

accessed. When dealing with the structure that resides the main memory of the computer system, this is referred to as storage structure. When dealing with an auxiliary structure, we refer to it as file structure.

17. 3) When is a binary search best applied?18. A binary search is an algorithm that is best applied to search a list

when the elements are already in order or sorted. The list is search starting in the middle, such that if that middle value is not the target search key, it will check to see if it will continue the search on the lower half of the list or the higher half. The split and search will then continue in the same manner.

19. 4) What is a linked list?20. A linked list is a sequence of nodes in which each node is

connected to the node following it. This forms a chain-like link of data storage.

21. 5) How do you reference all the elements in a one-dimension array?22. To do this, an indexed loop is used, such that the counter runs

from 0 to the array size minus one. In this manner, we are able to reference all the elements in sequence by using the loop counter as the array subscript.

23. 6) In what areas do data structures applied?24. Data structure is important in almost every aspect where data is

involved. In general, algorithms that involve efficient data structure is applied in the following areas: numerical analysis, operating system, A.I., compiler design, database management, graphics, and statistical analysis, to name a few.

25. 7) What is LIFO?26. LIFO is short for Last In First Out, and refers to how data is

accessed, stored and retrieved. Using this scheme, data that was stored last , should be the one to be extracted first. This also means that in order to gain access to the first data, all the other data that was stored before this first data must first be retrieved and extracted.

27. 8 ) What is a queue?

Page 5: Web viewInterview Questions. 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to

28. A queue is a data structure that can simulates a list or stream of data. In this structure, new elements are inserted at one end and existing elements are removed from the other end.

29. 9) What are binary trees?

30.31. A binary tree is one type of data structure that has two nodes, a

left node and a right node. In programming, binary trees are actually an extension of the linked list structures.

32. 10) Which data structure is applied when dealing with a recursive function?

33. Recursion, which is basically a function that calls itself based on a terminating condition, makes use of the stack. Using LIFO, a call to a recursive function saves the return address so that it knows how to return to the calling function after the call terminates.

34. 11) What is a stack?35. A stack is a data structure in which only the top element can be

accessed. As data is stored in the stack, each data is pushed downward, leaving the most recently added data on top.

36. 12) Explain Binary Search Tree37. A binary search tree stores data in such a way that they can be

retrieved very efficiently. The left subtree contains nodes whose keys are less than the node’s key value, while the right subtree contains nodes whose keys are greater than or equal to the node’s key value. Moreover, both subtrees are also binary search trees.

38. 13) What are multidimensional arrays?39. Multidimensional arrays make use of multiple indexes to store

data. It is useful when storing data that cannot be represented using a

Page 6: Web viewInterview Questions. 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to

single dimensional indexing, such as data representation in a board game, tables with data stored in more than one column.

40. 14) Are linked lists considered linear or non-linear data structure?41. It actually depends on where you intend to apply linked lists. If you

based it on storage, a linked list is considered non-linear. On the other hand, if you based it on access strategies, then a linked list is considered linear.

42. 15) How does dynamic memory allocation help in managing data?43. Aside from being able to store simple structured data types,

dynamic memory allocation can combine separately allocated structured blocks to form composite structures that expand and contract as needed.

44. 16) What is FIFO?45. FIFO is short for First-in, First-out, and is used to represent how

data is accessed in a queue. Data has been inserted into the queue list the longest is the one that is removed first.

46. 17) What is an ordered list?47. An ordered list is a list in which each node’s position in the list is

determined by the value of its key component, so that the key values form an increasing sequence, as the list is traversed.

48. 18) What is merge sort?49. Merge sort takes a divide-and-conquer approach to sorting data.

In a sequence of data, adjacent ones are merged and sorted to create bigger sorted lists. These sorted lists are then merged again to form an even bigger sorted list, which continuous until you have one single sorted list.

50. 19) Differentiate NULL and VOID.51. Null is actually a value, whereas Void is a data type identifier. A

variable that is given a Null value simply indicates an empty value. Void is used to identify pointers as having no initial size.

52. 20) What is the primary advantage of a linked list?53. A linked list is a very ideal data structure because it can be

modified easily. This means that modifying a linked list works regardless of how many elements are in the list.

54. 21) What is the difference between a PUSH and a POP?55. Pushing and popping applies to the way data is stored and

retrieved in a stack. A push denotes data being added to it, meaning data is being “pushed” into the stack. On the other hand, a pop denotes data retrieval, and in particular refers to the topmost data being accessed.

56. 22) What is a linear search?

Page 7: Web viewInterview Questions. 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to

57. A linear search refers to the way a target key is being searched in a sequential data structure. Using this method, each element in the list is checked and compared against the target key, and is repeated until found or if the end of the list has been reached.

58. 23) How does variable declaration affect memory allocation?59. The amount of memory to be allocated or reserved would depend

on the data type of the variable being declared. For example, if a variable is declared to be of integer type, then 32 bits of memory storage will be reserved for that variable.

60. 24) What is the advantage of the heap over a stack?61. Basically, the heap is more flexible than the stack. That’s because

memory space for the heap can be dynamically allocated and de-allocated as needed. However, memory of the heap can at times be slower when compared to that stack.

62. 25) What is a postfix expression?63. A postfix expression is an expression in which each operator

follows its operands. The advantage of this form is that there is no need to group sub-expressions in parentheses or to consider operator precedence.

64. 26) What is Data abstraction?65. Data abstraction is a powerful tool for breaking down complex

data problems into manageable chunks. This is applied by initially specifying the data objects involved and the operations to be performed on these data objects without being overly concerned with how the data objects will be represented and stored in memory.

66. 27) How do you insert a new item in a binary search tree?67. Assuming that the data to be inserted is a unique value (that is,

not an existing entry in the tree), check first if the tree is empty. If it’s empty, just insert the new item in the root node. If it’s not empty, refer to the new item’s key. If it’s smaller than the root’s key, insert it into the root’s left subtree, otherwise, insert it into the root’s right subtree.

68. 28) How does a selection sort work for an array?69. The selection sort is a fairly intuitive sorting algorithm,, though not

necessarily efficient. To perform this, the smallest element is first located and switched with the element at subscript zero, thereby placing the smallest element in the first position. The smallest element remaining in the subarray is then located next with subscripts 1 through n-1 and switched with the element at subscript 1, thereby placing the second smallest element in the second position. The steps are repeated in the same manner till the last element.

70. 29) How do signed and unsigned numbers affect memory?

Page 8: Web viewInterview Questions. 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to

71. In the case of signed numbers, the first bit is used to indicate whether positive or negative, which leaves you with one bit short. With unsigned numbers, you have all bits available for that number. The effect is best seen in the number range (unsigned 8 bit number has a range 0-255, while 8-bit signed number has a range -128 to +127.

72. 30) What is the minimum number of nodes that a binary tree can have?

73. A binary tree can have a minimum of zero nodes, which occurs when the nodes have NULL values. Furthermore, a binary tree can also have 1 or 2 nodes.

74. 31) What are dynamic data structures?75. Dynamic data structures are structures that expand and contract

as a program runs. It provides a flexible means of manipulating data because it can adjust according to the size of the data.

76. 32) In what data structures are pointers applied?77. Pointers that are used in linked list have various applications in

data structure. Data structures that make use of this concept include the Stack, Queue, Linked List and Binary Tree.

78. 33) Do all declaration statements result in a fixed reservation in memory?

79. Most declarations do, with the exemption of pointers. Pointer declaration does not allocate memory for data, but for the address of the pointer variable. Actual memory allocation for the data comes during run-time.

80. 34) What are ARRAYs?81. When dealing with arrays, data is stored and retrieved using an

index that actually refers to the element number in the data sequence. This means that data can be accessed in any order. In programming, an array is declared as a variable having a number of indexed elements.

82. 35) What is the minimum number of queues needed when implementing a priority queue?

83. The minimum number of queues needed in this case is two. One queue is intended for sorting priorities while the other queue is intended for actual storage of data.

84. 36) Which sorting algorithm is considered the fastest?85. There are many types of sorting algorithms: quick sort, bubble

sort, balloon sort, radix sort, merge sort, etc. Not one can be considered the fastest because each algorithm is designed for a particular data structure and data set. It would depend on the data set that you would want to sort.

86. 37) Differentiate STACK from ARRAY.

Page 9: Web viewInterview Questions. 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to

87. Data that is stored in a stack follows a LIFO pattern. This means that data access follows a sequence wherein the last data to be stored will the first one to be extracted. Arrays, on the other hand, does not follow a particular order and instead can be accessed by referring to the indexed element within the array.

88. 38) Give a basic algorithm for searching a binary search tree.89. 1. if the tree is empty, then the target is not in the tree, end search

2. if the tree is not empty, the target is in the tree3. check if the target is in the root item4. if target is not in the root item, check if target is smaller than the root’s value5. if target is smaller than the root’s value, search the left subtree6. else, search the right subtree

90. 39) What is a dequeue?91. A dequeue is a double-ended queue. This is a structure wherein

elements can be inserted or removed from either end.92. 40) What is a bubble sort and how do you perform it?93. A bubble sort is one sorting technique that can be applied to data

structures such as an array. It works by comparing adjacent elements and exchanges their values if they are out of order. This method lets the smaller values “bubble” to the top of the list, while the larger value sinks to the bottom.

94. 41) What are the parts of a linked list?95. A linked list typically has two parts: the head and the tail. Between

the head and tail lie the actual nodes, with each node being linked in a sequential manner.

96. 42) How does selection sort work?97. Selection sort works by picking the smallest number from the list

and placing it at the front. This process is repeated for the second position towards the end of the list. It is the simplest sort algorithm.

98. 43) What is a graph?99. A graph is one type of data structure that contains a set of

ordered pairs. These ordered pairs are also referred to as edges or arcs, and are used to connect nodes where data can be stored and retrieved.

100. 44) Differentiate linear from non linear data structure.101. Linear data structure is a structure wherein data elements are

adjacent to each other. Examples of linear data structure include arrays, linked lists, stacks and queues. On the other hand, non-linear data structure is a structure wherein each data element can connect to more

Page 10: Web viewInterview Questions. 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to

than two adjacent data elements. Examples of non linear data structure include trees and graphs.

102. 45) What is an AVL tree?103. An AVL tree is a type of binary search tree that is always in a

state of partially balanced. The balance is measured as a difference between the heights of the subtrees from the root. This self-balancing tree was known to be the first data structure to be designed as such.

104. 46) What are doubly linked lists?105. Doubly linked lists are a special type of linked list wherein

traversal across the data elements can be done in both directions. This is made possible by having two links in every node, one that links to the next node and other one that links to the previous node.

106. 47) What is Huffman’s algorithm?107. Huffman’s algorithm is associated in creating extended binary

trees that has minimum weighted path lengths from the given weights. It makes use of a table that contains frequency of occurrence for each data element.

108. 48) What is Fibonacci search?109. Fibonacci search is a search algorithm that applies to a sorted

array. It makes use of a divide-and-conquer approach that can greatly reduce the time needed in order to reach the target element.

110. 49) Briefly explain recursive algorithm.111. Recursive algorithm targets a problem by dividing it into smaller,

manageable sub-problems. The output of one recursion after processing one sub-problem becomes the input to the next recursive process.

112. 50) How do you search for a target key in a linked list?113. To find the target key in a linked list, you have to apply sequential

search. Each node is traversed and compared with the target key, and if it is different, then it follows the link to the next node. This traversal continues until either the target key is found or if the last node is reached.

114.Read more at http://www.gointerviews.com/top-50-data-structure-interview-questions/#TsmZDRpDHbR8Z4LX.99 

115. What is data structure?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.

Page 11: Web viewInterview Questions. 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to

116. List out the areas in which data structures are applied extensively?Compiler Design, Operating System, Database Management System, Statistical analysis package, Numerical Analysis, Graphics, Artificial Intelligence, Simulation

117. If you are using C language to implement the heterogeneous linked list, what pointer type will you use?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.

118. What is the data structures used to perform recursion?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.

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

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

121. In RDBMS, what is the efficient data structure used in the internal storage representation?B+ tree. Because in B+ tree, all the data is stored only in leaf nodes, that makes searching easier. This corresponds to the records that shall be stored in leaf nodes.

122. What is a spanning Tree?A spanning tree is a tree associated with a network. All the nodes of the graph appear on the tree once. A minimum spanning tree is a spanning tree organized so that the total edge weight between nodes is minimized.

123. Does the minimum spanning tree of a graph give the shortest distance between any 2 specified nodes?Minimal spanning tree assures that the total weight of the tree is kept at its minimum. But it doesn't mean that the distance between any two nodes involved in the minimum-spanning tree is minimum.

124. Whether Linked List is linear or Non-linear data structure?According to Access strategies Linked list is a linear one. According to Storage Linked List is a Non-linear one.

125. What is the quickest sorting method to use?The answer depends on what you mean by quickest. For most sorting problems, it just doesn't matter how quick the sort is because it is done infrequently or other operations take significantly more time anyway. Even in cases in which sorting speed is of the essence, there is no one answer. It depends on not only the size and nature of the data, but also the likely order. No algorithm is best in all cases. There are three sorting methods in this author's toolbox that are all very fast and that are useful in different situations. Those methods are quick sort, merge sort, and radix sort.

The Quick SortThe quick sort algorithm is of the divide and conquer type. That means it works by reducing a sorting problem into several easier sorting problems and solving each of them. A dividing value is chosen from the input data, and the data is partitioned into three sets: elements that belong before the dividing value, the

Page 12: Web viewInterview Questions. 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to

value itself, and elements that come after the dividing value. The partitioning is performed by exchanging elements that are in the first set but belong in the third with elements that are in the third set but belong in the first Elements that are equal to the dividing element can be put in any of the three sets the algorithm will still work properly.

The Merge SortThe merge sort is a divide and conquer sort as well. It works by considering the data to be sorted as a sequence of already-sorted lists (in the worst case, each list is one element long). Adjacent sorted lists are merged into larger sorted lists until there is a single sorted list containing all the elements. The merge sort is good at sorting lists and other data structures that are not in arrays, and it can be used to sort things that don't fit into memory. It also can be implemented as a stable sort. 

The Radix SortThe radix sort takes a list of integers and puts each element on a smaller list, depending on the value of its least significant byte. Then the small lists are concatenated, and the process is repeated for each more significant byte until the list is sorted. The radix sort is simpler to implement on fixed-length data such as ints.

126. How can I search for data in a linked list?Unfortunately, the only way to search a linked list is with a linear search, because the only way a linked list's members can be accessed is sequentially. Sometimes it is quicker to take the data from a linked list and store it in a different data structure so that searches can be more efficient.

127. What is the heap?The heap is where malloc(), calloc(), and realloc() get memory.

Getting memory from the heap is much slower than getting it from the stack. On the other hand, the heap is much more flexible than the stack. Memory can be allocated at any time and deallocated in any order. Such memory isn't deallocated automatically; you have to call free().Recursive data structures are almost always implemented with memory from the heap. Strings often come from there too, especially strings that could be very long at runtime. If you can keep data in a local variable (and allocate it from the stack), your code will run faster than if you put the data on the heap. Sometimes you can use a better algorithm if you use the heap faster, or more robust, or more flexible. Its a tradeoff.If memory is allocated from the heap, its available until the program ends. That's great if you remember to deallocate it when you're done. If you forget, it's a problem. A �memory leak is some allocated memory that's no longer needed but isn't deallocated. If you have a memory leak inside a loop, you can use up all the memory on the heap and not be able to get any more. (When that happens, the allocation functions return a null pointer.) In some environments, if a program doesn't deallocate everything it allocated, memory stays unavailable even after the program ends.

128. What is the easiest sorting method to use?The answer is the standard library function qsort(). It's the easiest sort by far for several reasons:It is already written.It is already debugged.

Page 13: Web viewInterview Questions. 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to

It has been optimized as much as possible (usually).Void qsort(void *buf, size_t num, size_t size, int (*comp)(const void *ele1, const void *ele2));

129. What is the bucket size, when the overlapping and collision occur at same time?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.

130. In an AVL tree, at what condition the balancing is to be done?If the pivotal value (or the Height factor) is greater than 1 or less than 1.

131. Minimum number of queues needed to implement the priority queue?Two. One queue is used for actual storing of data and another for storing priorities.

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

133. What is a node class?A node class is a class that, relies on the base class for services and  implementation, provides a wider interface to users than its base class, relies primarily on virtual functions in its public interface depends on all its direct and indirect base class can be understood only in the context of the base class can be used as base for further derivationcan be used to create objects. A node class is a class that has added new services or functionality beyond the services inherited from its base class.

134. When can you tell that a memory leak will occur?A memory leak occurs when a program loses the ability to free a block of dynamically allocated memory.

135. What is placement new?When you want to call a constructor directly, you use the placement new. Sometimes you have some raw memory that’s already been allocated, and you need to construct an object in the memory you have. Operator new’s special version placement new allows you to do it.class Widget{public :Widget(int widgetsize);…Widget* Construct_widget_int_buffer(void *buffer,int widgetsize){return new(buffer) Widget(widgetsize);}};This function returns a pointer to a Widget object that’s constructed within the buffer passed to the function. Such a function might be useful for applications using shared memory or memory-mapped I/O, because objects in such applications must be placed at specific addresses or in memory allocated by special routines.

136. List out the areas in which data structures are applied extensively ?Compiler Design, Operating System, Database Management System, Statistical analysis package, Numerical Analysis, Graphics, Artificial Intelligence, Simulation

137. If you are using C language to implement the heterogeneous linked list, what pointer type will you use?

Page 14: Web viewInterview Questions. 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to

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.

138. What is the data structures used to perform recursion?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.

139. Whether Linked List is linear or Non-linear data structure?According to Access strategies Linked list is a linear one.

According to Storage Linked List is a Non-linear one140. Tell how to check whether a linked list is circular ?

Create two pointers, each set to the start of the list. Update each as follows:

while (pointer1) 

{pointer1 = pointer1->next;pointer2 = pointer2->next; if (pointer2) pointer2=pointer2->next;if (pointer1 == pointer2) 

? ? ? ? ? ? {print (\”circular\n\”);}}

141. What is the difference between ARRAY and STACK?STACK follows LIFO. Thus the item that is first entered would be the last removed.

In array the items can be entered or removed in any order. Basically each member access is done using index. No strict order is to be followed here to remove a particular element.

142. What is the difference between NULL AND VOID pointer?NULL can be value for pointer type variables.VOID is a type identifier which has not size.NULL and void are not same. Example: void* ptr = NULL;

143. What is precision?Precision refers the accuracy of the decimal portion of a value. Precision is the number of digits allowed after the decimal point.

144. What is impact of signed numbers on the memory?Sign of the number is the first bit of the storage allocated for that number. So you get one bit less for storing the number. For example if you are storing an 8-bit number, without sign, the range is 0-255. If you decide to store sign you get 7 bits for the number plus one bit for the sign. So the range is -128 to +127.

145. How memory is reserved using a declaration statement ?Memory is reserved using data type in the variable declaration. A programming language implementation has predefined sizes for its data types.

Page 15: Web viewInterview Questions. 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to

For example, in C# the declaration int i; will reserve 32 bits for variable i.

A pointer declaration reserves memory for the address or the pointer variable, but not for the data that it will point to. The memory for the data pointed by a pointer has to be allocated at runtime.

The memory reserved by the compiler for simple variables and for storing pointer address is allocated on the stack, while the memory allocated for pointer referenced data at runtime is allocated on the heap.

146. How many parts are there in a declaration statement?There are two main parts, variable identifier and data type and the third type is optional which is type qualifier like signed/unsigned.

147. Is Pointer a variable?Yes, a pointer is a variable and can be used as an element of a structure and as an attribute of a class in some programming languages such as C++, but not Java. However, the contents of a pointer is a memory address of another location of memory, which is usually the memory address of another variable, element of a structure, or attribute of a class.

148. What is Data Structure?A data structure is a group of data elements grouped together under one name. These data elements, known as members, can have different types and different lengths. Some are used to store the data of same type and some are used to store different types of data.

149. What is significance of  ” * ” ?The symbol “*” tells the computer that you are declaring a pointer.Actually it depends on context.In a statement like int *ptr; the ‘*’ tells that you are declaring a pointer.In a statement like int i = *ptr; it tells that you want to assign value pointed to by ptr to variable i.

The symbol “*” is also called as Indirection Operator/ Dereferencing Operator.150. Why do we Use a Multidimensional Array?

A multidimensional array can be useful to organize subgroups of data within an array. In addition to organizing data stored in elements of an array, a multidimensional array can store memory addresses of data in a pointer array and an array of pointers.

Multidimensional arrays are used to store information in a matrix form.e.g. a railway timetable, schedule cannot be stored as a single dimensional array.One can use a 3-D array for storing height, width and length of each room on each floor of a building.

151. How do you assign an address to an element of a pointer array ?We can assign a memory address to an element of a pointer array by using the address operator, which is the ampersand (&), in an assignment statement such as ptemployee[0] = &projects[2];

152. Run Time Memory Allocation is known as ?Allocating memory at runtime is called a dynamically allocating memory. In this, you dynamically allocate memory by using the new operator when declaring the array, for example : int grades[] = new int[10];

153. What method is used to place a value onto the top of a stack?push() method, Push is the direction that data is being added to the stack. push() member method places a value onto the top of a stack.

Page 16: Web viewInterview Questions. 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to

154. What method removes the value from the top of a stack?The pop() member method removes the value from the top of a stack, which is then returned by the pop() member method to the statement that calls the pop() member method.

155. What does isEmpty() member method determines?isEmpty() checks if the stack has at least one element. This method is called by Pop() before retrieving and returning the top element.

156. What is a queue ?A Queue is a sequential organization of data. A queue is a first in first out type of data structure. An element is inserted at the last position and an element is always taken out from the first position.

157. What is the relationship between a queue and its underlying array?Data stored in a queue is actually stored in an array. Two indexes, front and end will be used to identify the start and end of the queue.

When an element is removed front will be incremented by 1. In case it reaches past the last index available it will be reset to 0. Then it will be checked with end. If it is greater than end queue is empty.

When an element is added end will be incremented by 1. In case it reaches past the last index available it will be reset to 0. After incrementing it will be checked with front. If they are equal queue is full.

158. Which process places data at the back of the queue?Enqueue is the process that places data at the back of the queue.

159. Why is the isEmpty() member method called?The isEmpty() member method is called within the dequeue process to determine if there is an item in the queue to be removed i.e. isEmpty() is called to decide whether the queue has at least one element. This method is called by the dequeue() method before returning the front element.

160. How is the front of the queue calculated ?The front of the queue is calculated by front = (front+1) % size.

161. What does each entry in the Link List called?Each entry in a linked list is called a node. Think of a node as an entry that has three sub entries. One sub entry contains the data, which may be one attribute or many attributes. Another points to the previous node, and the last points to the next node. When you enter a new item on a linked list, you allocate the new node and then set the pointers to previous and next nodes.

162. 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 datatype 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.

163. What member function places a new node at the end of the linked list?The appendNode() member function places a new node at the end of the linked list. The appendNode() requires an integer representing the current data of the node.

164. How is any Data Structure application is classified among files?A linked list application can be organized into a header file, source file and main application file. The first file is the header file that contains the definition of the

Page 17: Web viewInterview Questions. 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to

NODE structure and the LinkedList class definition. The second file is a source code file containing the implementation of member functions of the LinkedList class. The last file is the application file that contains code that creates and uses the LinkedList class.

165. Which file contains the definition of member functions?Definitions of member functions for the Linked List class are contained in the LinkedList.cpp file.

166. What are the major data structures used in the following areas : RDBMS, Network data model & Hierarchical data model.1. RDBMS Array (i.e. Array of structures)2. Network data model Graph3. Hierarchical data model Trees.

167. Difference between calloc and malloc ?malloc: allocate n bytescalloc: allocate m times n bytes initialized to 0

data structure Questions1.What is data structure?2.What are the goals of Data Structure ?3.What does abstract Data Type Mean?4.What is the difference between a Stack and an Array?5.What do you mean by recursive definition?6.What is sequential search?7.What actions are performed when a function is called?8.What actions are performed when a function returns?9.What is a linked list ?10.What are the advantages of linked list over array(static data structure) ?11.Can we apply binary search algorithm to a sorted linked list,why ?12.What do you mean by free pool ?13.What do you mean by garbage collection ?14.What do you mean by overflow and underflow ?15.What are the disadvantages array implementation of linked list ?16.What is a queue ?17. What is a priority queue ?18.What are the disadvantages of sequential storage?19.What are the disadvantages of representing a stack or queue by a linked list ?20.What is dangling pointer and how to avoid it ?21.What are the disadvantages of linear list ?22.Define circular list ?23. What are the disadvantages of circular list ?24.Define double linked list?25.Is it necessary to sort a file before searching a particular item ?26.What are the issues that hampers the efficiency in sorting a file ?27.Calculate the efficiency of sequential search ?28. Is any implicit arguments are passed to a function when it is called ?29.Parenthesis is never required in Postfix or Prefix expressions, Why?30.List out the areas in which data structures are applied extensively?31.What are the major data structures used in the following areas : network data model & Hierarchical data model.32.If you are using C language to implement the heterogeneous linked list, what pointer type will you use?

Page 18: Web viewInterview Questions. 1. What is data structure? A data structure is a way of organizing data that considers not only the items stored, but also their relationship to

33.Minimum number of queues needed to implement the priority queue?34.What is the data structures used to perform recursion?35.What are the notations used in Evaluation of Arithmetic Expressions using prefix and postfix forms?36. Convert the expression ((A + B) * C – (D – E) ^ (F + G)) to equivalent Prefix and Postfix notations.37. Sorting is not possible by using which of the following methods?38. List out few of the Application of tree data-structure?39. List out few of the applications that make use of Multilinked Structures?40. In tree construction which is the suitable efficient data structure?41. What is the type of the algorithm used in solving the 8 Queens problem?42 .In an AVL tree, at what condition the balancing is to be done?43 .There are 8, 15, 13, 14 nodes were there in 4 different trees. Which of them could have formed a full binary tree?44.In RDBMS, what is the efficient data structure used in the internal storage representation?45. Of the following tree structure, which is, efficient considering space and time complexities?(a) Incomplete Binary Tree.(b) Complete Binary Tree.(c) Full Binary Tree.46.What is a spanning Tree?47.Does the minimum spanning tree of a graph give the shortest distance between any 2 specified nodes?48.Whether Linked List is linear or Non-linear data structure?

Read more: data structures interview questions for freshers | FreeJobAlert.com http://www.freejobalert.com/data-structures/2903/#ixzz2GWIwdcYZ