The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from linked list's own run on the numbers shown.
choose one
1question 1
An empty chain kept in order puts in 30, 12 and 45, takes 12 out, then puts in 20. What does the chain hold then, from the start?
the answer, and why
the answer is B
After 12 leaves, the chain holds 30, 45. 30 is bigger than 20, so the first look stops the walk and 20 goes in at the start.
step 10 of 12
30 is bigger than 20, so 20 goes just before it.
looks so far: 1
step 11 of 12
Link 20 in at the start of the chain.
looks so far: 1
the start, holding no number
a look, numbered in turn
looked at now
just linked in, with its new pointers
Operation 5 puts 20 in, after operations 1 to 4 put in 30, 12 and 45 and took 12 out. 30 is bigger than 20, so 20 is linked in at the start.
if you chose another
AThat keeps 12, but the fourth operation takes 12 out.
CThat puts 20 at the end, but a put stops at the first bigger number, 30.
DThat loses 30. Taking 12 out links the start to 30, which stays.