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.

51.

What is the time complexity for decreasing priority of key in a maximum ternary heap of n elements?(a) O (log n/ log 3)(b) O (3log n/ log 3)(c) O (n)(d) O (1)This key question is from Ternary heap in section Heap of Data Structures & Algorithms IThis question was posed to me in examination.

Answer»

Correct choice is (B) O (3log n/ log 3)

The explanation is: In order to decrease the priority of key in a maximum ternary heap DATA STRUCTURE having n elements, it performs downward SWAPPING. So the time complexity for worst case is found to be O (3log n/ log 3).

52.

What is the time complexity for increasing priority of key in a minimum ternary heap of n elements?(a) O (log n/ log 3)(b) O (3log n/ log 3)(c) O (n)(d) O (1)This interesting question is from Ternary heap topic in section Heap of Data Structures & Algorithms II had been asked this question by my school principal while I was bunking the class.

Answer»

The correct answer is (b) O (3LOG n/ log 3)

Explanation: In order to the INCREASING the priority of key in a minimum ternary heap data structure having n elements, it performs downward swapping. So the time COMPLEXITY for WORST case is found to be O (3log n/ log 3).

53.

What is the time complexity for deleting root key in a ternary heap of n elements?(a) O (log n/ log 3)(b) O (3log n/ log 3)(c) O (n)(d) O (1)I need to ask this question from Ternary heap topic in portion Heap of Data Structures & Algorithms IThis question was posed to me in a job interview.

Answer»

The correct OPTION is (b) O (3log N/ log 3)

The explanation is: In order to delete a root key in a ternary heap data structure having n elements, it performs downward swapping. So the time COMPLEXITY for WORST case is found to be O (3log n/ log 3).

54.

What is the time complexity for increasing priority of key in a maximum ternary heap of n elements?(a) O (log n/ log 3)(b) O (n!)(c) O (n)(d) O (1)This key question is from Ternary heap topic in chapter Heap of Data Structures & Algorithms II got this question during an interview.

Answer»

The correct choice is (a) O (log N/ log 3)

The explanation is: In order to increase the PRIORITY of an item in a ternary heap data structure having n elements, it performs upwards swapping. So the time complexity for WORST case is found to be O (log n/ log 3).

55.

What is the time complexity for decreasing priority of key in a minimum ternary heap of n elements?(a) O (log n/ log 3)(b) O (n!)(c) O (n)(d) O (1)Enquiry is from Ternary heap topic in section Heap of Data Structures & Algorithms II have been asked this question during an online interview.

Answer»

The correct option is (a) O (log N/ log 3)

Explanation: In order to decrease the priority of an item in a ternary heap data structure having n elements, the heap has great EFFICIENCY for DECREASING them. So the time COMPLEXITY for WORST case is found to be O (log n/ log 3). This is due to the upwards swapping process.

56.

Is decrease priority operation performed more quickly in a ternary heap with respect to the binary heap.(a) True(b) FalseThis question is from Ternary heap in chapter Heap of Data Structures & Algorithms IThe question was posed to me in semester exam.

Answer»

Correct option is (a) True

The EXPLANATION is: 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, the decrease priority operation performs more quickly in a ternary heap.

57.

What is the time complexity for inserting a new item in a ternary heap of n elements?(a) O (log n/ log 3)(b) O (n!)(c) O (n)(d) O (1)The query is from Ternary heap in portion Heap of Data Structures & Algorithms II got this question in final exam.

Answer»

The CORRECT answer is (a) O (log n/ log 3)

Best EXPLANATION: In order to insert a new item in a TERNARY HEAP data structure having n elements, the heap has great efficiency for inserting them. So the time complexity for worst CASE is found to be O (log n/ log 3).

58.

Who invented d-ary heap?(a) Carl Rick(b) Alan Turing(c) Donald Johnson(d) EuclidQuestion is from Ternary Heap topic in chapter Heap of Data Structures & Algorithms II had been asked this question in a job interview.

Answer»

The CORRECT answer is (c) DONALD Johnson

The explanation is: Ternary heap is a TYPE of data structure in the field of computer science. It is a part of the Heap data structure family. The d-ary heap was invented by Donald Johnson in the year 1975.

59.

What is a ternary heap?(a) An array with three elements(b) Linked list with three elements(c) Tree with three children(d) Heap with all nodes having three childrenThe doubt is from Ternary Heap in portion Heap of Data Structures & Algorithms IThe question was asked in an interview for job.

Answer»

Right OPTION is (d) HEAP with all nodes having THREE children

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. So, it follows all the property of heap. THEREFORE, all the nodes in the ternary heap have 3 nodes.

60.

Is the priority queue abstract data type.(a) True(b) FalseThis interesting question is from Ternary Heap in chapter Heap of Data Structures & Algorithms II had been asked this question in class test.

Answer»

Correct OPTION is (a) True

To explain: Priority QUEUE is an ABSTRACT data type. It is also the extension of the Queue data STRUCTURE where all the ELEMENTS have been assigned some priority and on the basis of this priority, the elements are dequeued from the structure.

61.

Which type of data structure is a ternary heap?(a) Array(b) Hash(c) Priority Queue(d) Priority StackThe above asked question is from Ternary Heap in chapter Heap of Data Structures & Algorithms II had been asked this question during an interview for a job.

Answer»

The correct option is (c) Priority Queue

For 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. It is a priority queue type of data structure that follows all the property of heap.

62.

What is the process of building a ternary heap called?(a) Heapify(b) Hashing(c) Linking(d) MergingMy question is based upon Ternary Heap topic in chapter Heap of Data Structures & Algorithms IThe question was asked in a job interview.

Answer»

Right choice is (a) Heapify

Easy 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. So, the process of building a ternary heap is KNOWN as Heapify.

63.

Should leaves in ternary heap be distributed from left to right.(a) True(b) FalseThis interesting question is from Ternary Heap topic in portion Heap of Data Structures & Algorithms IThe question was asked during an interview.

Answer»

The correct option is (a) True

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. So, it should hold all the properties of Heap that is all the LEVELS of the heap has to be filled from left to right.

64.

Which property should ternary heap hold for execution?(a) Associative(b) Commutative(c) Tree(d) HeapQuery is from Ternary Heap topic in portion Heap of Data Structures & Algorithms II had been asked this question in an online interview.

Answer»

Correct answer is (d) Heap

For 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. So, it should hold all the properties of Heap that is all the levels of the heap has to be filled from left to right.

65.

What is the height of a given minimum ternary heap?(a) 1(b) 10(c) 2(d) 24The question is from Ternary Heap in portion Heap of Data Structures & Algorithms II have been asked this question in a national level competition.

Answer»

Right option is (a) 1

Explanation: Minimum ternary heap has the SMALLEST element as its root node. The parent node is all either EQUAL or less than children node in a minimum ternary heap. Height is the TOTAL length from the root node to the leaf node. So the height of the minimum ternary heap is 1.

66.

What are the siblings of smallest element of the given maximum ternary heap?(a) 31(b) 12(c) 18(d) 22This intriguing question originated from Ternary Heap topic in portion Heap of Data Structures & Algorithms II had been asked this question in an online quiz.

Answer»

The correct answer is (c) 18

Explanation: MAXIMUM ternary heap has the HIGHEST element as its root node. The parent node is all EITHER EQUAL or greater than CHILDREN node in a maximum ternary heap. The smallest element in the maximum ternary heap is 10 and its siblings are 18, 20.

67.

What is the child of smallest element of the given minimum ternary heap?(a) 1(b) 10(c) 22(d) 24My query is from Ternary Heap in section Heap of Data Structures & Algorithms II had been asked this question in an online interview.

Answer»

The CORRECT choice is (B) 10

For explanation: Minimum ternary heap has the smallest element as its ROOT node. The PARENT node is all either equal or less than children node in a minimum ternary heap. In the above minimum ternary heap, the smallest element is 1 and its children are 10, 18, 20.

68.

What is the highest element of the given maximum ternary heap?(a) 31(b) 10(c) 18(d) 20The doubt is from Ternary Heap in chapter Heap of Data Structures & Algorithms II got this question in unit test.

Answer»

Right option is (a) 31

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. Maximum ternary heap has the highest ELEMENT as its root NODE. The parent node is all either equal or greater than children node in a maximum ternary heap.

69.

What is the smallest element of the given minimum ternary heap?(a) 1(b) 10(c) 18(d) 20The doubt is from Ternary Heap topic in section Heap of Data Structures & Algorithms IThis question was addressed to me during an interview for a job.

Answer» RIGHT option is (a) 1

For 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. Minimum ternary heap has the smallest element as its ROOT NODE. The parent node is all EITHER equal or less than children node in a minimum ternary heap.
70.

On which data structure is a d-ary heap based?(a) stack(b) queue(c) linked list(d) priority queueI'd like to ask this question from Heap in portion Heap of Data Structures & Algorithms IThe question was posed to me in a national level competition.

Answer» CORRECT choice is (d) priority queue

The best EXPLANATION: d-ary heap is a priority queue based data structure that is a GENERALIZATION of BINARY heaps.
71.

How many secondary operations are performed in a d-heap?(a) 1(b) 2(c) 3(d) 4The above asked question is from Heap topic in portion Heap of Data Structures & Algorithms IThe question was asked in unit test.

Answer» CORRECT ANSWER is (d) 4

For explanation: The other OPERATIONS that can be performed in a d-heap are increasekey, decreasekey, buildheap and delete.
72.

Multiplication and division to find children and parents cannot be implemented in a d-heap.(a) true(b) falseThe question is from Heap in section Heap of Data Structures & Algorithms IThe question was asked during an interview.

Answer»

The correct answer is (b) false

Easy explanation - MULTIPLICATION and division for FINDING CHILDREN and parents can be IMPLEMENTED in a d-heap but d should be a power of 2.

73.

The following figure is an example for(a) d-heap(b) binary heap(c) leftist heap(d) skew heapI need to ask this question from Heap topic in section Heap of Data Structures & Algorithms IThis question was addressed to me in a national level competition.

Answer»

Right answer is (a) d-HEAP

Best EXPLANATION: The GIVEN heap is a d-heap since it looks LIKE a binary heap with d- children. Here, d=3.

74.

What is the run time efficiency of delete-min operation?(a) O(log N)(b) O(logd N)(c) O(d logd N)(d) O(d)Origin of the question is Heap in section Heap of Data Structures & Algorithms II have been asked this question in an online interview.

Answer»

The correct answer is (C) O(d logd N)

EXPLANATION: The run time efficiency of a delete-min ALGORITHM USING d-1 comparisons is mathematically FOUND to be O(d logd N).

75.

How many basic operations can be performed in a d-heap?(a) 1(b) 2(c) 3(d) 4Query is from Heap in section Heap of Data Structures & Algorithms IThis question was posed to me in quiz.

Answer»

The CORRECT option is (b) 2

Best EXPLANATION: The two basic OPERATIONS PERFORMED in a d-heap are insert and delete-min operations.

76.

How many comparisons will occur while performing a delete-min operation?(a) d(b) d-1(c) d+1(d) 1Question is taken from Heap in chapter Heap of Data Structures & Algorithms IThe question was posed to me in quiz.

Answer»

Right choice is (b) d-1

Easy explanation - SINCE, the delete-min operation is more expensive and the HEAP is SHALLOW, the MINIMUM of d elements can be FOUND using d-1 comparisons.

77.

What is the run time efficiency of an insertion algorithm in d-heap?(a) O(N)(b) O(log N)(c) O(logd N)(d) O(N^d)The query is from Heap topic in portion Heap of Data Structures & Algorithms IThis question was posed to me by my college director while I was bunking the class.

Answer»

Right option is (c) O(logd N)

Easy EXPLANATION - The run TIME efficiency of an insertion algorithm in a d-heap is FOUND to be O(logd N) where d is the NUMBER of children.

78.

Which operation is not efficiently performed in a d-heap?(a) insert(b) delete(c) find(d) mergeThe origin of the question is Heap in chapter Heap of Data Structures & Algorithms II had been asked this question by my school principal while I was bunking the class.

Answer» RIGHT option is (d) merge

The best I can explain: UNLIKE FIND operation, which cannot be PERFORMED in a d-heap, the task of merging two d-heaps is very DIFFICULT.
79.

Which operation cannot be directly performed in a d-heap?(a) insert(b) delete(c) find(d) createMy question is based upon Heap topic in portion Heap of Data Structures & Algorithms II had been asked this question in an interview for internship.

Answer»

The CORRECT ANSWER is (C) find

Explanation: Find operation in a d-heap cannot be performed as in other HEAPS. This is the main WEAKNESS of d-heap.

80.

d-heap is shallower than a binary heap.(a) true(b) falseOrigin of the question is Heap topic in division Heap of Data Structures & Algorithms II had been asked this question in an internship interview.

Answer»

The CORRECT choice is (a) true

The explanation is: d-heap is much SHALLOWER than a binary heap with respect to PERFORMANCE efficiency of insert and delete OPERATIONS.

81.

d-heap is similar to that of a?(a) binary heap(b) fibonacci heap(c) leftist heap(d) treapQuestion is taken from Heap topic in section Heap of Data Structures & Algorithms II have been asked this question in my homework.

Answer»

Correct answer is (a) BINARY HEAP

Easiest explanation - A d-heap is SIMILAR to that of a binary heap EXCEPT that binary heaps have two children and d-heaps have d children.

82.

Choose the option with function having same complexity for a fibonacci heap.(a) Insertion, Union(b) Insertion, Deletion(c) extract_min, insertion(d) Union, deleteMy question is from Binomial and Fibonacci Heap in portion Heap of Data Structures & Algorithms II had been asked this question by my school teacher while I was bunking the class.

Answer»

The CORRECT option is (a) INSERTION, Union

Easiest explanation - For a FIBONACCI HEAP insertion, union take O(1) while REMAINING take O(logn) time.

83.

Given a heap of n nodes.The maximum number of tree for building the heap is.(a) n(b) n-1(c) n/2(d) lognMy question is based upon Binomial and Fibonacci Heap topic in chapter Heap of Data Structures & Algorithms II had been asked this question by my school principal while I was bunking the class.

Answer»

The correct option is (a) n

Explanation: Each node could be seen as a TREE with only one node and as a result maximum SUBTREE in the HEAP is EQUAL to number of NODES in the heap.

84.

The Statement “Fibonacci heap has better amortized running time in compare to a binomial heap”.(a) True(b) FalseMy doubt stems from Binomial and Fibonacci Heap in chapter Heap of Data Structures & Algorithms II got this question in final exam.

Answer»

Correct choice is (a) True

Best explanation: Overall COMPLEXITY of insertion, merging, deleting is in ORDER of O((a+b)logn) For FIBONACCI the complexity REDUCES to O(a+ blogn).

85.

Which of these operations have same complexities?(a) Insertion, find_min(b) Find_min, union(c) Union, Insertion(d) Deletion, Find _maxQuery is from Binomial and Fibonacci Heap in section Heap of Data Structures & Algorithms IThis question was posed to me in an online quiz.

Answer»

Correct OPTION is (c) Union, Insertion

The best I can explain: With proper implementation USING link list find_min and find_max operation can be done in O(1), while the REMAINING takes O(LOGN) TIME.

86.

Time taken in decreasing the node value in a binomial heap is(a) O(n)(b) O(1)(c) O(logn)(d) O(nlogn)I'm obligated to ask this question of Binomial and Fibonacci Heap in portion Heap of Data Structures & Algorithms IThe question was posed to me in exam.

Answer»

Correct option is (c) O(LOGN)

Explanation: Decreasing a node value may result in VIOLATING the min property. As a result be there would be exchange in the value of PARENT and child which at max goes up to HEIGHT of the HEAP.

87.

What is order of resultant heap after merging two tree of order k?(a) 2*k(b) k+1(c) k*k(d) k+logkAsked question is from Binomial and Fibonacci Heap in section Heap of Data Structures & Algorithms IThis question was addressed to me in an online quiz.

Answer»

Right option is (B) k+1

Easiest EXPLANATION - This COULD be EASILY verified by looking at the structure of a binomial heap.

88.

In a binomial heap the root value is greater than left child and less than right child.(a) True(b) FalseAsked question is from Binomial and Fibonacci Heap topic in section Heap of Data Structures & Algorithms II had been asked this question in a job interview.

Answer» CORRECT choice is (b) False

The explanation is: Binomial TREE USED in MAKING binomial heap FOLLOWS min heap property.
89.

The number of trees in a binomial heap with n nodes is(a) logn(b) n(c) nlogn(d) n/2My question is from Binomial and Fibonacci Heap in portion Heap of Data Structures & Algorithms IThis question was posed to me in quiz.

Answer»

The CORRECT CHOICE is (a) logn

The best I can explain: At each DEPTH there is a BINOMIAL tree in a binomial HEAP.

90.

The main distinguishable characterstic of a binomial heap from a binary heap is that(a) it allows union operations very efficiently(b) it does not allow union operations that could easily be implemented in binary heap(c) the heap structure is not similar to complete binary tree(d) the location of child node is not fixed i.e child nodes could be at level (h-2) or (h-3), where h is height of heap and h>4My enquiry is from Binomial and Fibonacci Heap in portion Heap of Data Structures & Algorithms II had been asked this question by my school teacher while I was bunking the class.

Answer»

The correct answer is (a) it allows union OPERATIONS very EFFICIENTLY

The best explanation: The main use of BINOMIAL heap is to unify two different heap efficiently.

91.

Theleaf node for a heap of height h will be at which position.(a) h(b) h-1(c) h or h-1(d) h-2This key question is from Weak Heap in portion Heap of Data Structures & Algorithms II had been asked this question during an interview.

Answer»

Right OPTION is (c) H or h-1

For explanation: A complete binary tree is ALSO a HEAP so by the PROPERTY of binary tree the leaf nodes will be must at height h or h-1.

92.

Does there exist a heap with seven distinct elements so that the Inorder traversal gives the element in sorted order.(a) Yes(b) NoQuestion is taken from Weak Heap in chapter Heap of Data Structures & Algorithms II got this question by my college director while I was bunking the class.

Answer»

Right answer is (b) No

Best explanation: No, The INORDER traversal will not give elements in SORTED order. As heap is implemented as either min-heap or max-heap, the ROOT will be have highest or lowest VALUE than remaining values of the nodes. So this traversal will not give a sorted list.

93.

The total comparisons in finding both smallest and largest elements are(a) 2*n +2(b) n + ((n+1)/2) -2(c) n+logn(d) n^2Question is from Weak Heap topic in chapter Heap of Data Structures & Algorithms IThe question was posed to me in an interview.

Answer»

The CORRECT option is (b) N + ((n+1)/2) -2

The best explanation: The total COMPARISONS in FINDING smallest and LARGEST elements is n + ((n+1)/2) – 2.

94.

What is the worst case time in searching minimum value in weak -heap?(a) O(log n)(b) O(n)(c) O(n logn)(d) O(1)This intriguing question comes from Weak Heap topic in portion Heap of Data Structures & Algorithms IThe question was posed to me in examination.

Answer»

The correct CHOICE is (d) O(1)

EASY EXPLANATION - Weak HEAP is an array based FORM that supports the operation of finding a minimum in O(1).

95.

What is the other name of weak heap?(a) Min-heap(b) Max-heap(c) Relaxed -heap(d) Leonardo heapMy doubt stems from Weak Heap topic in division Heap of Data Structures & Algorithms II have been asked this question in examination.

Answer»

Right answer is (c) RELAXED -HEAP

The BEST explanation: Relaxedheap is just ANOTHER name of WEAK heap.

96.

Left child of parent node has value lesser than the parent node.(a) True(b) FalseOrigin of the question is Weak Heap in portion Heap of Data Structures & Algorithms IThis question was posed to me in quiz.

Answer»

The correct choice is (B) False

The BEST explanation: Weak heap has no LEFT CHILD.

97.

Choose the correct properties of weak-heap.(a) Every node has value greater than the value of child node(b) Every right child of node has greater value than parent node(c) Every left child of node has greater value than parent node(d) Every left and right child of node has same value as parent nodeThe question is from Weak Heap in division Heap of Data Structures & Algorithms II had been asked this question during an interview for a job.

Answer»

Right option is (B) Every right CHILD of node has greater value than parent node

The BEST explanation: This is the PROPERTY of a weak HEAP.

98.

Given an array of element 5, 7, 9, 1, 3, 10, 8, 4. Which of the following are the correct sequences of elements after inserting all the elements in a min-heap?(a) 1,3,4,5,7,8,9,10(b) 1,4,3,9,8,5,7,10(c) 1,3,4,5,8,7,9,10(d) 1,3,7,4,8,5,9,10My doubt stems from Binary Heap in section Heap of Data Structures & Algorithms IThe question was asked during an online exam.

Answer»

The CORRECT choice is (a) 1,3,4,5,7,8,9,10

Easy explanation - Building a min-heap the RESULT will a sorted array so the 1, 3, 4, 5, 7, 8, 9, 10 is correct. If we change the implementation strategy 1, 4, 3, 8, 9, 5, 7, 10 is also correct. (First filling the right child RATHER than left child first).

99.

What is the location of a parent node for any arbitary node i?(a) (i/2) position(b) (i+1)/ position(c) floor(i/2) position(d) ceil(i/2) positionThe above asked question is from Binary Heap topic in chapter Heap of Data Structures & Algorithms IThis question was posed to me by my school teacher while I was bunking the class.

Answer»

Right choice is (c) floor(i/2) position

The best I can EXPLAIN: For any NODE CHILD NODES are located at either 2*i, 2*i +1 So the parent node could be found by taking the floor of the half of child node.

100.

What is the best case complexity in building a heap?(a) O(nlogn)(b) O(n^2)(c) O(n*longn *logn)(d) O(n)Origin of the question is Binary Heap in portion Heap of Data Structures & Algorithms IThe question was asked by my school teacher while I was bunking the class.

Answer»

The correct OPTION is (d) O(n)

For EXPLANATION: The best CASE complexity OCCURS in bottom-up CONSTRUCTION when we have a sortes array given.