Embercode
✕
Flowcharts and PseudocodeQuick quiz

Reading and comparing algorithms

8 questions. Covers Comparing two algorithms on paper.

Questions 1 to 5 of 8

  1. 1. The loop for the sum of 1 to n makes one addition for each number from 1 to n. It makes 1,000 additions when n is 1,000. How many additions does it make when n is 250,000?

    Type a number.

  2. 2. The loop for the sum of the even numbers from 1 to n checks every number and adds only the even ones. For n equal to 100, how many checks and how many additions does it make?
  3. 3. The function mystery is below. Why does mystery([-4, -1, -7]) return 0? ``python def mystery(values): result = 0 pos = 0 while pos < len(values) and values[pos] != 0: if values[pos] > result: result = values[pos] pos = pos + 1 return result ``
  4. 4. In find_first_repeat, the check items[i] in seen comes before seen.append(items[i]). Why must the order stay this way?
  5. 5. True or false: a formula that gives the right answer for n equal to 10 is proven correct for every n.

5 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.