Skip to content

DSA · written course

Why your program is slow, and what to do about it

From your first line of code to a queue you built yourself.

Start reading32 pages · about 178 minutes

By the end of this course

Not a list of data structures to memorise: a way of deciding. By the end you can look at a loop and say how it will behave on a million items, choose between an array and a hash map for a reason you can defend, and read the complexity table in an interview question rather than guessing at it.

All 32 pages

  1. 1The program that worked until it did not5 min read
  2. 2Counting without a stopwatch6 min read
  3. 3The other resource5 min read
  4. 4Arrays, and why index 0 is instant5 min read
  5. 5Answering range questions in one step5 min read
  6. 6Strings are arrays with sharp edges5 min read
  7. 7Searching: from every item to twenty5 min read
  8. 8Binary search when the target is not there6 min read
  9. 9Sorting, and why some ways are hopeless6 min read
  10. 10Three sorts that matter, and why6 min read
  11. 11Splitting a problem in half5 min read
  12. 12Recursion, and the stack underneath it6 min read
  13. 13Trying everything, but not stupidly6 min read
  14. 14Linked lists: the opposite trade5 min read
  15. 15Stacks: last in, first out5 min read
  16. 16Queues: first in, first out5 min read
  17. 17Hash tables, and the trick from page one6 min read
  18. 18A tree shaped like a prefix5 min read
  19. 19When a list is the wrong shape6 min read
  20. 20A tree that keeps things in order6 min read
  21. 21When you only ever want the best one6 min read
  22. 22When anything can connect to anything6 min read
  23. 23Two ways to walk a graph6 min read
  24. 24Putting dependencies in order5 min read
  25. 25When the edges have weights6 min read
  26. 26Connecting everything as cheaply as possible5 min read
  27. 27Which things are connected5 min read
  28. 28Two indices instead of two loops6 min read
  29. 29Taking the best option now6 min read
  30. 30Working with the bits directly6 min read
  31. 31What to do when you have never seen it6 min read
  32. 32Choosing, which is the actual skill6 min read

Then what

Reading is the first half. When you finish, the questions for this subject test whether it went in, and every wrong option tells you why it was wrong rather than just that it was.

See the questions for DSA