CS241: Spring 2017 -- Onward!

  1. Midterm feedback:
    1. On process (as opposed to content)... learning computing is an *active* process!
    2. If you need something to work on... how to do the partition in quicksort (see example on board)?
    3. Naming conventions
    4. 3 -- facts/parts
      1. named equals
      2. two int[] params
      3. returns boolean
      4. check same length
      5. check all elements are ==
    5. Definition and implications of O
    6. 9 -- facts/parts
      1. named expand
      2. one int[] param
      3. returns int[]
      4. create array to return
      5. copy all elements from small array to big array
  2. Onward!
    1. The TimingBase I provided
    2. Quick sort pseudocode
      	quickSort(List aList) {
      		if (size>1) {
      			select a pivot and split aList into head and tail (where everything in head is < pivot...) with the pivot in between
                              quickSort(head)
                              quickSort(tail)
      		}
      	}
              
      Indices:
      1. pivot
      2. where next element going in the tail goes
      3. where we are currently looking
    3. Representation of parts of a list (so as not to have to copy the list (which would make the algorithm much slower (as in no longer n log n!))
      1. The array
      2. start index
      3. end index
      4. Example: head after the first time through 4 3 5 2 7 8 1 2
    4. Merge sort pseudocode
      	mergeSort(List aList) {
      		if (size>1) {
      			split aList roughly in half creating head and tail
                              mergeSort(head)
                              mergeSort(tail)
      			merge head and tail
      		}
      	}
              
    5. mergesorting 3, 2, 1, 6, 7, 8, 5, 4 (in place)