CS 371: Module 8: Exercise 0 (2 Points)
Developed by Professor Tralie and Professor Mongan.
Exercise Goals
The goals of this exercise are:- To implement data structures in python using object-oriented paradigms
Fill in the binary_search
method to complete the binary search technique to find an element in a sorted array. Note that the //
operator rounds the division down to the nearest int, which you'll need to do to keep them as indices. Refer to the image below to recall how this algorithm works:
Running into infinite loops is very common here! So if your code doesn't terminate quickly, you probably have an infinite loop, and you may need to refresh your page. Don't feel bad about this though...I had this happen to me when I implemented this for the first time in CS 174 last fall.
Enter your Ursinus netid before clicking run. This is not your ID number or your email. For example, my netid is ctralie
(non Ursinus students can simply enter their name to get this to run, but they won't get an e-mail record or any form of credit)
Netid |