Why does a loop inside a loop compare N(N-1)/2 pairs, and what happens to the runtime every time you double the input?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
Build the points for diameter the way the video does: point i, for each i from 0 to N - 1, sits at an angle of i radians and at a distance of i from the origin, so the points spiral outward instead of all landing on one circle. math.cos and math.sin both take an angle in radians. Define create_list_of_2D_points(N) returning the list of these N points as (x, y) tuples.
An inner loop from i+1 compares each pair once
Write out diameter, hand-trace the index pairs it compares for five points with one row per outer iteration, and add the row lengths to match .
Quadratic growth: double the input, quadruple the work
Compute the pair counts for 100, 200 and 400 points and their consecutive ratios, state the tenfold-input, hundredfold-time rule, and contrast the 6,000-point limit of diameter with linear functions reaching 100 million.
Linear, quadratic and logarithmic curves on one plot
Sketch input size against running time for is_in, diameter and binary_search, label each curve linear, quadratic or logarithmic, and note that the logarithmic curve keeps rising without ever levelling off.
Machine-dependent times, machine-independent growth
Record the compound timings of about 1, 63.57 and 126.98 seconds on three machines, state that the input-to-time relationship is the same on each, and name asymptotic complexity as the goal.