Search this site
Embedded Files
Skip to main content
Skip to navigation
Mr. K. McKay - Computer Science & Technology
Courses
ICS2O
ICS2O-MathematicalOperations
ICS2O-VariableDeclarations
ICS3U
ICS3U-Intro-String-Class
ICS3U-Intro-Strings
ICS4U
TEJ3M
TEJ4M
TER3M
BTT1O
BTT1OX
ROBOTICS TEAM 5870
Grade 8 Students & Parents
Programming Contests
Mr. K. McKay - Computer Science & Technology
Courses
ICS2O
ICS2O-MathematicalOperations
ICS2O-VariableDeclarations
ICS3U
ICS3U-Intro-String-Class
ICS3U-Intro-Strings
ICS4U
TEJ3M
TEJ4M
TER3M
BTT1O
BTT1OX
ROBOTICS TEAM 5870
Grade 8 Students & Parents
Programming Contests
More
Courses
ICS2O
ICS2O-MathematicalOperations
ICS2O-VariableDeclarations
ICS3U
ICS3U-Intro-String-Class
ICS3U-Intro-Strings
ICS4U
TEJ3M
TEJ4M
TER3M
BTT1O
BTT1OX
ROBOTICS TEAM 5870
Grade 8 Students & Parents
Programming Contests
ICS4U
Sorting Theory & PRACTICE
Sorting Theory
Read pages 455-465 and
Sorting Comparisons
What are the four factors that affect sorting routines?
What does Big-O notation mean? Give an example.
The two classes of sorting algorithms are O(n2) and O(n log n).
Give an example of each.
Compare the efficiency of each.
What is the basic algorithm for the merge sort? quick sort?
If you were given the code for either, would you recognize it?
How do worst case times compare?
Given a scenario, what type of sort would you use.
Sorting Practice
Create a program that creates a 1-D array of 100. Create methods to:
Randomly generate numbers between 1 and 100 for each element.
Printout the array in 10 columns
Create a separate class (SortLibrary) of sorting methods(selection, merge sort and quick sort). Each sort should have an integer array as a parameter.
Instantiating the SortLibrary object, for example:
int [] marks = new int[10];
SortLibrary s=new SortLibrary();
s.selectionSort(marks);
//assuming you have a method called selectionSort
Create the main to:
Call your random filling method.
Print out the unsorted array.
Call each method in turn and print out the results
Report abuse
Report abuse