Answer to Question #237645 in C++ for Owen

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


1
Expert's answer
2021-09-15T17:19:23-0400

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS