Length aj firstifirst ifirst

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { int iFirst = 0; // Next element to consider in the first array int iSecond = 0; // Next element to consider in the second array int j = 0; // Next open position in a while (iFirst < first.length && iSecond < second.length) { if (first[iFirst] < second[iSecond]) { a[j] = first[iFirst]; iFirst++; } else { a[j] = second[iSecond]; iSecond++; } j++; } (4) Quick Sort (5) Linear search (sequential search) while (iFirst < first.length) { a[j] = first[iFirst]; iFirst++; j++; } while (iSecond < second.length) { a[j] = second[iSecond]; iSecond++; j++; } } } public void sort(int from, int to) { if (from >= to) return; int p = partition(from, to); sort(from, p); sort(p + 1, to); } private int partition(int from, int to) { int pivot = a[from]; int i = from - 1; int j = to +...
View Full Document

This essay was uploaded on 03/30/2014 for the course HEALTH 101 taught by Professor Ayman during the Spring '14 term at Saudi Electronic University.

Ask a homework question - tutors are online