Functional Problem Solving (CSC 151 2014F) : Outlines

Outline 46: Binary Search


Held: Monday, 24 November 2014

Back to Outline 45 - Pause for Breath. On to Outline 47 - Binary Search Lab.

Summary

We consider the general problem of searching and binary search, one of the most efficient algorithms for searching.

Related Pages

Overview

Administrivia

Upcoming Work

Extra Credit Opportunities

Academic

Peer Support

Project Questions

We're drawing/selecting polygons with turtles. We realize that in order to get it to scale we would have to change the angels of our polygons so that they would no longer follow the (/ 360 sides) formula. What should we do?

Note that you would also have to change the length of each side. But both figuring out the angles and figuring out the side length is not reasonable. Hence, I am comfortable as long as your scaling works within the same aspect ratio, even if it does not work with different aspect ratios. (E.g., if the image goes from 100x100 to 200x200 or from 100x200 to 200x400, the turtle portions should scale correctly, but if it goes from 100x100 to 200x100 or 100x200, then the turtle portions do not need to scale correctly.) I'd recommend that you base your side length on either the minimum, maximum, or average of the dimensions of the image.

Common Problems and Algorithms

Searching

Demonstration: Destructive Binary Search

Exploring the Search API

Suppose we have data for various students on campus: Last Name (string), First Name (string), Graduation Year (integer), Box Number (integer), and Phone number (string). We might search by any of the four criteria (and by other criteria) and we might therefore order in various ways.

(define people
  (vector 
    ("Aanderson" "Aan"    2017 4114 "x4410")
    ("Brown"     "Bruin"  2016 8123 "x9000")
    ("Doe"       "J"      2018 9999 "none")
    ("Smith"     "Kieran" 2015 4112 "x9231")
    ("Taylor"    "Mic"    2017 1234 "x0001")))

Lab