1__Questions_8

1__Questions_8 - 4. An array contains the elements shown...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CIS 15BG Questions Chapter 8 Arrays: One Dimensional Arrays 1. A. Because of its efficiency, binary search is the best search for any array, regardless of its size and order. True / False B. Under what circumstances should we use binary search? 2. Trace the steps of the binary search algorithm to search the following list: A. target = 24 12, 14, 19, 24, 28, 30, 35, 39, 42, 44, 50, 55, 58 0 1 2 3 4 5 6 7 8 9 10 11 12 B. target = 40 12, 14, 19, 24, 28, 30, 35, 39, 42, 44, 50, 55, 58, 60 0 1 2 3 4 5 6 7 8 9 10 11 12 13 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CIS 15BG Questions Chapter 8 Arrays: One Dimensional Arrays 3. A. The __________________ sort finds the smallest element from the unsorted sub-list and swaps it with the element at the beginning of the unsorted data. B. The __________________ sort does not exchange elements.
Background image of page 2
This is the end of the preview. Sign up to access the rest of the 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

Page1 / 2

1__Questions_8 - 4. An array contains the elements shown...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online