You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
This lesson covers merge sort and quick sort — two efficient, divide-and-conquer sorting algorithms in the OCR A-Level Computer Science (H446) specification. These algorithms are significantly faster than bubble sort and insertion sort for large data sets.
Both merge sort and quick sort use the divide and conquer strategy:
Merge sort works by:
function mergeSort(data)
if data.length <= 1 then
return data
endif
mid = data.length DIV 2
left = mergeSort(data[0..mid-1])
right = mergeSort(data[mid..data.length-1])
return merge(left, right)
endfunction
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.