Problem Solving with Go course

ComplexityQuiz: Complexity

Problem Solving with Go

Display

Theme

Complexity · Quiz

Quiz: Complexity

Check what you know about counting steps, Big-O, prefix sums, counting by group and choosing a data structure. Answer every question below.

  1. Question 1 of 5An O(n²) program takes 1 second for n = 1,000. Roughly how long for n = 10,000?
  2. Question 2 of 5How many times does body() run for n = 6?
    for i := 0; i < n; i++ {
    	for j := i + 1; j < n; j++ {
    		body()
    	}
    }
  3. Question 3 of 5p is the prefix sum of xs (p[0] = 0). Which formula gives the sum of xs[2] through xs[5], both included?
  4. Question 4 of 5In a simulation the number of items doubles every step, and part two asks for 60 steps. Every item of the same kind behaves the same way. What's the right approach?
  5. Question 5 of 5A program must answer 100,000 questions "has this ID appeared?" about 100,000 IDs. Which structure fits best?