السلام عليكم ورحمة الله
والله ياريت احد يساعدني فيها
1.Describe the following functions for a stack
Peek
Is empty()
Is full()
Pop()
Push
2. String x,y,z,t ;
customer.enque(“A”);
customer.enque(“d”);
customer.enque(“rr”);
x= customer .deque();
customer.enque(“wr”);
customer.enque(“bb”);
customer.enque(“cc”);
y= customer.deque();
a. What is the value of x?
b. What is the value of y?
3. Explain the concept of queue in detail with example
4. Assume that a Queue named Ticket is defined of size 5. Draw the queue for all the operations given below. Mark the Front and rear of your queue
Ticket.enque(23);
Ticket.enque(4);
Ticket.enque(34);
Ticket.enque(11);
Ticket.deque();
Ticket.deque();
Ticket.enque(15);
Ticket.enque(29);
Ticket.deque();
Ticket.enque(32);
5.Assume that there is a stack named s of size 10. See the following operations on this stack and answer the questions a to d
int x,y,z,t ;
s.push(133);
s.push(127);
x=s.pop();
s.push(33);
s.push(38);
y=s.pop();
z=s.pop();
s.push(s.pop();
t=s.pop();
a. What is the value of x?
b. What is the value of y?
c. What is the value of z?
d. What is the value of t?
11. Assume that there is a Queue named customers of size 10. See the following operations on this queue and answer the questions a to e (8)
String x,y,z,t ;
customer.enque(“Ali”);
customer.enque(“Ahmed”);
x= customer .deque();
customer.enque(“Anwar”);
customer.enque(“Bobby”);
y= customer.deque();
z= customer.deque();
t= customer.deque();
c. What is the value of x?
d. What is the value of y?
e. What is the value of z?
f. What is the value of t?
1. Assume that a Circular Queue named People is defined of size 5. Draw the queue for all the operations given below. Mark the Front and rear of your queue. (15marks)
People.enque(5);
People.enque(6);
People.enque(67);
People.enque(89);
People.deque();
People.deque();
People.enque(45);
People.enque(89);
People.deque();
People.enque(62);
2. Suppose that s and t are empty stacks. Draw the stack and explain the operation for each of the given operations. (8 marks)
s.push(a)
s.push(b)
s.push( c )
t.push(d)
t.push(s.pop())
t.push(s.peek())
s.push(t.pop())
t.pop()
3. Assume that there is a stack named s of size 10. See the following operations on this stack and answer the questions a to d ( 8 marks)
int x,y,z,t ;
s.push(23);
s.push(15);
x=s.pop();
s.push(20);
s.push(28);
y=s.pop();
z=s.pop();
s.push(s.pop();
t=s.pop();
e. What is the value of x?
f. What is the value of y?
g. What is the value of z?
h. What is the value of t?
4. Assume that there is a Queue named customers of size 10. See the following operations on this queue and answer the questions a to e
String x,y,z,t ;
customer.enque(“Jane”);
customer.enque(“Jess”);
customer.enque(“Jill”);
x= customer .deque();
customer.enque(“Jimr”);
y= customer.deque();
customer.enque(“Bobby”);
z= customer.deque();
t= customer.deque();
g. What is the value of x?
h. What is the value of y?
i. What is the value of z?
j. What is the value of t?
5. Assume that a Circular Queue named People is defined of size 5. Draw the queue for all the operations given below. Mark the Front and rear of your queue
People.enque(“Ali”);
People.enque(“Anwar”);
People.enque(“Bashar”);
People.enque(“Sami”);
People.deque();
People.deque();
People.enque(“Risha”);
People.enque(“Jose”);
People.deque();
People.enque(“Bader”);


