A fossil collection is ordered by repeatedly comparing each pair of neighbouring specimens and exchanging them when they are in the wrong order. the name of this sorting algorithm.
Loading subject…
Practice IB Computer Science (First Exam 2027) Topic B2.4 Programming Algorithms with authentic exam-style questions for both SL and HL students. This question bank focuses on the exact syllabus content for B2.4 Programming Algorithms and mirrors Paper 1, 2 style where relevant.
Get instant solutions, detailed explanations, and build confidence with questions aligned to IB examiner expectations.
A fossil collection is ordered by repeatedly comparing each pair of neighbouring specimens and exchanging them when they are in the wrong order. the name of this sorting algorithm.
A guitar workshop sorts serial numbers with a bubble sort that compares every neighbouring pair on every pass.
…
A racing pigeon club processes nested loft records using recursion.
(b) how the calls build up and then return for the list 4, 11, 6.
(c) one situation in which an iterative version would be preferred.
A land registry has measured its bubble sort on lists of different sizes. On an already sorted list of 20 000 entries the version without early stopping takes the same time as on a randomly ordered list of the same size.
(a) why the version without early stopping is unaffected by the initial order.
(b) how adding a flag that records whether any exchange occurred changes the behaviour on an already sorted list.
(c) why this change does not alter the algorithm's Big O notation.
A meteorite catalogue states that its linear search has a space complexity of O(1). what this means.
(a) a recursive function that is passed a list and a starting position, and returns the largest value in the list from that position onwards. The list is not empty. You must not use a loop or any built-in function that returns a largest value.