Today's tip: From Hello, World to hired.

Courses / Data Structures & Algorithms / Lesson 1

1. Big-O in plain words

Every programmer starts here. In this lesson you write a complete program, run it, and change it until it does what you want.

Binary searchpython
def binary_search(items, target):
    lo, hi = 0, len(items) - 1
    while lo <= hi:
        mid = (lo + hi) // 2
        if items[mid] == target:
            return mid
        if items[mid] < target:
            lo = mid + 1
        else:
            hi = mid - 1
    return -1

Your turn

Change the program so it greets you by name, then run it in the playground. The checks turn green when the output matches.

Open the playground Next lesson →