retagged by
1,119 views
2 votes
2 votes

Fill in the blanks in the procedure:

void
Prod (Element Type X, Priority Queue H)
{
int i;
if (IsFull(H))
{
Error ("Priority queue is full");
return;
}
for (i=++H -> size; H -> Elements [i/2]>X; i/=2)
_________________
}


Find the statement which has to be placed below the for loop for inserting a key.

  1. $H$$\rightarrow$ Elements $[i]=H$ $\rightarrow$ Elements [i/2];       $H$ $\rightarrow$Elements $[i] = X$;
  2. $H$$\rightarrow$ Elements $[i/2]=H$$\rightarrow$ Elements $[i/2]$;
  3. $H$$\rightarrow$ Elements $[i^2 ]=X;$
  4. $H$$\rightarrow$ Elements $[i]=X;$
retagged by

1 Answer

Best answer
0 votes
0 votes
This is a pseudo-code to insert a Node in a Priority queue.

The above code for insertion of node in min heap .

Option A is correct .
selected by
Answer:

Related questions

4 votes
4 votes
2 answers
2
Bikram asked Jan 16, 2017
886 views
Hash a list of $3$ keys into hash table with $20$ locations. What will be the probability of the event $A$ in which hashing the three keys causes a collision?$0.123$$0.14...
0 votes
0 votes
1 answer
3
Bikram asked Jan 16, 2017
627 views
Let $f\left ( n \right )$m $g\left ( n \right )$ and $h\left ( n \right )$ be functions whose domain is a subset of positive integers such that $f\left ( n \right )= O\l...