Question #237645

Sort all the stacks in this order:

Stack1 in alphabetic order by name

Stack2 in alphabetic order by Surname

Stack3 in Numeric order (descending) by marks obtained


Expert's answer

The below algorithm can be used to sort all the three stacks:

  

declare a temporary stack say temporary_tack.
While (input_stack is NOT empty){
pop an item from the input_stack and name it as temp
while(temporary_tack is not empty and top of temporary_tack > temp){
pop from the temporary_tack and push it back to the input_stack.
push temp into the  temporary_stack

}


} 
input_stack = temporary_tack 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS