1 / 5

Engineering 1020

Engineering 1020. Introduction to Programming Peter King peter.king@mun.ca www.engr.mun.ca/~peter Winter 2010. ENGI 1020: Sorting. One of the most common things programs do to data is sort them

pmaldonado
Download Presentation

Engineering 1020

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Engineering 1020 Introduction to Programming Peter King peter.king@mun.ca www.engr.mun.ca/~peter Winter 2010

  2. ENGI 1020: Sorting One of the most common things programs do to data is sort them Sorting algorithms vary from very simple 'brute-force' methods to more complex schemes that maximize efficiency There is generally a trade-off between complexity and efficiency

  3. ENGI 1020: Sorting We will investigate one method for sorting arrays The Bubble Sort This method is simple to describe and program This method is not the most efficient • but should be fine for smaller data sets

  4. ENGI 1020: Sorting Bubble Sort - Starting at the bottom of the array we simple compare each element to the one above it - If the above element is less, we swap - We repeat this until we reach the top of the array - We then return to the bottom and repeat the entire process - We continue this process until no swapping is required

  5. ENGI 1020: Sorting http://en.wikipedia.org/wiki/Bubble_sort

More Related