DATA STRUCTURE INTERVIEW QUESTION & ANSWERS
46. |
Is merge sort stable sorting algorithm? |
|
Yes, merge sort is the stable sorting algorithm. A sorting algorithm is said to be stable if it preserves the ordering of similar (equal) elements after applying sorting method. And merge sort is a method which preserves this kind of ordering. Hence merge sort is a stable sorting algorithm.
|
47. |
What is the maximum possible height of a binary tree with N nodes? |
|
A binary tree that is either totally skewed to left or right can have height N. |
48. |
What is the height of a complete binary tree with N nodes? |
|
A complete binary tree with N nodes has the height (log N). |
49. |
What is a priority queue? |
|
A priority queue is a queue that has a ‘priority’ or ‘rank’ associated with the items that are inserted. The insertion and removal of die items from this data structure is done based on the priority of the values it stores (instead of the arrival order/time). |
50. |
What is the relationship between trees and graphs? |
|
A tree is a connected graph with no circuits (a circuit is the one where the starting point equals the end point). If we remove an edge from a tree, one or more nodes will become disconnected, so a tree is a 'minimally connected' graph. All trees are graphs (but not vice–versa).
|