AP CSP Pages 115-139

0.0(0)
studied byStudied by 1 person
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/21

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

22 Terms

1
New cards

Given a collection of numbers, find and remove all zeros

Data cleanup algorithm

2
New cards

(Data Cleanup Algorithm) Scans a list from left to right, when a zero is found, shift all values to its right one slot to the left

Shuffle Left Algortihm

3
New cards

best case for shuffle left algorithm

order of magnitude n

4
New cards

Create a second, initially empty, list Look at each value in the original If it is non-zero, copy it to the second list

Copy-Over Algorithm

5
New cards

Is the copy-over algorithm time and space efficient

yes, no

6
New cards

What is the Copy-Over algorithm an example of

Time-space tradeoff

7
New cards

A data cleanup that squeezes out zeros and finishes when both data pointers converge at a nonzero value.

Converging Pointers Algorithm

8
New cards

Is the Converging Pointers Algorithm time and space efficient

yes, yes

9
New cards

What order of magnitude is the converging-pointers algorithm

Order of magnitude n

10
New cards

Given a target value and an ordered list of values, find the location of the target in the list, if it occurs, by starting in the middle and splitting the range in two with each comparison

Binary Search Algorithm

11
New cards

What is the unit of work for the binary search algorithm

The number of comparisons

12
New cards

How much work does the binary search algorithm do compared to the sequential search algorithm

Half as much

13
New cards

worst case for binary search algorithm

order of magnitude lg n

14
New cards

What is the fastest order of magnitude

order of magnitude lg n

15
New cards

How does the binary search's efficiency compare to the sequential search

Faster, but needs a sorted list

16
New cards

What is the unit of work for the pattern matching algorithm

comparing the text to the pattern

17
New cards

Best case for pattern matching

order of magnitude n

18
New cards

worst case for pattern matching

order of magnitude m * n

19
New cards

worst case for shuffle left algorithm

order of magnitude n^2

20
New cards

best case for binary search

order of magnitude 1

21
New cards

What algorithm is more work than any polynomial in n

exponential algorithm

22
New cards

run in polynomial time but do not give optimal solutions

approximation algorithms