Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Computer Science Introduction to Algorithms Algorithms in Code Binary Search in Code

Confused on looping back through after 'first' becomes 5

I understand that the first becomes 5 in the elif statement. Then we loop back through with our new first value. I don't understand how we arrive at 6 for the midpoint value. If 5(first) + 8 (last) = 13 --> //2 then how do we know to round up or down to get 6 as the midpoint?

Any help to further break down this process would be helpful. Thank you!

1 Answer

// in python is a floor division operator, i.e. it always rounds down.