Sorting Algorithms - Data Structures and Algorithms | MIS 301, Assignments of Business Management and Analysis

Material Type: Assignment; Class: Data Structures and Algorithms; Subject: Management Info Systems Main; University: University of Arizona; Term: Fall 1998;

Typology: Assignments

Pre 2010

Uploaded on 08/30/2009

koofers-user-d97
koofers-user-d97 🇺🇸

10 documents

1 / 11

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
MIS 121 1
Sorting
Major activity of computers
Major topic in MIS 301
Over a hundred sorting algorithms
Classic text is Donald Knuth, Sorting and Searching,
Second Edition, Addison Wesley, 1998. (Vol-
ume 3 of Art of Computer Programming) see
www-cs-faculty.stanford.edu/knuth/index.html
Sorting Printed 12 November 1998
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Sorting Algorithms - Data Structures and Algorithms | MIS 301 and more Assignments Business Management and Analysis in PDF only on Docsity!

Sorting

  • Major activity of computers
  • Major topic in MIS 301
  • Over a hundred sorting algorithms
  • Classic text is Donald Knuth, Sorting and Searching , Second Edition, Addison Wesley, 1998. (Vol- ume 3 of Art of Computer Programming ) see www-cs-faculty.stanford.edu/∼knuth/index.html

Sorting Algorithms

  • Two kinds of sorting algorithms (from standpoint of MIS 301 student)

— basic algorithms (easy to understand but slow)

— efficient algorithms (faster, harder to explain)

Basic and Efficient Algorithms

  • Basic

— insertion

— selection

— bubblesort (the worst of all! never use it!)

Basic and Efficient Algorithms—

  • Efficient

— ShellSort

— HeapSort

— QuickSort

Why I’m telling you all this

  • Our textbook shows selection sort in §9.
  • You can use it for hw7 (it’s in sorting1.c and sort- ing2.c)
  • You should know its place as an algorithm that is easy to write but not very useful for sorting large amounts of data

Selection Sort Algorithm

for(i=0;i<n-1;i++) {

select the smallest item from among data[i], ... , data[n-1] swap it with data[i]

}

(note: this is how you’ll get algorithms in MIS301, then you translate into code)

Comma Expressions

  • It’s possible to do more than one initialization and increment in the head of a for loop.
  • Use comma expression to do it.
  • Example:

for (x=0,y=N;x<N&&y>0;x++,y--)

Comma Expression Definition

  • Two expressions separated by a comma.
  • Evaluation:

— LHS is fully evaluated. — If LHS produces a value, the value is discarded. — RHS is fully evaluated. — The type and value of the comma expression is the type and value of the RHS.