Skip to content
Exit presentation

Programming Proper II: Functions, Lists & Simple Algorithms

Start here

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.

Jump to lesson

This track

  1. 0 Start here
  2. 1 Is it there at all?
  3. 2 The counted loop
  4. 3 In order first
  5. 4 Counting both searches
  6. 5 One pass, and the box in the middle
  7. 6 The whole sort, written down
  8. 7 Sort once, search many
  9. 8 How the count grows
  10. 9 The big picture
  11. 10 Track quiz

Other tracks