test 3 c++

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/25

encourage image

There's no tags or description

Looks like no tags are added yet.

26 Terms

1
New cards

The advantage of a linear search is that

it is simple and it can be used on unordered data
A linear search starts at the beginning and checks each item one at a time

2
New cards

A(n)_____ search is more efficient than a(n)_______ search.

binary, linear
A linear search checks one value at a time (doesnt have to be stored data)
A binary search keeps eliminating half of the remaining values (requires sorted data)

3
New cards

The linear search is adequate for searching through ______ arrays but not through _____ ones.

small, large
linear may have to check every element
5 elements easy, short
10000 elements harder, longer

4
New cards

Using a linear search you are more likely to find an item than if you use a binary search

FALSE
binary is more efficent and faster

5
New cards

A binary search begins by examining the _____ element of an array

middle

6
New cards

If the item being searched for is not in the array, binary search stops looking for it and reports that it is not there when

array infex first > array index last
this means there are no elements left to search

7
New cards

When searching for an item in an unordered set of data, binary search can find the item more quickly than linear search

FALSE
binary requires sorted/ordered data

8
New cards

A search can be performed on an array of

integers, strings objects, whether the data is in order or not

9
New cards

a sorting algorithm can be used to arrange a set of ____ in ____ order

numeric or string values ascending or descending,

10
New cards

the _____ sort usually performs fewer exchanges than the ______ sort

selection, bubble
bubble sort swaps values constantly
selection sort finds the smallest value and usually makes one exchange

11
New cards

to find a value that is in an unordered array of 100 items, how many values must linear seach examine on average?

50
linear search starts at the beginning but the value can be anywhere

12
New cards

to determine that an item is not in an unordered array of 100 items, how many values must linear search examine on average?

100

13
New cards

to find a value in an ordered array of 100 items how many values must binary search examine at most?

7
binary search keeps cutting the search area apporximately in half
100 → 50 → 25 → 12 → 6 → 3 → 1

14
New cards

When sorting an array of objects or structures one must decide which data item to sort on

True

15
New cards

When sorting an array of objects, if the values in the data member being sorted on are out of order for two objects, it is nececessary to

swap the entire two objects
if sorting highest girst, swap other data

16
New cards

Bubble sort and selection sort can also be used with STL vectors

TRUE
algorithms arent exclusive to arrays

17
New cards

We can measure the complexity of an algorithm that solves a computational problem by determining the number of _____ for an input size of n

basic steps it requires
Algorithm efficiency is measured by how many basic steps are needed as the input gets larger

18
New cards
19
New cards
20
New cards
21
New cards
22
New cards
23
New cards
24
New cards
25
New cards
26
New cards