Skip to content
Your progress

Checking your sign-in…

Who's learning?

Each profile keeps its own read lessons, badges, streak, and practice scores on this device.

Lesson 0 of 11

4 min

Text size

This term you search a list. Then you put it in order. You also count the work.

Search asks where. Sort puts things in order. Both are counted.

What you will learn

  • Is it there at all? — check each item, say true or false.
  • Where exactly — a counted loop: start (init), test, update, traced.
  • In order first — a search that halves a sorted list.
  • Counting both searches — the checks, called comparisons, side by side.
  • One pass of selection — find the smallest, swap it to the front.
  • The whole sort — repeat the pass until each item is placed.
  • Sort once, search many — when sorting first saves work.
  • How the count grows — double the list, watch each count.

Need a quick recap?

  • Return sends one value back to the code that asked.
  • A position finds one item in a list.
  • Halving checks the middle and rules out half.

The code here is plain code, not Python. The ideas also work in Python.