algo_042
Problem Statement
Problem Statement
Write an algorithm to enqueue an element into a circular queue using linked representation.
Algorithm
procedure enqueue(cq, val)
begin
ptr ← getNode();
info(ptr) ← val;
next(ptr) ← ptr;
if (cq = NULL) then
cq ← ptr;
else
next(ptr) ← next(cq);
next(cq) ← ptr;
cq ← ptr;
endif
return(cq);
end procedure1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14