Question
c++ 1. A binary search begins by examining the ________ element of an array. 1. last 2. middle 3. largest 4. first 5. smallest 2.
c++
1. A binary search begins by examining the ________ element of an array.
1. last
2. middle
3. largest
4. first
5. smallest
2. A bubble sort is being used to arrange the following set of numbers in ascending order:
7 5 3 9 2 6
After the first pass of the sort is completed, what order will the data be in?
1. 2 3 5 6 7 9
2. 5 7 3 9 2 6
3. 5 3 7 2 6 9
4. 2 5 3 9 7 6
5. None of the above
3. A search can be performed on an array of ________ .
1. strings
2. integers
3. All of the above
4. objects
5. A and B, but not C
4. A selection sort is being used to arrange the following set of numbers in ascending order:
7 5 3 9 2 6
After the first pass of the sort is completed, what order will the data be in?
1. 5 7 3 9 2 6
2. 2 3 5 6 7 9
3. 2 5 3 9 7 6
4. 5 3 7 2 6 9
5. None of the above
5. A sorting algorithm can be used to arrange a set of ________ in ________ order.
1. strings, ascending
2. strings, descending
3. numeric values, ascending
4. numeric values, descending
5. All of the above
6. A(n) ________ search is more efficient than a(n) ________ search.
1. integer, double
2. linear, binary
3. string, double
4. binary, linear
5. None of the above; all searches are equally efficient.
7. 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, algorithm A is considered to be more efficient than Algorithm B.
1. True
2. False
8. 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 ________.
1. Boolean variable found = false
2. it finds a value larger than the search key
3. array index first > array index last
4. it has examined all the elements in the array
5. Boolean variable found = true
9. The ________ sort usually performs fewer exchanges than the ________ sort.
1. selection, bubble
2. bubble, selection
3. linear, binary
4. binary, linear
5. linear, bubble
10. The advantage of a linear search is that ________.
1. it is simple
2. it is efficient
3. it is fast
4. it can be used on unordered data
5. both A and D
11. The linear search is adequate for searching through ________ arrays, but not through ________ ones.
1. small, large
2. char, string
3. int, double
4. any regular, vector
5. ascending, descending
12. To determine that a item is not in an unordered array of 100 items, linear search must examine an average of ________ values.
1. 7
2. 10
3. 50
4. 100
5. 101
13. To find a value that is in an unordered array of 100 items, linear search must examine an average of ________ values.
1. 7
2. 10
3. 50
4. 100
5. 101
14. To locate a value in an ordered array of 100 items, binary search must examine at most ________ values.
1. 7
2. 10
3. 50
4. 100
5. 101
15. True/False: Bubble sort and selection sort can also be used with STL vectors.
1. True
2. False
16. True/False: Using a linear search, you are more likely to find an item than if you use a binary search.
1. True
2. False
17. True/False: When searching for an item in an unordered set of data, binary search can find the item more quickly than linear search.
1. True
2. False
18. True/False: When sorting an array of objects or structures, one must decide which data item to sort on.
1. True
2. False
19. We can measure the complexity of an algorithm that solves a computational problem by
determining the number of ________ for an input of size n.
1. basic steps it requires
2. variables it uses
3. operations it performs
4. times it loops
5. output statements it has
20. When sorting an array of objects, if the values in the data member being sorted on are out of order for two objects, it is necessary to ________.
1. examine a different data member
2. swap these two data values
3. swap one-by-one all data members in the two objects
4. swap the two objects
5. stop the sort
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started