Binary search animation

This presentation should give you a visual overview of what is happening during an iterative implementation of binary search on an array.

  • Notice that the array must be sorted in order to do binary search (why?)
  • Higher level should also look up the recursive implementation.
  • What is the time complexity of binary search? In other words, how many loops do you have to do for an array of N elements?

binary search of array animation

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s