Logo 
Search:

C++ Programming FAQ

Submit Interview FAQ
Home » Interview FAQ » C++ ProgrammingRSS Feeds

Write an algorithm for Deleting an element from the queue using array in dfs

  Shared By: Adalia Miller    Date: Nov 28    Category: C++ Programming    Views: 7041

Answer:

PROCEDURE DELETE(QUEUE, F, R, item)
[Deletes ‘item’ from the ‘stack’, ‘F’ is the Front end pointer and ‘R’ is the rare end pointer]

1. [Underflow ?]

if (R <= 0)
write Stack is empty.
return.

2. [Deleting Element]

item <-- QUEUE[F]

3. [Incrementing F]

F <-- F + 1

4. [Checking for empty queue]

if (F > R)
then F <-- R <-- 0
return.

Share: 
 


Related Topics:

Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: