algo_077
Problem Statement
Problem Statement
Write an algorithm to insert an element into a deque at the rear end.
Algorithm
procedure InsertDequeRear(DEQ, MAX, FRONT, REAR, ITEM)
begin
if (FRONT = 1 and REAR = MAX) or (FRONT = REAR + 1) then
print("Overflow")
return()
endif
if FRONT = -1 then
FRONT ← 1
REAR ← 1
else if REAR = MAX then
REAR ← 1
else
REAR ← REAR + 1
endif
DEQ[REAR] ← ITEM
end procedure1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18