The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+16 votes
1k views

The most appropriate matching for the following pairs

    X: depth first search         1: heap 
    Y: breadth-first search       2: queue 
    Z: sorting                    3: stack

is:

  1. $\text{X - 1,  Y - 2,  Z - 3}$
  2. $\text{X - 3,  Y - 1,  Z - 2}$
  3. $\text{X - 3,  Y - 2,  Z - 1}$
  4. $\text{X - 2,  Y - 3,  Z - 1}$
asked in Algorithms by Veteran (59.5k points)
edited by | 1k views

3 Answers

+16 votes
Best answer

Answer is $C$.

X - 3 DFS uses stack implicitly
Y - 2 BFS uses queue explicitly in Algo
Z - 1 Heap-Heapsort
 

answered by Boss (42.8k points)
edited by
+1
What do you mean by the words "EXPLICIT" and "IMPLICIT" here?
0
DFS algorithm directly does not use any stack but since it calls itself(recursion), recursion stack will be  used by the OS
+6 votes
Answer: C
answered by Boss (34k points)
+1 vote
Ans: C
answered by Loyal (7.3k points)
Answer:

Related questions



Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

39,778 questions
46,781 answers
140,752 comments
58,672 users