Chapter 8 C++

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

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

It loops sequentially step through an array, starting with the first element. It compares each element with the value being searched for, and stops when either the value is found or the end of the array is encountered.

Why is the bubble sort inefficient for large arrays?

It moves the items int he array only by one element at a time.

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?

It will have to read 10,000 elements of the array.

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

Linear or Sequential

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

Linear search

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?

Log2(1000) = 10 times Formula: Log2(N)

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

N/2 times

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.

One time

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

Selection sort performs fewer exchanges because it moves items immediately to their final position in the array.

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

T

True or False! 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).

T

if an array is sorted in _____ order, the values are sorted from highest to lowest.

Descending

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

F

True or False! 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).

F, N times because it went through all of them

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

Ascending

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

Binary search

The _____ search algorithm requires that the array's contents be sorted.

Binary search


Kaugnay na mga set ng pag-aaral

Unit 1 - Differentiated Instruction

View Set

Pharmacology Week 1 Chapter Questions

View Set

Portfolio Management Theory, Portfolio Development, and Asset Allocation

View Set

Leadership Chapter 1 Quiz (Mindtap)

View Set

Civil War and Reconstruction - Why did the Civil War last four years?

View Set

Chapter 33: Coronary Artery Disease and Acute Coronary Syndrome

View Set