Given operation are: push, pop, top, isEmpty Lets assume that \'S\' is given stack 1. Set num to the second element from the top of the stack, leaving the stack without its top elements. setSecondElement(S, num): if(S.isEmpty()) print \"stack is empty\" S.pop() if(S.isEmpty()) print \"stack is empty\" num = S.top() 2. Given an integer n, set the nth element from the top of the stack, leaving the stack unchanged. setNthWithoutChange(S, num, n): create tempStack // popping first n elements from S and pushing into temp stack for i=1 to n: if(S.isEmpty()): print \"stack contains less element than n\" break; tempStack.push(S.pop()) // if we have sufficient elements if i==n : num= tempStack.top() // pop all elements from tempstack and push back into S while(!tempStack.isEmpty()): S.push(tempStack.pop()) 3. Set num to the bottom element of the stack, leaving the stack empty. setBottomElementWithChange(S, num): if(S.isEmpty()): print \"stack is empty\" else: num = S.pop() // setting first element to num while(!S.isEmpty()) num = S.pop() 4. Set num to the bottom element of the stack, leaving the stack unchanged. setBottomElementWithoutChange(S, num): if(S.isEmpty()): print \"stack is empty\" else: create a tempStack while(!S.isEmpty()) tempStack.push(S.pop()) num = tempStack.top() // pushing back into S while(!tempStack.isEmpty()) S.push(tempStack.pop()) 5. Set num to the nth element from the bottom of the stack leaving the stack unchanged. if(S.isEmpty()): print \"stack is empty\" else: create a tempStack while(!S.isEmpty()) tempStack.push(S.pop()) int count = 0; while(!tempStack.isEmpty()) temp = tempStack.pop() count = count + 1 if(count == n) num = temp S.push(temp) if count < n: print \"stack do not have sufficient element\" Solution Given operation are: push, pop, top, isEmpty Lets assume that \'S\' is given stack 1. Set num to the second element from the top of the stack, leaving the stack without its top elements. setSecondElement(S, num): if(S.isEmpty()) print \"stack is empty\" S.pop() if(S.isEmpty()) print \"stack is empty\" num = S.top() 2. Given an integer n, set the nth element from the top of the stack, leaving the stack unchanged. setNthWithoutChange(S, num, n): create tempStack // popping first n elements from S and pushing into temp stack for i=1 to n: if(S.isEmpty()): print \"stack contains less element than n\" break; tempStack.push(S.pop()) // if we have sufficient elements if i==n : num= tempStack.top() // pop all elements from tempstack and push back into S while(!tempStack.isEmpty()): S.push(tempStack.pop()) 3. Set num to the bottom element of the stack, leaving the stack empty. setBottomElementWithChange(S, num): if(S.isEmpty()): print \"stack is empty\" else: num = S.pop() // setting first element to num while(!S.isEmpty()) num = S.pop() 4. Set num to the bottom element of the stack, leaving the stack unchanged. setBottomElementWithoutChange(S, num): if(S.isEmpty()): print \"stack is empty\" else: create a tempStack while(!S..