[Home]

CS 223 - Spring 2017. 4/26

Farewell to CS 223!

Logical problem of the day

bsearch.c
int find2(int * keys, int target, int len){
  int high = len;
  int low = -1;

  int probe;
  while (high - low > 1){
    probe = (low + high) >> 1;
    // does the following line improve the code?
    if (keys[probe] == target) { return probe;} 
    if (keys[probe] > target) {
      high = probe;
    } else {
      low = probe;
    }
  }
  if (low == -1 || keys[low] != target) {
    return -1;
  } else {
    return low;
  }
}
Is binary search of an array faster with or without the check?

(From the very fine book: Beautiful Code)

Administrivia

  • Office hours:
    The office hours are Sun/Tue/Thu 8-11 PM at Hillhouse 17 Rm 111. (Hannah will be there 7-10pm on Thursday)
  • My office hours this week are Wednesday 3-5pm. (today)
  • hw7 extension: 2:00 AM, Wednesday, 3 May 2017
  • exam grades posted next week. You will be able to pick up your exams.

    How to make a decision

    Lecture 24: Machine Learning

  • Machine Learning
  • Lecture 24: Decision Making

  • Cognitive Models of Decision Making
  • A Realistic Model of Rationality
  • Running VOTE on the Zoo
  • Lecture 24: Vale

  • Ithaka More appropriate: Billy Collins youtube
  • The City of New Haven (Steve Goodman's The City of New Orleans)
    [Home]