a) The stack class has been created as follows:
class Stack {
int maxSize;
double stackÄrray[ ]
int top;
i) Write the constructer method to initiate Stack class properties.
ii) Write the pop() method to remove a value from the Stack.
public double pop ( )
b) Assume S is stack developed using a linked list.
Show the final contents of the Stack after executing the following code.
for (int k=1; k<=7;k++)
s. push (k) ;
for (int k=1; k<=7;k++)
s . push (s.pop ( ) ) ;
c) The Queue class has been created as follows, to store integer values.
class Queue {
LinkedList queueList;
int n Items;
i)Write the constructor to initiate the Queue class properties.
ii)Write a method to insert a value to the Queue.
public void insert (int i)
iii)Write a method to delete a value from a Queue.
public Link delete()
iv)What is the major limitation of Linear queues?
Comments
Leave a comment