0% found this document useful (0 votes)
66 views

KIE1008 (Theory Tutorial) Session 2016/2017 (Semester 2)

This tutorial covers stacks and queues data structures. It compares stacks and queues, describing their operations and providing examples of implementing each using arrays. For stacks, it shows the output at each line of code for an array implementation as elements are pushed and popped. Similarly, it shows the output for a circular queue implementation using an array as elements are enqueued and dequeued.

Uploaded by

Mazen Jamal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

KIE1008 (Theory Tutorial) Session 2016/2017 (Semester 2)

This tutorial covers stacks and queues data structures. It compares stacks and queues, describing their operations and providing examples of implementing each using arrays. For stacks, it shows the output at each line of code for an array implementation as elements are pushed and popped. Similarly, it shows the output for a circular queue implementation using an array as elements are enqueued and dequeued.

Uploaded by

Mazen Jamal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

KIE1008 (Theory Tutorial) Session 2016/2017 (Semester 2)

Tutorial 4: Stacks and Queues

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--

You might also like