40/40
Part 7 of 7 · Follow-upsCheck yourself
Check yourself
6 questions
  1. 1.You check whether a value is in a collection of n items. What does each lookup cost on average with a list and with a set?

  2. 2.Which of these can be a key in a Python dict?

  3. 3.What does {1: "int", 1.0: "float", True: "bool"} evaluate to?

  4. 4.You want to open only the files whose size another file shares, so you loop once and flag a file when its size is already in a seen-set. What goes wrong on sizes 17, 17, 10, 9000, 10?

  5. 5.Two copies of the same 1 GiB file are read in chunks of different sizes. You can't hold a whole file in memory, and the keys are saved to compare with next week's scan. Which way of hashing gives both copies the same key?

  6. 6.In the two-sum loop, you write seen[size] = j before checking need in seen. What happens with sizes [750, 100] and capacity 1500?

Now the problem this lesson builds to: 29 Find the duplicate filesPractice it