CJCoding With Joseph
15free / daySign inCreate account

University of Lethbridge - CPSC

binary_search()

Assignment 1 - Movie2 - SM 25

What is this function?

This function performs a binary search on the list of movies. It looks for a title by repeatedly cutting the list in half until it either finds the match or confirms that the movie isn’t there.

Just like in linear_search(), it:

  • Returns true if the title is found and stores the release year

  • Returns false if it’s not found

  • Counts how many comparisons it makes using the comparisons variable/parameter

Members only

Keep reading this lesson

You've reached the end of the free preview. Unlock the rest of this lesson plus 27 more lessons in University of Lethbridge - CPSC.

  • Unlimited coding questions
  • Unlimited access to all classroom material
  • Weekly live call for questions and guidance
  • 3,000 AI tutor tokens / month
  • Personal SQL database (3 MB)
  • Progress tracking

Cancel any time.