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

The most appropriate matching for the following pairs

$$\begin{array}{|l|l|}\hline \text{X: depth first search}  &  \text{1: heap } \\\hline  \text{Y: breadth first search} & \text{2: queue} \\\hline  \text{Z: sorting} & \text{3: stack} \\\hline \end{array}$$

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 (52.1k points)
edited by | 1.3k views

3 Answers

+17 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 (41k points)
edited by
+1
What do you mean by the words "EXPLICIT" and "IMPLICIT" here?
+2
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 (33.8k points)
+1 vote
Ans: C
answered by Loyal (7.1k 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
49,814 questions
54,521 answers
188,388 comments
75,423 users