Question: given an empty stack, execute the following sequence of operations: push(3), push(4), push(5), pop(), pop(), push(3). module programming language - python c) Give pseudocode for
given an empty stack, execute the following sequence of operations: push(3), push(4), push(5), pop(), pop(), push(3).

module programming language - python
c) Give pseudocode for a recursive algorithm that returns the sum of the in a given stack. Your algorithm should not use for, while or loops. (6 marks) (d) G iven a queue, with all elements in the queue being distinct, write pseudocode n algorithm that returns the sum of the elements in the queue. At the end for a of the algorithm, all the elements should still be in the queue in their original order. Do not use any additional queues, stacks, arrays or linked lists. Hint: After an element has been added to the sum, insert it back into the queue. This can be done in a while loop. Think about an appropriate condition (7 marks) to ensure that the while loop terminates. Modify the above algorithm so that it works when all the numbers are positive but not necessarily distinct. Do not use any additional queues, stacks, arrays (3 marks) (e) or linked lists
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
