Homework_3 - CSE 331: Computer Organization and Design...

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

View Full Document Right Arrow Icon
CSE 331: Computer Organization and Design Spring 2008 Homework #3: Implement Bubble Sort using SPIM Points: 15 (Pair programming assignment) Due: 5pm, Tuesday, Feb. 12, 2007 This assignment is to write a “bubble sort” program in MIPS assembler. Bubble sort is one of the simpler sorting algorithms. It gets its name from the way smaller elements “bubble” to the top (i.e., the beginning) of the list (i.e., linear array) via swaps. The basic idea is to put adjacent elements in the array in sort order; look at the first two elements, swap them if necessary, then look at the second and third elements, swap if necessary, then look at the third the fourth elements, swap if necessary, etc. After one pass through the array, the largest item will be at the end of the array. After the second pass through the array, the second largest item will be in position. After (n-1) such passes, all of the array will be sorted from smallest at the beginning of the array to largest at the end.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the 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