Logo 
Search:

C++ Programming FAQ

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

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

  Shared By: Abby Fischer    Date: Oct 11    Category: C++ Programming    Views: 8394

Answer:

PROCEDURE CQDELETE(QUEUE, F, R, item,N)
[Deletes ‘item’ from the ‘queue’, ‘F’ is the Front end pointer and ‘R’ is the rare end pointer and ‘N’ is the number of elements in queue]

1. [Underflow ?]

if (F = 0)
write Stack is empty.
return.

2. [Insert element]

QUEUE [R] <-- item

3. [Checking for empty queue]

if (F = R)
then F <-- R <-- 0
return(item).

4. [Setting the front pointer]

if (F = N)
then F <-- 1
F <-- F + 1
return (item).

Share: 
 


Related Topics:

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


Tagged: