Bai 3

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

create array a

let int n be the a's maximun size (the queue size)


let int index = 0 as a pointer (not the pointer type) pointing to the current tail
of the queue

void func add(int x):


if index < n then:
a[n] = x
index++
elseif index >=n then:
for i in range 0 to index-1:
a[i] = a[i+1]
a[index] = x

Complexity: O(n)

void func remove(){


for i in range 0 to index-1:
a[i] = a[i+1]
index--
}

Complexity: O(n)

You might also like