Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

What is the fundamental operation performed in skew heaps?(a) intersection(b) difference(c) merging(d) sortingThis interesting question is from Heap in section Heap of Data Structures & Algorithms II have been asked this question during an online interview.

Answer»

Right answer is (C) merging

Best explanation: The fundamental OPERATION of SKEW heaps is merging. Hence, it is similar to that of a LEFTIST HEAP.

2.

What is the time per operation of merging, insertion and deletion operations in a skew heap?(a) O(N)(b) O(log N)(c) O(N log N)(d) O(N^2)I need to ask this question from Heap topic in division Heap of Data Structures & Algorithms IThis question was posed to me during an interview.

Answer»

Correct ANSWER is (b) O(log N)

Best explanation: Skew heaps support merging, INSERTION and deletion all effectively in O(log N) TIME PER OPERATION.

3.

Why would a recursive implementation fail in skew heaps?(a) skew heaps are self adjusting(b) efficiency gets reduced(c) lack of stack space(d) time complexityMy query is from Heap topic in portion Heap of Data Structures & Algorithms IThe question was posed to me in class test.

Answer»

Correct ANSWER is (c) lack of stack SPACE

For explanation: In skew heaps, a RECURSIVE implementation could fail because of lack of stack space EVEN though performance is acceptable.

4.

Which of the following is difficult to determine the right path length?(a) Skew heaps(b) Binomial tree(c) Leftist heap(d) d-heapI need to ask this question from Heap topic in division Heap of Data Structures & Algorithms II got this question in class test.

Answer»

Correct option is (a) Skew heaps

The BEST I can EXPLAIN: It is an open problem to determine precisely the expected right path LENGTH of both LEFTIST and skew heaps and comparatively, the latter is difficult.

5.

The worst case analysis for a naïve merge is given as?(a) O(N)(b) O( log N)(c) O( N log N)(d) O(N^2)This interesting question is from Heap in portion Heap of Data Structures & Algorithms IThe question was posed to me during an online interview.

Answer»

Right choice is (a) O(N)

To EXPLAIN: The worst-case analysis for the naïve MERGE is an INSERTION in a right heavy tree. So, insertion takes O(N).

6.

How many types of the merge are available in skew heaps?(a) 1(b) 2(c) 3(d) 4I want to ask this question from Heap topic in chapter Heap of Data Structures & Algorithms IThis question was posed to me in my homework.

Answer»

The CORRECT answer is (B) 2

Best explanation: Two kinds of the merge are AVAILABLE in SKEW heaps- naïve merge and skew merge.

7.

What is the amortized efficiency of skew merge?(a) O(N)(b) O( log N)(c) O( N log N)(d) O(N^2)Question is from Heap in chapter Heap of Data Structures & Algorithms IThis question was posed to me during an interview for a job.

Answer» CORRECT option is (b) O( log N)

The best explanation: The AMORTIZED efficiency of a skew heap is mathematically FOUND to be O( log N).
8.

In skew heaps, certain constraints are to be met in order to perform swapping.(a) true(b) falseThis question is from Heap in section Heap of Data Structures & Algorithms II have been asked this question during an interview.

Answer»

The correct choice is (b) false

Best explanation: In SKEW HEAPS, swaps are UNCONDITIONAL. It is done with the exception that the largest of all NODES does not have its CHILDREN swapped.

9.

Descending priority queue can be implemented using ______(a) max heap(b) min heap(c) min-max heap(d) trieMy question is based upon Heap topic in section Heap of Data Structures & Algorithms II had been asked this question during an interview for a job.

Answer»

The correct choice is (a) MAX heap

Easiest EXPLANATION - Descending priority QUEUE arranges the ELEMENTS based on their priority or value and allows REMOVING the elements in descending order. So, it can be efficiently implemented using max heap.

10.

Min heap can be used to implement selection sort.(a) True(b) FalseThis key question is from Heap topic in chapter Heap of Data Structures & Algorithms IThis question was posed to me during an internship interview.

Answer»

Right option is (a) True

To explain: In MIN heap, the insertion and deletion operation takes O(LOGN) time. Therefore, a selection SORT with n INSERTIONS and n DELETIONS can be implemented using a min heap in O(nlogn) operations.

11.

The ascending heap property is ___________(a) A[Parent(i)] =A[i](b) A[Parent(i)] = A[i](d) A[Parent(i)] > 2 * A[i]My doubt is from Heap in portion Heap of Data Structures & Algorithms II have been asked this question in unit test.

Answer»

Right answer is (b) A[PARENT(i)] <= A[i]

Best EXPLANATION: The min heap is also known as ascending heap. Min heap of SIZE n is an almost complete binary tree of n nodes such that the element at each node is greater than or equal to the element at its parent node.

12.

The procedure FindMin() to find the minimum element and the procedure DeleteMin() to delete the minimum element in min heap take _________(a) logarithmic and linear time constant respectively(b) constant and linear time respectively(c) constant and quadratic time respectively(d) constant and logarithmic time respectivelyThe origin of the question is Heap topic in chapter Heap of Data Structures & Algorithms IThis question was posed to me in exam.

Answer»

The correct option is (d) constant and logarithmic TIME respectively

The best I can explain: In the min heap, the root is the maximum element in the tree. So, LOCATING it takes constant time, but deleting it takes logarithmic time. Because after deleting it, the root is replaced with LAST element and then the PROCEDURE to maintain the min ORDERING is invoked.

13.

Which one of the following array elements represents a binary min heap?(a) 12 10 8 25 14 17(b) 8 10 12 25 14 17(c) 25 17 14 12 10 8(d) 14 17 25 10 12 8My enquiry is from Heap topic in section Heap of Data Structures & Algorithms IThis question was posed to me in an interview.

Answer» RIGHT option is (b) 8 10 12 25 14 17

To explain: A tree is MIN heap when data at every node in the tree is smaller than or equal to it’s children’ s data. So, only 8 10 12 25 14 17 generates REQUIRED tree.
14.

In a binary min heap containing n elements, the largest element can be found in __________ time.(a) O(n)(b) O(nlogn)(c) O(logn)(d) O(1)The doubt is from Heap in portion Heap of Data Structures & Algorithms IThe question was asked in an online interview.

Answer»

Right answer is (a) O(n)

The best I can EXPLAIN: In MIN heap the SMALLEST is located at the root and the largest elements are located at the leaf nodes. So, all leaf nodes need to be checked to find the largest element. Thus, worst case TIME will be O (n).

15.

Min heap is a complete binary tree.(a) True(b) FalseMy question comes from Heap topic in portion Heap of Data Structures & Algorithms IThis question was addressed to me by my school teacher while I was bunking the class.

Answer»

Right option is (a) True

The best EXPLANATION: A tree, in which all levels are fully filled, except possibly the last LEVEL, is called as the COMPLETE binary tree. And min HEAP maintains shape property, so it is a complete binary tree. The shape property ensures that all levels in the min heap are fully filled, except the last one, and, if the last level is not filled completely, then fill the ELEMENTS from left to right.

16.

What will be the position of 5, when a max heap is constructed on the input elements 5, 70, 45, 7, 12, 15, 13, 65, 30, 25?(a) 5 will be at root(b) 5 will be at last level(c) 5 will be at second level(d) 5 can be anywhere in heapI would like to ask this question from Heap topic in division Heap of Data Structures & Algorithms IThe question was posed to me during an online interview.

Answer»

Right option is (b) 5 will be at last level

Best explanation: In MAX heap the greatest element is at the ROOT and the smallest ELEMENTS are at the last level. As 5 is the smallest INPUT element, it will be at the last level.

17.

The relationship of skew heaps to leftist heaps is analogous to that of?(a) Splay tree and AVL tree(b) Red black tree and AVL tree(c) Binary tree and Splay tree(d) Binary tree and Red black treeThe origin of the question is Heap topic in chapter Heap of Data Structures & Algorithms IThe question was asked during an internship interview.

Answer»

Right CHOICE is (a) SPLAY tree and AVL tree

The best I can explain: Splay tree is a self -ADJUSTING VERSION of AVL tree. Similarly, skew heap is a self-adjusting version of leftist heap.

18.

What is the amortized cost per operation of a skew heap?(a) O(N)(b) O(N log N)(c) O(N^2)(d) O(log N)My question is from Heap in division Heap of Data Structures & Algorithms IThe question was asked in quiz.

Answer»

The correct choice is (d) O(log N)

For explanation: The AMORTIZED cost PER operation of a SKEW heap is O(log N) since the WORST case ANALYSIS of skew heap is O(N) and splay tree is O(M log N).

19.

The worst case running time of all operations in a skew heap is given as?(a) O(N)(b) O(N log N)(c) O(N^2)(d) O(M log N)My query is from Heap topic in section Heap of Data Structures & Algorithms IThe question was posed to me in an online interview.

Answer»

The correct answer is (a) O(N)

Easiest explanation - The worst CASE running TIME of all operations in a skew HEAP is MATHEMATICALLY found to be O(N).

20.

___________ is a self-adjusting version of a leftist heap.(a) Rightist heap(b) Skew heap(c) d-heap(d) Binary heapThis interesting question is from Heap in portion Heap of Data Structures & Algorithms II had been asked this question during an interview for a job.

Answer» CORRECT option is (b) Skew HEAP

The BEST I can EXPLAIN: A skew heap is a self-adjusting version of a LEFTIST heap and it is simpler to implement.
21.

In what time can a leftist heap be built?(a) O(N)(b) O(N log N)(c) O(log N)(d) O(M log N)The query is from Heap topic in portion Heap of Data Structures & Algorithms IThe question was asked in a job interview.

Answer»

Right CHOICE is (a) O(N)

BEST EXPLANATION: The mathematical calculation yields a result that, a leftist heap can be built in O(N) time by BUILDING a binary heap.

22.

What is the time taken to delete a minimum element in a leftist heap?(a) O(N)(b) O(N log N)(c) O(log N)(d) O(M log N)My enquiry is from Heap in portion Heap of Data Structures & Algorithms IThis question was posed to me in my homework.

Answer»

Correct ANSWER is (c) O(log N)

The explanation is: The time TAKEN to delete a minimum element in a LEFTIST HEAP is mathematically found to be O(log N).

23.

What happens if the null path length is not updated?(a) error occurs(b) all null path lengths will be 0(c) all null path lengths will be -1(d) all null path lengths will be 1My query is from Heap topic in division Heap of Data Structures & Algorithms II had been asked this question in an online interview.

Answer» RIGHT choice is (b) all null path lengths will be 0

Explanation: While performing insertion VIA merge OPERATION in a leftist HEAP, if the null path length is not updated, all null path lengths will be 0.
24.

What would be the result if the left subtree of the root has a null path length of 1 and the right subtree has a null path length of 2?(a) merge occurs without violation(b) violation at left subtree(c) violation at right subtree(d) violation at the rootMy question comes from Heap in chapter Heap of Data Structures & Algorithms II got this question during an interview.

Answer»

Correct answer is (d) violation at the root

To explain: When two leftist HEAPS are merged, if the left subtree of the root has a null path length of 1 and the right subtree has a null path length of 2, leftist PROPERTY is violated at the root.

25.

In a leftist heap, all the operations should be performed on?(a) left path(b) centre path(c) right path(d) rootThis intriguing question comes from Heap in portion Heap of Data Structures & Algorithms IThe question was asked in unit test.

Answer»

The correct answer is (c) RIGHT PATH

The EXPLANATION is: All the operations are PERFORMED on the right path because right paths are short. HOWEVER, insertion and merges cannot be performed on the right path.

26.

Why is this heap named leftist heap?(a) only left subtrees exist(b) the tree is biased to get deep down the left(c) it is balanced(d) right trees are unbalancedThe origin of the question is Heap topic in chapter Heap of Data Structures & Algorithms II got this question in my homework.

Answer»

Right option is (B) the tree is biased to GET DEEP down the left

The best explanation: The heap is named as leftist heap because it tends to have deep left paths. It FOLLOWS that the right path ought to be SHORT.

27.

What is the node path length of a node with 0 or 1 child?(a) 1(b) -1(c) 0(d) nullThe query is from Heap in chapter Heap of Data Structures & Algorithms IThis question was addressed to me in an interview for internship.

Answer»

The correct answer is (C) 0

The explanation is: The length of the shortest path from a NODE to a node without TWO children is defined as 0.

28.

What is the efficiency of merge used in leftist heaps?(a) O(N)(b) O(N log N)(c) O(M log N)(d) O(log N)Origin of the question is Heap topic in division Heap of Data Structures & Algorithms IThe question was posed to me in an interview for job.

Answer»

Correct answer is (d) O(LOG N)

The best explanation: The efficiency of MERGE operations in leftist heap is mathematically found to be O( log N) which is the same in binary heaps.

29.

A leftist heap is also said to be a binary heap.(a) true(b) falseMy question comes from Heap topic in chapter Heap of Data Structures & Algorithms II have been asked this question in final exam.

Answer»

The correct answer is (a) true

Easiest EXPLANATION - A LEFTIST heap has a STRUCTURAL property and an ordering property which is similar to that of a binary heap. Hence, leftist heap is also SAID to be binary heap.

30.

What is the fundamental operation on leftist heap?(a) insertion(b) merging(c) deletion(d) swappingMy question is taken from Heap topic in section Heap of Data Structures & Algorithms IThis question was addressed to me in a job interview.

Answer»

The correct option is (b) merging

The EXPLANATION is: The fundamental OPERATIONS on leftist heaps is MERGE. Insertion operation is a merge of a one-node heap with a LARGER heap.

31.

Which of the following operations does not destroy the leftist heap property?(a) insert(b) merge(c) delete(d) swapThe query is from Heap topic in portion Heap of Data Structures & Algorithms IThis question was addressed to me in class test.

Answer»

The correct ANSWER is (c) delete

Best EXPLANATION: Performing insert and merge operations on the right path COULD destroy the leftist HEAP property. It is extremely easy to restore that property.

32.

How many nodes does a leftist tree with r nodes must have?(a) 2^r(b) 2^r-1(c) 2r(d) 2r-1My doubt is from Heap in section Heap of Data Structures & Algorithms II got this question in an interview.

Answer»

Correct answer is (B) 2^r-1

The best explanation: A leftist tree with r NODES on the RIGHT path is proved to have at least 2^r-1 nodes. This theorem is proved by induction.

33.

In a leftist heap, the null path length of a null node is defined as?(a) 0(b) 1(c) null(d) -1I'm obligated to ask this question of Heap topic in chapter Heap of Data Structures & Algorithms IThis question was posed to me in an interview for internship.

Answer»

Correct choice is (d) -1

To EXPLAIN: In a LEFTIST heap tree, the null path length of a null NODE with no CHILDREN is defined as -1.

34.

How many properties does a leftist heap support?(a) 1(b) 2(c) 3(d) 4This interesting question is from Heap topic in division Heap of Data Structures & Algorithms II got this question in homework.

Answer»

Correct choice is (c) 3

To EXPLAIN: A leftist HEAP supports TWO properties- structural property, ORDERING property and a heap order property.

35.

Pointer manipulation is generally more time-consuming than multiplication and division.(a) true(b) falseMy doubt is from Heap topic in section Heap of Data Structures & Algorithms II have been asked this question in class test.

Answer»

The CORRECT answer is (a) true

Easiest explanation - USE of pointers for merging reduces the speed of other operations. This is the main drawback of all ADVANCED data structures.

36.

What is the run time efficiency of an insertion algorithm?(a) O(N)(b) O(log N)(c) O(N^2)(d) O(M log N)My doubt stems from Heap topic in section Heap of Data Structures & Algorithms IThis question was addressed to me in my homework.

Answer»

The CORRECT option is (a) O(N)

BEST explanation: The run time EFFICIENCY of an insertion ALGORITHM in a pairing heap is mathematically found to be O(N).

37.

Out of the following given options, which is the fastest algorithm?(a) fibonacci heap(b) pairing heap(c) d-ary heap(d) binary heapMy enquiry is from Heap in section Heap of Data Structures & Algorithms IThis question was posed to me in a job interview.

Answer»

Correct option is (a) fibonacci heap

The best I can explain: ALTHOUGH pairing heap is an efficient algorithm, it is worse than the Fibonacci heap. Also, pairing heap is FASTER than d-ary heap and BINARY heap.

38.

The amortized time efficiency for performing deletion of a minimum element is?(a) O(N)(b) O(log N)(c) O(N^2)(d) O(M log N)I need to ask this question from Heap in chapter Heap of Data Structures & Algorithms II have been asked this question in semester exam.

Answer»

The CORRECT answer is (b) O(log N)

Best explanation: The AMORTIZED time efficiency for performing DELETION of a minimum element is mathematically FOUND to be O(log N).

39.

The roots of the elements of the subtrees are smaller than the root of the heap.(a) True(b) FalseThis intriguing question originated from Heap in chapter Heap of Data Structures & Algorithms II have been asked this question in homework.

Answer»

Correct CHOICE is (B) False

For explanation: The heap ordering PROPERTY requires that all the root ELEMENTS of the subtrees in the list are not SMALLER than the root element of the heap.

40.

Pairing heaps time complexity was inspired by that of?(a) splay tree(b) treap(c) red-black tree(d) avl treeMy query is from Heap in division Heap of Data Structures & Algorithms IThis question was posed to me in an international level competition.

Answer»

Correct ANSWER is (a) splay tree

Explanation: The pairing HEAPS insertion, deletion and search time complexity was initially INSPIRED by that of splay TREES.

41.

Which of the following methods is the best choice for complex applications?(a) binary heap(b) d-heap(c) treap(d) pairing heapMy question comes from Heap topic in section Heap of Data Structures & Algorithms II have been asked this question during an interview for a job.

Answer»

The correct option is (d) pairing HEAP

BEST explanation: Pairing heap is the best choice for COMPLEX APPLICATIONS because it is SIMPLE and better than the others.

42.

If there are c children of the root, how many calls to the merge procedure is required to reassemble the heap?(a) c(b) c+1(c) c-1(d) 1Asked question is from Heap in division Heap of Data Structures & Algorithms IThis question was addressed to me in class test.

Answer»

Correct ANSWER is (C) c-1

Best explanation: If there are c children of the root, then c-1 MERGES are required to reassemble the pairing heap.

43.

What is the basic operation performed in a pairing heap?(a) merge(b) deletion(c) insertion(d) swappingI'm obligated to ask this question of Heap topic in portion Heap of Data Structures & Algorithms II have been asked this question by my school principal while I was bunking the class.

Answer»

Right choice is (a) merge

Best explanation: The basic operation performed in a PAIRING HEAP is merging. INSERTION is ALSO DONE by merging.

44.

Which of the heaps is implemented by the following figure?(a) fibonacci heaps(b) pairing heap(c) skew heap(d) leftist heapThe above asked question is from Heap in portion Heap of Data Structures & Algorithms IThis question was addressed to me in quiz.

Answer» CORRECT answer is (b) PAIRING heap

The best I can explain: The above figure is a REPRESENTATION of a pairing heap because it has LEFT CHILDREN and right siblings.
45.

Which node contains a pointer to its parent?(a) root node(b) right most child(c) left most child(d) left siblingMy enquiry is from Heap topic in portion Heap of Data Structures & Algorithms IThis question was posed to me during an internship interview.

Answer»

Correct option is (c) left most child

Easiest explanation - A NODE that is a LEFTMOST node contains a POINTER to its parent, otherwise, the node is a right SIBLING.

46.

How is a pairing heap represented?(a) binary tree(b) fibonacci tree(c) heap ordered tree(d) treapThis intriguing question comes from Heap in portion Heap of Data Structures & Algorithms IThe question was posed to me in semester exam.

Answer»

The CORRECT choice is (c) heap ordered TREE

Best explanation: A pairing heap is represented as a heap-ordered tree and the ANALYSIS of pairing heap is open.

47.

What is the reason for the efficiency of a pairing heap?(a) simplicity(b) time-efficient(c) space-efficient(d) advancedI'd like to ask this question from Heap in division Heap of Data Structures & Algorithms IThe question was asked during an online interview.

Answer»

The CORRECT OPTION is (a) SIMPLICITY

Explanation: The reason for the simplicity of a pairing heap is its simplicity as it is SIMPLER and outperform other heap STRUCTURES.

48.

Which of the following is the application of minimum ternary heap?(a) Prim’s Algorithm(b) Euclid’s Algorithm(c) Eight Queen Puzzle(d) TreeEnquiry is from Ternary heap in section Heap of Data Structures & Algorithms II got this question during an interview.

Answer»

The CORRECT option is (a) Prim’s ALGORITHM

To explain: When working on the graph in the COMPUTER science field, the Prim’s Algorithm for spanning trees uses a minimum ternary heap as there are delete operation equal to a number of edges and DECREASE priority operation equal to the number of vertices associated with the graph.

49.

What is the time complexity for creating a ternary heap using swapping?(a) O (log n/ log 3)(b) O (n!)(c) O (n)(d) O (1)The question is from Ternary heap in chapter Heap of Data Structures & Algorithms IThe question was posed to me in class test.

Answer»

The correct answer is (C) O (n)

The explanation is: Ternary Heap can be formed by TWO swapping operations. Therefore, the TIME complexity for creating a ternary heap using two swapping operation is FOUND to be O (n).

50.

Do ternary heap have better memory cache behavior than binary heap.(a) True(b) FalseThis intriguing question originated from Ternary heap topic in section Heap of Data Structures & Algorithms IThis question was addressed to me in a national level competition.

Answer»

The correct choice is (a) True

The BEST EXPLANATION: Ternary heap is a type of DATA structure in the field of computer science. It is a PART of the Heap data structure family. Due to the SWAPPING process, they have better memory cache behavior.