Algorithms · GCSE · about 25 min
Survey the room, sort the records, answer questions from sorted data, and choose the algorithms.
[1 mark]After sorting survey records nearest first, where is the farthest direction?
[1 mark]The sorted distances are 15, 16, 16, 26, 26, 31, 31, 34, 34, 35, 51, 57. What is the median?
[1 mark]To sort records by distance, what does the sort compare?
[1 mark]Why is any of the three sorts fine for 12 readings?
Do the survey from the brief. Sort the records nearest first with a sorting algorithm you write (no sort or sorted). Print one line sorted: followed by the distances in order, then median: <cm> cm and farthest: <degrees> degrees. Turn to face the farthest direction and beep.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
survey = []
for i in range(12):
turn_right(30, angle=30)Plan your program here, then type it in and press Run.