KIE1008 (Theory Tutorial) Session 2016/2017 (Semester 2)
KIE1008 (Theory Tutorial) Session 2016/2017 (Semester 2)
1. What is a stack data structure and what is a queue data structure? Compare the similarities and
differences of stack and queue data structures.
2. What are the operations in stack and queue data structures?
3. Highlight the output at each lines of the following codes for an implementation of stack using
array:
top Arry[]
[0] [1] [2] [3] [4]
char arry[5]; X X X X X
int top = 0; 0 X X X X X
arry.push(a); 1 a X X X X
arry.push(y); 2 a y X X X
arry.push(b); 3 a y b X X
arry.pop(); 2 a y b X X
arry.pop(); 1 a y b X X
arry.push(c); 2 a c b X X
arry.push(z); 3 a c z X X
arry.push(s); 4 a c z s X
arry.push(t); 5 a c z s t
arry.pop(); 4 a c z s t
4. Highlight the output at each lines of the following codes for an implementation of queue using
array (circular implementation):
Queue
front rear count
[0] [1] [2] [3] [4] [5]
char Queue[6]; X X X X X X
int front=?,
rear=?, count=?;
Queue.enQ(a);
Queue.enQ(y);
Queue.enQ(b);
Queue.deQ();
Queue.deQ();
Queue.enQ(c);
Queue.enQ(z);
Queue.enQ(s);
Queue.enQ(t);
Queue.deQ();
Queue.enQ(m);
Queue.enQ(n);
--END--