Exam 18: Searching and Sorting Algorithms

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

To construct a search algorithm of the order less than log2n,it cannot be ____________________ based.

(Short Answer)
4.8/5
(42)

In the bubble sort algorithm,the following code accomplishes swapping values in elements at positions index and index + 1.

(Multiple Choice)
4.9/5
(35)

The swap function of quick sort is written differently from the swap function for selection sort.

(True/False)
4.7/5
(50)

The binary search algorithm can be written iteratively or recursively.

(True/False)
4.8/5
(42)

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};

(Multiple Choice)
4.7/5
(34)

Assuming the following list declaration,which element is at the position 0 after the first iteration of selection sort? int list[] = {16,30,24,7,62,45,5,55}

(Multiple Choice)
4.8/5
(38)

With the binary search algorithm,____ key comparison(s)is/are made in the successful case-the last time through the loop.

(Multiple Choice)
4.9/5
(38)

The following C++ function implements the ____________________ sort algorithm. template <class elemType> void Sort(elemType list[],int length) { \quad for (int iteration = 1; iteration < length; iteration++) \quad { \quad\quad for (int index = 0; index < length - iteration; index++) \quad\quad { \quad\quad\quad if (list[index] > list[index + 1]) \quad\quad\quad { \quad\quad\quad\quad elemType temp = list[index]; \quad\quad\quad\quad list[index] = list[index + 1]; \quad\quad\quad\quad list[index + 1] = temp; \quad\quad\quad\quad } \quad\quad\quad } \quad\quad } }

(Short Answer)
5.0/5
(36)

In a binary search,first,the search item is compared with the last element of the list.

(True/False)
4.8/5
(39)

In general,the selection sort algorithm is good only for small lists because ____________________ grows rapidly as n grows.

(Short Answer)
4.9/5
(37)
Showing 41 - 50 of 50
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)