• Home
  • Textbooks
  • Starting out with C++: From Control Structures through Objects
  • Searching and Sorting Arrays

Starting out with C++: From Control Structures through Objects

Tony Gaddis

Chapter 8

Searching and Sorting Arrays - all with Video Answers

Educators


Chapter Questions

Problem 1

Why is the linear search also called "sequential search"?

Check back soon!

Problem 2

If a linear search function is searching for a value that is stored in the last element of a 10,000-element array, how many elements will the search code have to read to locate the value?

Check back soon!

Problem 3

In an average case involving an array of N elements, how many times will a linear search function have to read the array to locate a specific value?

Check back soon!

Problem 4

A binary search function is searching for a value that is stored in the middle element of an array. How many times will the function read an element in the array before finding the value?

Check back soon!

Problem 5

What is the maximum number of comparisons that a binary search function will make when searching for a value in a 1,000 -element array?

Check back soon!

Problem 6

Why is the bubble sort inefficient for large arrays?

Check back soon!

Problem 7

Why is the selection sort more efficient than the bubble sort on large arrays?

Check back soon!

Problem 8

The _________ search algorithm steps sequentially through an array, comparing each item with the search value.

Check back soon!

Problem 9

The _________ search algorithm repeatedly divides the portion of an array being searched in half.

Check back soon!

Problem 10

The _________ search algorithm is adequate for small arrays but not large arrays.

Check back soon!

Problem 11

The _________ search algorithm requires that the array’s contents be sorted.

Check back soon!

Problem 12

If an array is sorted in _________ order, the values are stored from lowest to highest.

Check back soon!

Problem 13

If an array is sorted in _________ order, the values are stored from highest to lowest.

Check back soon!

Problem 14

True or False
T F If data are sorted in ascending order, it means they are ordered from lowest value to highest value.

Check back soon!

Problem 15

True or False
T F If data are sorted in descending order, it means they are ordered from lowest value to highest value.

Check back soon!

Problem 16

True or False
T F The average number of comparisons performed by the linear search on an array of N elements is N/2 (assuming the search values are consistently found).

Check back soon!

Problem 17

True or False
T F The maximum number of comparisons performed by the linear search on an array of N elements is N/2 (assuming the search values are consistently found).

Check back soon!
01:43

Problem 18

Complete the following table calculating the average and maximum number of comparisons the linear search will perform, and the maximum number of comparisons the binary search will perform.
Table can't copy

Sherrie Fenner
Sherrie Fenner
Numerade Educator