subject

Write a program which will rearrange and sort a stack of integer values, using two other stacks. The following algorithm describes how to do this: 1. Start with a stack of numbers named primary and two empty stacks named lower and higher. 2. Pop the first number from your primary stack and put it into the lower stack 3. Pop the next number from your primary stack, if it is smaller than the number you previously put into the lower stack, then add it to the lower stack, otherwise put it in the higher stack. 4. Repeat step 3 until the primary stack is empty. 5. Pop each of the elements from the lower stack and add them back into the primary stack. 6. Pop each element of the higher stack. If the value is greater than the value at the head of the primary stack, then add it onto the primary stack, otherwise add the number into the lower stack.

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 07:30, jackie0833
Which option allows you to view slides on the full computer screen?
Answers: 1
image
Computers and Technology, 24.06.2019 00:30, rustjallison9928
Asecurity policy is a a. set of guidlines b. set of transmission protocols c. written document d. set of rules based on standards and guidelines
Answers: 2
image
Computers and Technology, 24.06.2019 01:30, Cinders13
How can you make your column headings stand out?
Answers: 1
image
Computers and Technology, 24.06.2019 06:30, toolazytobehuman
Me and category do i put them in because this is science
Answers: 1
You know the right answer?
Write a program which will rearrange and sort a stack of integer values, using two other stacks. The...

Questions in other subjects:

Konu
Health, 08.08.2019 04:10