ICS4

Module 5 (April 29 - May 10)

This Module will provide an introduction to algorithms, measures of algorithm efficiency, and algorithm bias

Post Your Code

Post some or all of your code from Assignment 4 so you can share it with the class and tell us about your brilliant solutions or terrible struggles. Find the html file named with your initials (SP.html, for example) here: https://github.com/ICS4U-ICS4C/2018-Fall-4/tree/gh-pages/Brilliant. Replace the sample code with your own code and edit the description or other elements to your liking. Make a pull request so that I can merge your changes to the class site.

There's a link to your page in Module 4, if you scroll to the bottom.

Intro to Algorithms

Watch these clips on pseudocode, flowcharts, and algorithms





Measuring Algorithm Efficiency

Algorithms Worksheet, supplement to this video lecture from MIT CS

  1. What are the four types of 'operations' considered when counting steps?
  2. Try the best, worst, average cases Exercises at the end of the algorithm_efficiency notes

Algorithm Bias

Highly Recommended Reading: Weapons of Math Destruction by Cathy O'Neil

Or Watch a brief video from her blog, mathbabe.com, below

Also see Joy Buolamwini's Ted Talk about fighting algorithm bias below

Merge Sort Summary

(compliments of @Manav-Shardha)

  • Recursive function (it calls itself)
  • divides list into halves until each value is separate
  • compares the values and reconstructs the list in order
  • most efficient when working with list sizes equal to or close to powers of 2

Manav's merge sort example:
 
     #http://interactivepython.org/courselib/static/pythonds/SortSearch/TheMergeSort.html
     #backgound and sample on merge sort
     def merge_sort(num_list):
     i = 0
     j = 0
     sorted_list = []
     if len(num_list) > 1:
         mid = len(num_list)//2
         part_one = num_list[:mid]
         part_two = num_list[mid:]
 
          part_one = merge_sort(part_one)
         part_two = merge_sort(part_two)
     else:
         return num_list
 
     while True:
         if part_one[i] < part_two[j]:
             sorted_list.append(part_one[i])
             i+=1
         else:
             sorted_list.append(part_two[j])
             j+=1
 
          if (i >= len(part_one)):
             sorted_list = sorted_list + part_two[j:]
             break
         elif (j >= len(part_two)):
             sorted_list = sorted_list + part_one[i:]
             break
     return sorted_list
 
     print(merge_sort(num_list))
    

Review for Quiz

  • Test Suites (see 'all fluffy' worksheet in Module 4)
  • Be able to explain your own testing methods from Assignment 4
  • Measures of algorithm efficiency (see algortihms worksheet and MIT video)
  • Algorithm bias
  • You'll be asked to write a short algorithm for a simple task. You may use pseudocode for this

Assignment 5: May 10

Quiz 4: ?

Quiz 5: May 3

Note that any material presented in this module is fair game for the quiz

This work and other materials under github.com/ICS4U-ICS4C,
are licensed under Creative Commons Attribution 4.0 Int'l License.