Services
Discover
Homeschooling
Ask a Question
Log in
Sign up
Filters
Done
Question type:
Essay
Multiple Choice
Short Answer
True False
Matching
Topic
Computing
Study Set
C++ Programming Study Set 1
Quiz 18: Searching and Sorting Algorithms
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 1
Multiple Choice
Consider the following list:int list[] = {4, 8, 19, 25, 34, 39, 45, 48, 66, 75, 89, 95} When performing a binary search for 75, after the first comparison, the search is restricted to ____.
Question 2
True/False
The selection sort algorithm finds the location of the smallest element in the unsorted portion of the list.
Question 3
Multiple Choice
A sequential search of an n-element list takes ____ key comparisons if the item is not in the list.
Question 4
True/False
The binary search algorithm can be written iteratively or recursively.
Question 5
True/False
In a bubble sort, the smaller elements move toward the bottom, and the larger elements move toward the top of the list.
Question 6
Multiple Choice
With the binary search algorithm, ____ key comparison(s) is/are made in the successful case-the last time through the loop.
Question 7
True/False
The sequential search algorithm does not require that the list be sorted.
Question 8
True/False
In a binary search, first, the search item is compared with the last element of the list.
Question 9
True/False
The swap function of quick sort is written differently from the swap function for selection sort.
Question 10
Multiple Choice
In the average case, sequential search typically searches ____.
Question 11
Multiple Choice
The formula to find the index of the middle element of a list is ____.
Question 12
Multiple Choice
Assume that list consists of the following elements.What is the result after bubble sort completes? int list[] = {2, 56, 34, 25, 73, 46, 89, 10, 5, 16};
Question 13
Multiple Choice
In a bubble sort for list of length n, the first step is to compare elements ____.
Question 14
Multiple Choice
Consider the following list:int list[] = {4, 8, 19, 25, 34, 39, 45, 48, 66, 75, 89, 95} When performing a binary search, the target is first compared with ____.
Question 15
Multiple Choice
The sequential search algorithm uses a(n) ____ variable to track whether the item is found.
Question 16
Multiple Choice
In the bubble sort algorithm, the following code accomplishes swapping values in elements at positions index and index + 1.
Question 17
True/False
Suppose that L is a sorted list of size 1024, and we want to determine whether an item x is in L.From the binary search algorithm, it follows that every iteration of the while loop cuts the size of the search list by half.