Podcast
Questions and Answers
The advantage of a linear search is that
The advantage of a linear search is that
- it can be used on unordered data.
- it is simple.
- both A and D (correct)
- it is fast.
- it is efficient.
A(n) ______ search is more efficient than a(n) ______ search.
A(n) ______ search is more efficient than a(n) ______ search.
- string, double
- integer, double
- binary, linear (correct)
- linear, binary
- None of the above. All searches are equally efficient.
The linear search is adequate for searching through ______ arrays, but not through ______ ones.
The linear search is adequate for searching through ______ arrays, but not through ______ ones.
- any regular, vector
- ascending, descending
- char, string
- int, double
- small, large (correct)
Using a linear search, you are more likely to find an item than if you use a binary search.
Using a linear search, you are more likely to find an item than if you use a binary search.
A binary search begins by examining the ______ element of an array.
A binary search begins by examining the ______ element of an array.
If the item being searched for is not in the array, binary search stops looking for it and reports that it is not there when
If the item being searched for is not in the array, binary search stops looking for it and reports that it is not there when
When searching for an item in an unordered set of data, binary search can find the item more quickly than linear search.
When searching for an item in an unordered set of data, binary search can find the item more quickly than linear search.
A search can be performed on an array of
A search can be performed on an array of
A sorting algorithm can be used to arrange a set of ______ in ______ order.
A sorting algorithm can be used to arrange a set of ______ in ______ order.
The ______ sort usually performs fewer exchanges than the ______ sort.
The ______ sort usually performs fewer exchanges than the ______ sort.
To find a value that is in an unordered array of 100 items, how many values must linear search examine on average?
To find a value that is in an unordered array of 100 items, how many values must linear search examine on average?
To determine that an item is not in an unordered array of 100 items, how many values must linear search examine on average?
To determine that an item is not in an unordered array of 100 items, how many values must linear search examine on average?
To find a value in an ordered array of 100 items, how many values must binary search examine at most?
To find a value in an ordered array of 100 items, how many values must binary search examine at most?
If a bubble sort is used to arrange the numbers 7 5 3 9 2 6 in ascending order, what order will the data be in after the first pass?
If a bubble sort is used to arrange the numbers 7 5 3 9 2 6 in ascending order, what order will the data be in after the first pass?
If a selection sort is used to arrange the numbers 7 5 3 9 2 6 in ascending order, what order will the data be in after the first pass?
If a selection sort is used to arrange the numbers 7 5 3 9 2 6 in ascending order, what order will the data be in after the first pass?
When sorting an array of objects, if the values in the data member being sorted on are out of order for two objects, those two data values should be swapped.
When sorting an array of objects, if the values in the data member being sorted on are out of order for two objects, those two data values should be swapped.
Any sorting algorithm, such as bubble sort or selection sort, that can be used on data stored in an array can also be used on data stored in a vector.
Any sorting algorithm, such as bubble sort or selection sort, that can be used on data stored in an array can also be used on data stored in a vector.
If algorithm A requires 2n + 1 basic operations to process an input of size n, and Algorithm B requires 3n + 2 basic operations to process the same input, algorithms A and B are considered to be equally efficient.
If algorithm A requires 2n + 1 basic operations to process an input of size n, and Algorithm B requires 3n + 2 basic operations to process the same input, algorithms A and B are considered to be equally efficient.
A ______ search uses a loop to sequentially step through an array.
A ______ search uses a loop to sequentially step through an array.
A binary search requires that the elements be in order.
A binary search requires that the elements be in order.
The ______ search is adequate for searching through small arrays, but not through large ones.
The ______ search is adequate for searching through small arrays, but not through large ones.
Using a binary search, you are more likely to find an item than if you use a linear search.
Using a binary search, you are more likely to find an item than if you use a linear search.
If a binary search is used to search for the number 4 in the 11-element array shown here
int A[] = {1, 2, 3, 4, 6, 7, 8, 9, 10, 12, 17};
which value will the 4 be compared to first?
If a binary search is used to search for the number 4 in the 11-element array shown here int A[] = {1, 2, 3, 4, 6, 7, 8, 9, 10, 12, 17}; which value will the 4 be compared to first?
To determine that a value is not present in an unordered array of 50 items, how many values must linear search examine on average?
To determine that a value is not present in an unordered array of 50 items, how many values must linear search examine on average?
To find a value that is in an unordered array of 50 items, how many values must linear search examine on average?
To find a value that is in an unordered array of 50 items, how many values must linear search examine on average?
To find a value in an ordered array of 50 items, how many values must binary search examine at most?
To find a value in an ordered array of 50 items, how many values must binary search examine at most?
When searching for a particular object in an array of objects, it is necessary to compare the search key to the value in each examined object's key field.
When searching for a particular object in an array of objects, it is necessary to compare the search key to the value in each examined object's key field.
A(n) ______ algorithm arranges data into some order.
A(n) ______ algorithm arranges data into some order.
Sorted data can be ordered
Sorted data can be ordered
When an array is sorted from highest to lowest, it is said to be in ascending order.
When an array is sorted from highest to lowest, it is said to be in ascending order.
If a bubble sort is used to arrange the numbers 8 6 4 9 3 7 in ascending order, what order will the data be in after the first pass of the sort is completed?
If a bubble sort is used to arrange the numbers 8 6 4 9 3 7 in ascending order, what order will the data be in after the first pass of the sort is completed?
If a selection sort is used to arrange the numbers 8 6 4 9 3 7 in ascending order, what order will the data be in after the first pass of the sort is completed?
If a selection sort is used to arrange the numbers 8 6 4 9 3 7 in ascending order, what order will the data be in after the first pass of the sort is completed?
The ______ sort usually performs more exchanges than the ______ sort.
The ______ sort usually performs more exchanges than the ______ sort.
Selection sort requires _____ passes to put n data items in order.
Selection sort requires _____ passes to put n data items in order.
When sorting an array of objects, if the values in the data member being sorted on are out of order for two objects, those two data values should be swapped.
When sorting an array of objects, if the values in the data member being sorted on are out of order for two objects, those two data values should be swapped.
Any sorting algorithm, such as bubble sort or selection sort, that can be used on data stored in an array can also be used on data stored in a vector.
Any sorting algorithm, such as bubble sort or selection sort, that can be used on data stored in an array can also be used on data stored in a vector.
We can estimate the ______ of an algorithm by counting the number of basic steps it requires to solve a problem.
We can estimate the ______ of an algorithm by counting the number of basic steps it requires to solve a problem.
If algorithm A requires 2n + 1 basic operations to process an input of size n, and Algorithm B requires 3n + 2 basic operations to process the same input, algorithms A and B are considered to be equally efficient.
If algorithm A requires 2n + 1 basic operations to process an input of size n, and Algorithm B requires 3n + 2 basic operations to process the same input, algorithms A and B are considered to be equally efficient.
Flashcards
Linear Search Advantage
Linear Search Advantage
Linear search is simple and can be used on unordered data.
Binary Search Efficiency
Binary Search Efficiency
More efficient than linear search; works best on ordered datasets.
Linear Search Suitability
Linear Search Suitability
Suitable for small arrays, less efficient for large, unordered datasets.
Linear Search vs. Binary Search
Linear Search vs. Binary Search
Signup and view all the flashcards
Binary Search Starting Point
Binary Search Starting Point
Signup and view all the flashcards
Binary Search Termination?
Binary Search Termination?
Signup and view all the flashcards
Binary Search and Unordered Data
Binary Search and Unordered Data
Signup and view all the flashcards
Searchable Data Types
Searchable Data Types
Signup and view all the flashcards
Sorting Data Ordering
Sorting Data Ordering
Signup and view all the flashcards
Bubble Sort vs. Selection Sort
Bubble Sort vs. Selection Sort
Signup and view all the flashcards
Linear Search Average for 100 Items
Linear Search Average for 100 Items
Signup and view all the flashcards
Binary Search Maximum Examination
Binary Search Maximum Examination
Signup and view all the flashcards
First Pass Bubble Sort Example
First Pass Bubble Sort Example
Signup and view all the flashcards
First Pass Selection Sort Example
First Pass Selection Sort Example
Signup and view all the flashcards
Sorting Objects
Sorting Objects
Signup and view all the flashcards
Sorting Objects - Data Swapping
Sorting Objects - Data Swapping
Signup and view all the flashcards
Algorithm Efficiency
Algorithm Efficiency
Signup and view all the flashcards
Algorithm Comparison
Algorithm Comparison
Signup and view all the flashcards
Study Notes
Chapter 9 Test 1 and 2
- Linear Search Advantage: Simple, usable on unordered data.
- Binary Search Advantage: More efficient than linear search for ordered data.
- Linear Search Use Cases: Arrays of ints, doubles, chars and strings. Not ideal for large ordered arrays.
- Linear Search Limitations: Not efficient on large or ordered data.
- Binary Search Use Cases: Ordered arrays to find a specific item quickly.
- Binary Search for Missing Item: Array index first is greater than array last, or boolean variable found equals false.
- Binary Search Starting Point: Examines the middle element of the array.
- Binary Search Efficiency: More efficient for searching ordered data.
- Sorting Algorithm Use Cases: Arranging data (numbers, strings, etc.) in ascending or descending order.
- Bubble Sort: A sorting algorithm that progressively moves values to their correct positions.
- Bubble Sort Pass Order: Values are swapped on each pass to move larger values towards the end
- Selection Sort Pass Order: Finds the smallest element in each pass and places it in the beginning.
- Sorting Algorithms and STL Vectors: Possible to use bubble and selection sort with STL vectors.
- Algorithm Complexity: Measured by the number of basic steps for a given input size.
- Object Comparison in Arrays of Objects: Compare search key with a certain field in each object.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.