Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 1 (5pnts): Design and write in pseudocode an algorithm called SwapNumbers. Given two numbers that are stored in two different variables, the algorithm
Problem 1 (5pnts): Design and write in pseudocode an algorithm called SwapNumbers. Given two numbers that are stored in two different variables, the algorithm swaps them. Example: Given a = 6 and b = 20, after executing the algorithm, a should be 20 and b should be 6. Problem 2 (5pnts): Design and write in pseudocode an algorithm called BubbleMax. Given a value n 1 and a list containing exactly n numbers called A, A2, An, the algorithm starts at the first number compares it with the number that follows and if the first number is larger swaps them. It repeats the same process till it reaches the second to last number. After the algorithm terminates An has the largest number in the list. Problem 3 (10pnts): Write the Bubble Sort algorithm in pseudocode. Use the top-down stepwise refinement technique to design and express your algorithm. Use the BubbleMax algorithm from problem 2 as a building-block algorithm. Given a value n 1 and a list containing exactly n numbers called A, A2, ... , An, Bubble Sort repeats the BubbleMax step until no swaps happen during Bubble Max. At this point the list is sorted. What to submit: Submit a report that includes a detailed description in pseudocode for the algorithms of problems 1 and 2 and at least 3 different pseudocode versions of the Bubble Sort algorithm. The different versions of the Bubble Sort algorithm should reflect the steps of the top-down stepwise refinement. Thise means that the second version should be derived from the first with the refinement of one or more algorithm statements, similarly the third should be derived from the second the refinement of one or more statements. The last pseudocode version of the Bubble Sort algorithm should be fully developed - no statements need further refinement. Problem 1 (5pnts): Design and write in pseudocode an algorithm called SwapNumbers. Given two numbers that are stored in two different variables, the algorithm swaps them. Example: Given a = 6 and b = 20, after executing the algorithm, a should be 20 and b should be 6. Problem 2 (5pnts): Design and write in pseudocode an algorithm called BubbleMax. Given a value n 1 and a list containing exactly n numbers called A, A2, An, the algorithm starts at the first number compares it with the number that follows and if the first number is larger swaps them. It repeats the same process till it reaches the second to last number. After the algorithm terminates An has the largest number in the list. Problem 3 (10pnts): Write the Bubble Sort algorithm in pseudocode. Use the top-down stepwise refinement technique to design and express your algorithm. Use the BubbleMax algorithm from problem 2 as a building-block algorithm. Given a value n 1 and a list containing exactly n numbers called A, A2, ..., An, Bubble Sort repeats the BubbleMax step until no swaps happen during Bubble Max. At this point the list is sorted. What to submit: Submit a report that includes a detailed description in pseudocode for the algorithms of problems 1 and 2 and at least 3 different pseudocode versions of the Bubble Sort algorithm. The different versions of the Bubble Sort algorithm should reflect the steps of the top-down stepwise refinement. Thise means that the second version should be derived from the first with the refinement of one or more algorithm statements, similarly the third should be derived from the second the refinement of one or more statements. The last pseudocode version of the Bubble Sort algorithm should be fully developed - no statements need further refinement. Problem 1 (5pnts): Design and write in pseudocode an algorithm called SwapNumbers. Given two numbers that are stored in two different variables, the algorithm swaps them. Example: Given a = 6 and b = 20, after executing the algorithm, a should be 20 and b should be 6. Problem 2 (5pnts): Design and write in pseudocode an algorithm called BubbleMax. Given a value n 1 and a list containing exactly n numbers called A, A2, An, the algorithm starts at the first number compares it with the number that follows and if the first number is larger swaps them. It repeats the same process till it reaches the second to last number. After the algorithm terminates An has the largest number in the list. Problem 3 (10pnts): Write the Bubble Sort algorithm in pseudocode. Use the top-down stepwise refinement technique to design and express your algorithm. Use the BubbleMax algorithm from problem 2 as a building-block algorithm. Given a value n 1 and a list containing exactly n numbers called A, A2, ..., An, Bubble Sort repeats the BubbleMax step until no swaps happen during BubbleMax. At this point the list is sorted. What to submit: Submit a report that includes a detailed description in pseudocode for the algorithms of problems 1 and 2 and at least 3 different pseudocode versions of the Bubble Sort algorithm. The different versions of the Bubble Sort algorithm should reflect the steps of the top-down stepwise refinement. Thise means that the second version should be derived from the first with the refinement of one or more algorithm statements, similarly the third should be derived from the second the refinement of one or more statements. The last pseudocode version of the Bubble Sort algorithm should be fully developed - no statements need further refinement.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Ill provide pseudocode for each problem as described Problem 1 SwapNumbers Algorithm SwapNumbersa b ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started