CMPT 115 Lecture Notes - Lecture 2: Pseudocode, Dynamic Array, Bubble Sort

63 views18 pages
9 May 2016
School
Course
Professor

Document Summary

Notes written by michael horsch, mark eramian, ian mcquillan, lingling jin, and dmytro dyachuk. The di erence between a problem and an algorithm is subtle but important. A problem is a description which associates inputs to output states. Pre: list is the array of integers to be sorted, of length n. Post: list contains the same elements, rearranged into ascending order. Problems: the preconditions describe the inputs to the problem, the postconditions describe the resulting states of the variables, a problem statement itself does not indicate how to solve the problem. Sort the array list of integers into ascending order. Pre: list :: shared array ofinteger n :: integer -- the length of list. Post: list contains the same elements, rearranged into ascending order. if not(isempty (list)) then. Listofinteger larger selectlarger (list, pivot) quicksort(smaller ) quicksort(larger ) list gluetogether (smaller ,pivot,larger )

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents