DATA STRUCTURE INTERVIEW QUESTION & ANSWERS
31. |
What is the difference between greedy and dynamic programming? |
|
greedy |
dynamic programming |
Greedy method is used for obtaining optimum solution. |
Dynamic programming is also for obtaining optimum solution. |
In Greedy method a set of feasible solutions and the picks up the optimum solution. |
There is no special set of feasible solutions in this method. |
In Greedy method the optimum selection is without revising previously generated solutions. |
Dynamic programming considers all possible sequences in order to obtain the optimum solution.
|
In Greedy method there is no as such guarantee of getting optimum solution. |
It is guaranteed that the dynamic programming will generate optimal solution
using principle of optimality. |
|
32. |
What is a node class? |
|
A node class is a class that has added new services or functionality beyond the services inherited from its base class. |
33. |
What are the types of tree transversal? |
|
There are three types of tree transversal : - Inorder transversal
-
Preorder transversal
- Post order transversal
|
34. |
What is heap? |
|
Heap is a complete binary tree or a almost complete binary tree in which every parent node be either greater or lesser than its child nodes.
|
35. |
What are the types of heap? |
|
A Max heap is a tree in which value of each node is greater than or equal to the value of its children nodes. A Min heap is a tree in which value of each node is less than or equal to value of
its children nodes.
|