

BJC AP CSP Unit 5 Lab 1
Presentation
•
Computers
•
10th - 12th Grade
•
Practice Problem
•
Medium
TSEE LEE
Used 38+ times
FREE Resource
16 Slides • 18 Questions
1
Algorithmic Efficiency
2
Open Ended
We'll watch the video together. Describe the strategy that the contestant used.
3
Multiple Choice
Below is an unsorted list of numbers, which is a list whose elements are not in order.
True or False? The list contain the number 121.
[171, 122, 211, 120, 71, 217, 12, 11, 211, 212, 711, 21, 210, 1, 17, 100, 121, 102, 127, 21, 721, 1, 712, 117]
True
False
4
Multiple Choice
True or False? The list contain the number 71.
[171, 122, 211, 120, 71, 217, 12, 11, 211, 212, 711, 21, 210, 1, 17, 100, 121, 102, 127, 21, 721, 1, 712, 117]
True
False
5
Multiple Choice
True or False? The list contain the number 172.
[171, 122, 211, 120, 71, 217, 12, 11, 211, 212, 711, 21, 210, 1, 17, 100, 121, 102, 127, 21, 721, 1, 712, 117]
True
False
6
Checking each item (element) in a list from left to right, one after another, to find a specific item.
It checks each item in sequential order and stops when a match is found or when the entire list has been checked (which happens when the item being searched for isn’t in the list).
Aka. Sequential search.
7
Multiple Choice
Suppose an unordered list has n elements. In the best case scenario, how many comparisons are required to find a specific value?
1
n
between 1 and n
Not enough info
8
Multiple Choice
Suppose an unordered list has n elements. In the worst case scenario, how many comparisons are required to find a specific value?
1
n
between 1 and n
Not enough info
9
Multiple Choice
Suppose an unordered list has 1,000 elements, and it takes up to 1 second to search through the entire list.
Then, more items are added to the list so that it now has 1,000,000 elements. How many seconds will it take to search this list?
1
1,000
1,000,000
Not enough info
10
An algorithm takes linear time if multiplying the input size by ten multiplies the time required by ten.
A linear search (or sequential search) algorithm checks each element of a list in order, a process which takes linear time.
11
Multiple Choice
You choose a number between 1 and 1,000. Roughly how many guesses will I take to guess your number, if you tell me to go higher or lower?
1
10
100
1000
12
1) Set min & max
2) Average min & max to find the index of the middle element
3) Compare value at middle to target; if matched, return index
4) If element < target, set min to middle+1; Else, set max to middle-1
5) Repeat steps 2-4 until value is found or if min>max
13
Fill in the Blanks
One- or two-word answer if possible.
Challenge: Binary search can only be performed on a list that is ...?
Type answer...
14
Multiple Choice
Suppose an ordered list has n elements. In the best case scenario, using binary search, how many comparisons are required to find a specific value? (In CS, log is usually base 2.)
1
log n
n/2
n
15
Multiple Choice
Suppose an ordered list has n elements. In the worst case scenario, using binary search, how many comparisons are required to find a specific value? (In CS, log is usually base 2.)
1
log n
n/2
n
16
Are you searching for one thing in a list or are you finding all the things in the list with some characteristic?
Is your data sorted or unsorted?
17
Multiple Choice
Suppose an ordered list has 1,000 elements, and it takes up to 1 second to binary search through the entire list.
Then, more items are added to the list so that it now has 1,000,000 elements. How many seconds will it take to search this list?
1
2
10
500
1,000
18
Multiple Choice
Suppose an ordered list has 1,000 elements, and it takes up to 1 second to binary search through the entire list.
How many seconds will it take to search a list of 1,000,000,000?
3
6
log (1000)
log (1,000,000)
1000
19
Linear time: if the number of steps is proportional to the input size. 2x the input size, 2x the time.
Sublinear time: if the time grows more slowly than the size.
20
Constant time: if it takes the same amount of time regardless of input size.
Quadratic time: if the number of steps is proportional to the square of the input size.
21
Polynomial time: if the number of steps is less than or equal to a power of the size of the input, such as constant (n0), sublinear, linear (n1), quadratic (n2), or cubic (n3).
Exponential time: if the number of steps is less than or equal to a function like 2n, 10n, etc., which is much slower than any polynomial.
22
Multiple Choice
The table shows the computer time it takes to complete various tasks on the data of different sized towns.
Based on the information in the table, which of the following tasks is likely to take the longest amount of time when scaled up for a city of population 1,000,000?
Backing up data
Sorting data
Searching through data
Entering data
23
An exponential time algorithm still solves a problem correctly; it just takes a unreasonably long time.
Exponential time algorithms can sometimes be replaced by heuristics, which are polynomial-time algorithms that don't solve the problem exactly, but give a good enough approximation.
A decision problem is a problem with a true/false answer (for example, "is 5,825,496,221 a prime number?").
An optimization problem is one with the goal of finding the best solution among many (for example, "what's the best school schedule to place every student into as many of their requested classes as possible?").
24
Multiple Choice
Which type of algorithms may be replaced by heuristics?
Decision problems
Optimization problems
Both
Neither
25
There must be a shortest route.
There is no known polynomial time algorithm for this problem.
One heuristic: Pick a path at random, then try to improve it by swapping two cities repeatedly until you can't make the path better with such small changes.
26
You'll find the best nearby path (the top of a hill)
There might be a higher hill (a better path) further away
You'll be stuck at a local maximum
27
Multiple Choice
In which of the following problems is a heuristic solution appropriate?
Find the best combination of ingredients for spaghetti sauce.
Find the biggest item in a list.
Find the combination to a lock with n numbers.
Playing chess.
28
A decidable problem a decision problem for which it's possible to write an algorithm that will give a correct output for all inputs. EX: "Is the integer even?"
An undecidable problem is the opposite. It's not possible to write an algorithm that will give a correct output for all inputs—even though it might be possible for some of them. EX: "Will this computer program that takes an input always eventually report a result?"
29
In sequential computing, operations are performed in order one at a time.
In parallel computing, the program is broken into smaller steps; some steps are performed at the same time. Modern computers have multiple processors (2, 4, or 8 cores) in a single computer, so you can do small-scale parallel processing on your desktop machine.
30
Multiple Choice
How long will this sequential program take to run?
4
6
8
18
31
Multiple Choice
Careful! How long will this parallel program take to run?
6
8
14
18
32
Distributed computing is a form of parallel computing that uses multiple computers (perhaps even spread out around the world).
A processor is a piece of circuitry inside a computer that carries out the instructions from programs.
33
Programmers refer to the speedup of parallel solution to describe how many times as fast the parallel solution is compared to the sequential solution:
E.g. Sequential time is 10 mins, parallel time is 2 mins. speedup = 10/2 = 5. Parallelization is 5x faster.
34
APClassroom.CollegeBoard.org: "5.1 Checkpoint", 7 Q's
KhanAcademy.org: The building blocks of algorithms, Expressing an algorithm, and Verifying an algorithm (may be next day)
Algorithmic Efficiency
Show answer
Auto Play
Slide 1 / 34
SLIDE
Similar Resources on Wayground
25 questions
Electron Configuration, Orbital Notation, & Dot diagrams
Presentation
•
9th - 12th Grade
27 questions
iGCSE Computer Science - Sound
Presentation
•
10th - 12th Grade
28 questions
41 JavaScript Instrukcje sterujące
Presentation
•
KG
27 questions
Lesson on Factoring GCF and Difference of Two Squares
Presentation
•
9th - 12th Grade
27 questions
Cell Theory, Prokaryotes & Eukaryotes
Presentation
•
10th - 11th Grade
25 questions
Computer Science Principles Unit 9 Review
Presentation
•
9th - 12th Grade
28 questions
Bill of Rights
Presentation
•
10th - 12th Grade
25 questions
3.4 Dark Reaction / Calvin Cycle
Presentation
•
10th - 12th Grade
Popular Resources on Wayground
10 questions
How much do you know about our Portrait of an Eagle?
Quiz
•
10th Grade
10 questions
Fast Food Slogans
Quiz
•
6th - 8th Grade
21 questions
Continents and Oceans
Quiz
•
6th Grade
20 questions
Parts of Speech
Quiz
•
5th Grade
16 questions
Subject & Predicate
Quiz
•
5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
12 questions
Map Skills
Quiz
•
3rd Grade
22 questions
Continents and Oceans
Quiz
•
5th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials
Interactive video
•
6th - 10th Grade
20 questions
[AP CSP] Python Coding: Functions, Parameters, Return
Presentation
•
9th - 12th Grade
40 questions
Introduction to Microsoft Word
Quiz
•
8th - 12th Grade
20 questions
APCS Unit 1A
Quiz
•
9th - 12th Grade
24 questions
Binary
Quiz
•
9th - 12th Grade