Assessment Tool
Lecture 15: Linear and Binary Search
Content Tested: Motivation for Binary Search
Lecture Content:
-
Searching an array
-
Linear search
-
Binary search
-
Comparing algorithm performance
Goals:
-
Develop ability to apply principles and generalizations already learned
to new problems and situations
-
Develop problem-solving skills
-
Develop appropriate study skills, strategies, and habits
-
Improve mathematical skills
-
Prepare for transfer or graduate study
-
Learn techniques and methods used to gain new knowledge in this subject
Assessment Technique: Game
Purpose:
Instructors can find out how students design strategies for the "Choose
My Number" game. This activity should precede the viewing of this
lecture in order to motivate the process of binary search.
Activity:
This is an entire class activity. The instructor leads the "Choose
My Number" game.
Instructor says: I'm thinking of a number between 1 and 100, inclusive.
It's your job to guess my number. Upon each guess, I'll say "that's
my number", "my number is higher", or "my number is lower". You will
then have more turns to guess my number. Your goal is to guess my
number in 8 guesses.
At this point, the instructor should declare a process for guessing
among the students. The students could take turns guessing, the students
could agree as a group before guessing as a class, or there could be some
other way of organizing the guessing.
Possible Solution
Most likely, the students will come up with binary search to guess the
instructor's number. They'll find that if they apply the binary search
technique properly, they will succeed in finding the number in 8 or fewer
guesses.
The students might do random guessing. In this case they probably
won't find the number. Ask them to think together as a class about
a better strategy for guessing and play the game again.
Possible Uses of Activity:
-
Have the students formalize their strategy as an algorithm and write in
on the board. Compare their algorithm to binary search (should be
very close) during the discussion of binary search on the video.
-
Ask the students motivating questions such as the following:
-
If I give you 20 guesses to guess my number, how large can the range of
numbers be from which you're guessing? (You need to guess the number
correctly with those 20 guesses).
-
Answer: 2^20 which is 1048576 (See if they can come up with
the relationship on their own by examining the number of guesses used for
a range of 1 to 100).
-
Is it always better to use the "halving strategy" over simply guessing
numbers in order from 1, 2, 3, up to 100?
-
Answer: No. If you know the number is at the beginning of the
sequence, it's best to just start guessing there. For example, if
the secret number is 1 then it only takes 1 guess using the guessing in
order strategy.