This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 4. An array contains the elements shown below. Show the contents of the array after one pass of the A. Bubble sort algorithm. 11, 85, 3, 18, 20, 15, 5, 12, 70, 8, 50 B. Insertion sort algorithm. 11, 85, 3, 18, 20, 15, 5, 12, 70, 8, 50 C. Selection sort algorithm. 11, 85, 3, 18, 20, 15, 5, 12, 70, 8, 50 5. Predict the output (no computers please, and show how did you get the answer). int size = 16; int score[100] = {10, 9, 9, 10, 9, 8, 9, 7, 10, 5, 0, 9, 9, 7, 10, 8}; int a[11] = {0}; int i; for (i = 0; i < size; i++) a[score[i]]++; // a[score[i]] = a[score[i]] + 1; for (i = 0; i < 11; i++) if (a[i]) // a[i] != 0 printf(" %2d %2d\n", i, a[i]); 2...
View
Full Document
 Winter '10
 Staff
 Binary Search, Computer Programming, Bubble Sort, Insertion Sort, Selection Sort, Big O notation, Comparison sort

Click to edit the document details