Chapter 19
Self-Test
Top of Form
- The term _____ is used to describe the study of the function f as n becomes larger and larger without bound. (p.1198)
- A:mathematic
- B:asymptotic
- C:circular
- D:rhythmic
- The special member associated with each item in a data set that uniquely identifies an individual item in the data set is called the ____. (p.1185)
- A:name
- B:field
- C:key
- D:ID
- Given the unordered list [10, 7, 19, 5, 16], which of the following sequences represents the result of the second iteration of the bubble sort algorithm? (p.1204)
- A:[7, 10, 19, 5, 16]
- B:[16, 7, 5, 10, 19]
- C:[7, 5, 10, 16, 19]
- D:[7, 10, 5, 16, 19]
- The selection sort algorithm sorts a list by ____. (p.1208)
- A:partitioning the list into two sorted lists
- B:partitioning the list into two lists that are approximately the same size
- C:moving each element to its proper place in the sorted portion of the list
- D:None of the above
- With the exception of the last time through the loop, the binary search algorithm makes ____ key comparisons each time the loop is executed. (p.1189)
- A:1
- B:2
- C:3
- D:n - 2, where n is the number of items in the list
- The binary search algorithm ____. (p.1189)
- A:restricts the search to half of the list each time through the loop
- B:can be written iteratively or recursively
- C:is efficient for large lists
- D:all of the above
- Assume a block of code consists of two nested for loops containing an output statement. If the loops each iterate over the same range of indexes, the section of code is ____. (p.1201)
- A:O(1)
- B:O(log2n)
- C:O(n)
- D:O(n2)
- In a comparison tree, the ____ represents the final ordering of the nodes. (p.1217)
- A:leaf
- B:root
- C:branch
- D:binary tree
- Assume that the quick sort algorithm has been executed a few times on a list. The list now looks like [52, 13, 32, 48, 22, 11, 87, 55, 78, 96, 58, 66, 88, 45]. Which item will be the next item to be moved into a sublist? (p.1221)
- A:11
- B:45
- C:58
- D:98
- A binary tree is a comparison tree in which ____. (p.1217)
- A:each comparison has two outcomes
- B:each comparison can have one or more outcomes
- C:some comparisons may have zero outcomes
- D:some paths do not lead to leaf nodes
- The selection sort algorithm sorts a list by selecting the ____ element in the unsorted portion of the list and then moving this element to the top of the unsorted list. (p.1208)
- A:largest
- B:smallest
- C:empty
- D:None of the above
- Consider the list [35, 28, 18, 45, 62, 48, 30, 38]. Using the merge sort algorithm, after the first partition, which of the following elements are in the first sublist? (p.1225)
- A:35, 28, 18, 45
- B:35, 28, 18, 38
- C:18, 45, 62, 48
- D:62, 48, 60, 38
- Which of the following best describes the level of contribution that operations that are only performed once make to an algorithm's performance? (p.1195|1196)
- A:they contribute significantly to performance
- B:these operations are not dominant operations
- C:they do not significantly impact the algorithm's performance
- D:both b and c
- In the insertion sort algorithm on array-based lists, the firstOutOfOrder index is typically initialized to ____. (p.1215)
- A:0
- B:1
- C:n - 1, where n is the number of items in the list
- D:n, where n is the number of items in the list
- The sequential search is also called a _____. (p.1185)
- A:linear search
- B:circular search
- C:single search
- D:selective search
- Sequential and binary search algorithms are called ____-based search algorithms. (p.1202)
- A:code
- B:comparison
- C:analytical
- D:integer
- Which of the following best describes when the sorting work is done in the merge sort algorithm? (p.1226)
- A:when the list is partitioned into the first sublist and the second sublist
- B:when the first sublist and the second sublist are merged
- C:when swaps are performed
- D:when the data are input
- In the bubble sort, if the list is already sorted, how many assignments are performed? (p.1207)
- A:0
- B:1
- C:2
- D:n
- Assume that the quick sort algorithm has been executed a few times on a list. The list now looks like [52, 10, 23, 35, 17, 88, 65, 54, 2, 98, 33]. Which item is the pivot? (p.1220)
- A:17
- B:52
- C:88
- D:98
- Given the unordered list [10, 7, 19, 5, 16], which of the following sequences represents the result of the first iteration of the bubble sort algorithm? (p.1203)
- A:[7, 10, 19, 5, 16]
- B:[10, 7, 5, 16, 19]
- C:[19, 10, 7, 5, 16]
- D:[7, 10, 5, 16, 19]
- A binary search ____. (p.1187)
- A:can be performed on an unsorted list
- B:requires that the list be sorted
- C:sorts the elements in the list prior to searching the list
- D:is usually less efficient than a sequential search
- In a sequential search, the search item is called the ____. (p.1187)
- A:value
- B:target
- C:node
- D:None of the above
- In the best case for the insertion sort, the list is ____. (p.1216)
- A:already sorted
- B:not sorted
- C:sorted in reverse order
- D:partially sorted
- Let f be a function of n. Asymptotic means the study of the function f as n ____. (p.1198)
- A:varies from input file to input file
- B:varies with the number of coding statements in the program
- C:becomes larger and larger without bound
- D:remains constant
- Using the binary search algorithm, in a successful search, how many comparisons are performed during the last iteration of the loop? (p.1189)
- A:0
- B:1
- C:2
- D:n, where n is the number of items in the list
- The growth rate of g(n) = nlog2n is ____ g(n) = n. (p.1202)
- A:slower than
- B:faster than
- C:constant compared to
- D:about the same as
- Consider the list [63, 45, 32, 98, 46, 57, 28, 100]. Using the sequential search algorithm, how many comparisons are required to determine if the item 90 is in the list? (p.1186)
- A:0
- B:7
- C:8
- D:9
- For the bubble sort, the total number of comparisons is O(____). (p.1206)
- A:n
- B:n2
- C:log2n
- D:nlog2n
- The average number of comparisons for the merge sort algorithm is O(____). (p.1234)
- A:n
- B:n2
- C:log2n
- D:nlog2n
- Consider the list [45, 82, 25, 94, 50, 60, 78, 32, 92]. To begin using the quick sort algorithm, which item would be labeled the pivot? (p.1218)
- A:25
- B:50
- C:60
- D:94
- Consider the list [5, 7, 24, 30, 25, 62, 45, 16, 65, 50], which resulted after a few swaps during the selection sort. Which element is the leftmost element in the unsorted part of the list? (p.1209)
- A:16
- B:24
- C:25
- D:50
- The performance of the selection sort algorithm ____. (p.1212)
- A:depends on the initial arrangement of the data
- B:is always O(n2) for the # of comparisons
- C:is O(n) for the number of assignments
- D:all of the above
- Consider the list [63, 45, 32, 98, 46, 57, 28, 100]. Using the sequential search algorithm, how many comparisons are required to determine if the item 32 is in the list? (p.1186)
- A:0
- B:1
- C:3
- D:8
- On average, the sequential search algorithm makes how many comparisons? (p.1187)
- A:n/3
- B:n
- C:n2
- D:(n+1)/2
- In the binary search algorithm, in a successful search, the last time through the loop ____ key comparison(s) are made. (p.1189)
- A:0
- B:1
- C:2
- D:3
- The average case for the quick sort algorithm is O(____). (p.1225)
- A:n
- B:n2
- C:log2n
- D:nlog2n
- The merge sort algorithm is always O(____). (p.1234)
- A:O(1)
- B:O(n)
- C:O(log2n)
- D:O(nlog2n)
- The first key comparison preformed during the binary search algorithm is on the ____ item of the list. (p.1187)
- A:first
- B:second
- C:last
- D:None of the above
- The sequential search algorithm stops iterating when ____. (p.1185|1186)
- A:the target item has been found
- B:the entire list was searched unsuccessfully, that is, the item was not found
- C:the first item less than the target is found
- D:both a and b
- The _____ search algorithm uses the ‘‘divide and conquer'' technique to search the list. (p.1187)
- A:sequential
- B:linear
- C:binary
- D:division
- Using the binary search algorithm, in an unsuccessful search, how many key comparisons are performed during the last iteration of the loop? (p.1189)
- A:0
- B:1
- C:2
- D:n, where n is the number of items in the list
- The quick sort algorithm partitions a list into an upper sublist and a lower sublist. The upper sublist contains all items in the list that ____. (p.1218)
- A:have array indices larger than the index for the pivot element
- B:have a value greater than 47
- C:are greater than or equal to the pivot element
- D:have indices between 6 and 12
- The number of key comparisons refers to ____. (p.1185)
- A:the number of times the key of the search item is compared with the keys of the items in the list
- B:the number of swaps (or exchanges) that occur during execution
- C:the number of items in the list
- D:the number of temp variables
- The selection sort algorithm is good for ____. (p.1212)
- A:small lists
- B:medium size lists
- C:large lists
- D:lists of any size
- The ____ search algorithm is an optimal worst-case algorithm for solving search problems by the comparison method. (p.1202)
- A:sequential
- B:unary
- C:binary
- D:None of the above
- The ____ search algorithm sorts the elements in the list prior to searching the list. (p.1187)
- A:quadratic
- B:linear
- C:binary
- D:None of the above
- Which of the following best describes when the sorting work is done in the quick sort algorithm? (p.1218)
- A:when the list is partitioned into the lowerSublist and the upperSublist
- B:when the lowerSublist and the upperSublist are combined
- C:when swaps are performed
- D:when the data are input
- The worst case for the quick sort algorithm is O(____). (p.1225)
- A:n
- B:n2
- C:log2n
- D:nlog2n
- Which of the following is true about the quick sort and the merge sort algorithms? (p.1225)
- A:both algorithms partition the list in the same way
- B:the algorithms both partition the list but do not partition the list in the same way
- C:the merge sort partitions the list, but the quick sort does not
- D:the quick sort partitions the list, but the merge sort does not