Homework_4 - return to the main routine that should then...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Computer Science and Engineering 331 Computer Organization and Design Spring 2008 Homework #1. Implement Recursive Bubble Sort using SPIM Points: 15 (Pair programming assignment) Due: Friday, Feb 22, 2008 by 5:00pm Using SPIM, you will write a recursive program that implements “bubble sort”. The main routine should still prompt the user to input the integer numbers. ‘-1’ still signals the end of input. It should call the bubble sort procedure that performs the actual sorting. This procedure is recursive, i.e., it will call itself. Each time this recursive procedure is entered, it should print to the Entering Bubble Sort for the i = <#> time. where i is 1 for the first call to the bubble sort procedure from the main routine. After the recursive bubble sort procedure has determined the position of the smallest number, it should
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: return to the main routine that should then output the sorted array to the console Note that all the array elements comparison and swap must be done from within the recursive bubble sort procedure (e.g., 1-element arrays, which are always sorted, must be detected in the recursive bubble sort procedure). By single stepping your program determine how many instructions are executed in your recursive bubble sort procedure for 1-element, 2-element and 3-element arrays and report these instruction counts as comments in your code. A bonus of 2 points will be given to the 15 fastest (i.e., least number of instructions executed) correctly running programs submitted....
View Full Document

This note was uploaded on 09/30/2008 for the course CMPEN 331 taught by Professor Bhat during the Spring '08 term at Pennsylvania State University, University Park.

Ask a homework question - tutors are online