Question: question 1: For linear search, how many elements on average must we look at to find our desired value if it is in the array?
question 1:
For linear search, how many elements on average must we look at to find our desired value if it is in the array? Assume the array has N elements.
| N | ||
| N/2 | ||
| N * N | ||
| 1 |
QUESTION 2
When you are looking up a word in a paper dictionary, which searching method do you probably use?
| Dart Search | ||
| Random Search | ||
| Binary Search | ||
| Linear Search |
QUESTION 3
In linear search, how many locations must be checked if the element is not in the array?
| Half the elements. | ||
| Just the first one. | ||
| All of them. | ||
| All but one. |
QUESTION 4
If an array is sorted using bubble sort in ascending order starting from list[0], i.e., from int list[]={45, 11, 50, 59, 7} to {7, 11, 45, 50, 59}, the largest number is guaranteed to be placed in the correct position after the first pass (iteration).
True
False
QUESTION 5
In binary search, when my searched element is checked against the middle element, how many elements do I know must NOT contain my searched element, if N is the original array length?
| N-1 | ||
| 1 | ||
| N * N | ||
| N/2 |
QUESTION 6
Bubble sort must go through the entire array at least N/2 times (N is the number of elements in the array) before it finishes the sorting process.
True
False
QUESTION 7
Given an array int list[]= {45, 11, 50, 59, 7}, if it is sorted starting from list[0] using bubble sort, what is the array content after the first pass (iteration)? Note that the array will be sorted in ascending order, i.e., {7, 11, 45, 50, 59} after sorted.
| a. | {11, 45, 7, 50, 59} | |
| b. | {11, 45, 50, 59, 7} | |
| c. | {11, 45, 7, 59, 50} | |
| d. | {11, 45, 50, 7, 59} |
QUESTION 8
If an array is UNSORTED, which searching method is fastest?
| Unsorted arrays can not be sorted. | ||
| Linear Search | ||
| They are the same speed. | ||
| Binary Search |
QUESTION 9
Given an array int list[]= {45, 11, 50, 59, 7}, if it is sorted starting from list[0] using selection sort, what is the array content after the first pass (iteration)? Note that the array will be sorted in ascending order, i.e., {7, 11, 45, 50, 59} after sorted.
| {11, 7, 50, 45, 59} | ||
| {7, 11, 50, 59, 45} | ||
| {45, 11, 7, 50, 59} | ||
| {50, 11, 45, 7, 59} |
QUESTION 10
Usually, selection sort is more efficient than bubble sort due to fewer array element changes.
True
False
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
