Page 1 of 1

Q1: Write a non-recursive algorithm to compute the size of a stack. Make sure the stack does not lose its elements. Q2:

Posted: Thu Jun 02, 2022 7:43 am
by answerhappygod
Q1 Write A Non Recursive Algorithm To Compute The Size Of A Stack Make Sure The Stack Does Not Lose Its Elements Q2 1
Q1 Write A Non Recursive Algorithm To Compute The Size Of A Stack Make Sure The Stack Does Not Lose Its Elements Q2 1 (69.21 KiB) Viewed 14 times
Q1: Write a non-recursive algorithm to compute the size of a stack. Make sure the stack does not lose its elements. Q2: Write a recursive algorithm to compute the size of a stack. Make sure the stack does not lose its elements. Q3: Write a recursive method that calculates the sum of odd elements of a LinkedList. Q4: Write an algorithm to move a stack into a queue and return the queue to the caller. Q5: Using the specification of the Stack ADT, write a method to output the contents of a stack in reverse order. For example, if the stack contents are 1 2 3 4 with 4 at the top, the output should be 1 2 3 and 4. (You may use another stack to store temporary data) Q6: Using the specification of the Stack ADT, write a method to count the number of elements in a stack. The stack should be unchanged after the operation. (You may use another stack to store temporary data) Q7: Using the specification of the Stack ADT, write a method to delete every occurrence of an element from the stack leaving the order of other elements unchanged. (You may use another stack to store temporary data) Q8: Using the specification of the Stack ADT, write a method to return every third element from the stack. For example, if the contents of the stack are 1 2 3 4 5 6 7 8 9 then following should be outputted: 7,4 and 1. (You may use another stack to store temporary data)