
linear vs binary search
Presentation
•
Computers
•
8th Grade
•
Practice Problem
•
Easy
Manik Kusuma
Used 3+ times
FREE Resource
12 Slides • 2 Questions
1
Linear Search Vs Binary Search
Cont. learning Procedure (define and calling)
in class activity 28 October 2024
check discussion in managebac
for missing assignments
2
Two things to do in Procedure
Define
Call
Using procedures in your programming is called modular programming.
The advantages of using procedures:
1. Program became short and easier to read
2. Procedures can be reused, so it is saving time
Review: Procedure
3
Labelling
Matching the following programs
List
If Statement
Define Procedure
Conditional Loop
Call Procedure
4
Last week assignment
(Procedure)
If you submit only one file (Choice == C and Choice == D),
please submit the second one that using procedure (Choice == A for add_atom(), and Choice == B for remove_atom()), the instruction is in the task (click the slides link for name of the files)
5
Count through the list from the first
Compare each item to the search term
If there is a match, the item is in the list
Linear Search
Sort the list into order
Find the midpoint of the list
Compare the search term to the midpoint, is it higher or lower?
Keep splitting the list until it has only one
Binary Search
Search Atom Finder
6
Linear Search (Operators)
The return operator command will stop the procedure and 'return' to the main program, example:
click the link to see sample code.
Return (operator)
The relational operator in compares a single value and a list, try the code below:
click the link then try in online-python program
in (operator):
7
Review: Traverse a list (football team list)
Let's look at this table (for simple loop in python)
len = length
index start from 0
8
Match
Match the following for linear search
Store the input as a variable called 'name'
Find the stop value (length of list)
Use a for loop to count through the list one item at a time.
An if statement. The logical test
if the test is True, print a message
name = input("Enter a name:")
stop = len(atoms)
for i in range (stop):
if atoms[i] == name:
print (name, "found in list")
name = input("Enter a name:")
stop = len(atoms)
for i in range (stop):
if atoms[i] == name:
print (name, "found in list")
9
Let's try the code (linear search)
Click this link follow the instructions in google docs,
the file that you need to submit are .pdf(gdocs), and .py(python)
submit in managebac, total file needs to submit are 2 files
time: 15 Minutes
finish it together with your partner
10
Binary Search
Sort the list into order
Find the midpoint of the list
Compare the search term to the midpoint, is it higher or lower?
Keep splitting the list until it has only one
11
Binary Search
Sort the list into order
Find the midpoint of the list
Compare the search term to the midpoint, is it higher or lower?
Keep splitting the list until it has only one
12
Advantages and disadvantages
13
Let's try the code (Binary search)
Click the link follow the instructions in google docs.
the file that you need to submit are .pdf(gdocs), and .py(python)
submit in managebac (2 files)
Total files submit in managebac are 4 files (2 python, 2 PDF gdocs = linear and binary search)
time: 15 Minutes
finish it together with your partner
14
Continue the project
Progress submission (use procedure in your python project) then save and submit in managebac
Progress for this week and submission on November 4th, find the teacher then ask the approval for your project. The approval forms you can click this link after you got approval, you may begin to create your presentation.
Linear Search Vs Binary Search
Cont. learning Procedure (define and calling)
in class activity 28 October 2024
check discussion in managebac
for missing assignments
Show answer
Auto Play
Slide 1 / 14
SLIDE
Similar Resources on Wayground
11 questions
Articles of Confederation
Presentation
•
8th Grade
11 questions
Solving Equations Review
Presentation
•
8th Grade
11 questions
Ecosystems (interrelationships)
Presentation
•
8th Grade
10 questions
Freytag's Pyramid Practice
Presentation
•
8th Grade
8 questions
Product of Powers vs Power of Powers
Presentation
•
8th Grade
10 questions
Simple Interest
Presentation
•
8th Grade
10 questions
Multiplying and Dividing with Scientific Notation
Presentation
•
8th Grade
10 questions
Common and Proper Nouns
Presentation
•
8th Grade
Popular Resources on Wayground
20 questions
"What is the question asking??" Grades 3-5
Quiz
•
1st - 5th Grade
20 questions
“What is the question asking??” Grades 6-8
Quiz
•
6th - 8th Grade
10 questions
Fire Safety Quiz
Quiz
•
12th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
34 questions
STAAR Review 6th - 8th grade Reading Part 1
Quiz
•
6th - 8th Grade
20 questions
“What is the question asking??” English I-II
Quiz
•
9th - 12th Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
47 questions
8th Grade Reading STAAR Ultimate Review!
Quiz
•
8th Grade
Discover more resources for Computers
20 questions
“What is the question asking??” Grades 6-8
Quiz
•
6th - 8th Grade
34 questions
STAAR Review 6th - 8th grade Reading Part 1
Quiz
•
6th - 8th Grade
47 questions
8th Grade Reading STAAR Ultimate Review!
Quiz
•
8th Grade
44 questions
8th Grade Social Studies - Staar Review 2021
Quiz
•
8th Grade
20 questions
8th Grade Science STAAR Review
Quiz
•
8th Grade
8 questions
Amoeba Sister Asexual vs Sexual Reproduction
Interactive video
•
8th Grade
15 questions
Pythagorean Theorem Word Problems Quizizz
Quiz
•
8th Grade
29 questions
8th Grade Social Studies STAAR Review Part 2
Quiz
•
8th Grade