Bank of Questions 2021
Bank of Questions 2021
Consider the linked list shown in the following figure. Assume that list,
A, and B are pointers of type node.
7. Extend the class List by adding the function MinElement ( ) to find the
minimum element in a List.
8. Extend the class List by adding the function maxElement ( ) to find the
maximum element in a List.
9. At linked list program write function that performs Insert a value at
the beginning of the list.
10. At linked list program write the function that performs Insert a
value at the end of the list.
11. At liked list program write functions that Delete a value/ remove
nodes from the end
12. Push element to the stack using linked list
13. Write the function that make add element in circular Queue
14. Write a C++program to read some string from the user, and then
displays it again in reverse order using Stacks.
15. Write a function that will reverse a linked list while traversing it
only once. At the conclusion, each node should point to the node that
was previously its predecessor; the head should point to the node
that was formerly at the end, and the node that was formerly first
should have a NULL link.
17. Suppose that queue is a queueType object and the size of the array
implementing queue is 100. Also, suppose that the value of
queueFront is 98 and the value of queueRear is 12. What are the
values of queue Front and queueRear after adding two elements to
queue?
front: 98, rear: 14
18. Suppose that queue is a queueType object and the size of the array
implementing queue is 100. Also, suppose that the value of
queueFront is 99 and the value of queueRear is 25. What are the
values of queueFront and queueRear after adding two elements and
removes three elements from the queue?
front: 2, rear: 27
19. Suppose that queue is a queueType object and the size of the array
implementing queue is 100. Also, suppose that the value of
queueFront is 99 and the value of queueRear is 25.
A. What are the values of queueFront and queueRear after adding an
element to queue?
Front: 99, Rear: 26
B. What are the values of queueFront and queueRear after removing
an element from queue?
Front: 0, Rear: 25
20. Extend the class binaryTree by adding the function SumofElement
to return the summation of all the elements in the binary tree.
2. 12 25 5 1 / / * 8 7 + - = 45
29. Translate the following infix to post fix and prefix using Stack:
1. A * ((B + C) * (E – F) – G) * (H – I)
30. Show what output by the following segment of code is:
stackarray stack;
int x=4,y=10;
stack.push(7);
stack.push(x + 5);
y = stack.top( );
stack.pop();
stack.push(x + y);
x = stack.top();
stack.pop();
cout << "x = " << x << endl;
cout << "y = " << y << endl;
while (!stack.isEmptyStack())
{cout << stack.top() << endl;
stack.pop();
}
Output:
X = 13
Y=9
7
31. What is the output of the following program segment?
linkedStackType<int>myStack;
myStack.push(10);
myStack.push(20);
myStack.pop();
cout<<myStack.top()<<endl;
myStack.push(25);
myStack.push(2*myStack.top());
myStack.push(-60);
myStack.pop();
while( myStack.isEmptyStack())
{ cout<<tempStack.top()<<"";
tempStack.pop(); }
cout<<endl;
cout<<myStack.top()<<endl;
output:
10
50