6.100L | Fall 2022 | Undergraduate

Introduction to CS and Programming using Python

Lecture 6: Bisection Search

Topics: Simple Algorithms: bisection search, Newton-Raphson

Lecture Notes

Lecture 6: Bisection Search

Lecture 6 Code


Ch 3.4, 3.5

Finger Exercise Lecture 6

Assume you are given an integer 0 \\<= N \\\<= 1000. Write a piece of Python code that uses bisection search to guess N. The code prints two lines: count: with how many guesses it took to find N, and answer: with the value of N. Hints: If the halfway value is exactly in between two integers, choose the smaller one.

<a href=“https://ocw-studio.odl.mit.edu/sites/6100l-introduction-to-cs-and-programming-using-python/type/resource/edit/7887b2cc-3d12-4dee-ab69-0de71020d95d/?ocw_resource_link_uuid=7887b2cc-3d12-4dee-ab69-0de71020d95d&ocw_resource_link_suffix=">6.100L Finger Exercises Lecture 6 Solutions</a>

Course Info

As Taught In
Fall 2022
Learning Resource Types
Lecture Videos
Lecture Notes
Problem Sets
Programming Assignments with Examples
Recitation Notes