SlideShare a Scribd company logo
Do Now
● 2.4 Do Now
○ On your own
○ 5 minutes
Agenda
● 2.4 Do Now
● Unit 2 Tracker
● Unit 2 Test/Study Guide
● 2.4 Lecture
○ SWBAT use various sorting algorithms to sort data
● 2.4 Activity
○ With a partner
● 2.4 Exit Ticket
○ 15 minutes timed
● Finish Early?
○ Revises from Unit 1/Unit 2 Tracker
○ Typing Homework
○ Unit 2 Extra Credit Opportunities
2.4 Sorting
Algorithms
Ms. Deutsch
Do Now
Sort the following numbers from lowest to highest. Then
answer, the two questions.
15 6 8 34 5 26 17 18 41 22
1. What was your strategy in sorting?
DISCUSSION
a) Think of a time when you were using a computer
application or website that sorted values for you.
b) Think about how you sorted the numbers in the Do Now.
Would you use the same method to sort a set of 5000
numbers?
i) What might you change?
ii) What if you had a buddy to help you sort?
ALGORITHMS
● An algorithm is a specific process or set of rules followed to get to a
solution.
Examples:
● Recipes
● handshake problem
● Directions
● fencepost problem
● -n-1
SORTING ALGORITHMS
● Algorithms computers use to help it sort data
● Computer can only compare two items at a time
● We are going to learn TWO sorting algorithms.
○ SELECTION SORT
○ INSERTION SORT
SELECTION SORT
Sort a set of data by continuously “selecting”
the next lowest value from the unsorted list and
adding it to the sorted list (new set)
SELECTI
ON SORT
Algorithm:
1. Take the first item. Compare it to the
second item. The lower one is your
current minimum.
2. Continue to compare current min with the
rest of the values, always keeping the
lower number.
3. Once minimum is found, move to new
set.
4. Repeat.
EACH TURN, IT IS FINDING
THE LOWEST NUMBER
AND THEN MOVING IT TO THE
LEFT
(SORTED LIST)​
Selection Sort
3 1 6 2 5 4
● Pass #1: 1 3 6 2 5 4
● Pass #2: 1 2 3 6 5 4
● Pass #3: 1 2 3 6 5 4
● Pass #4: 1 2 3 4 5 6
● Pass #5: 1 2 3 4 5 6
Number of Comparisons
● 5
● 4
● 3
● 2
● 1
Remember, you can only compare
two items at a time.
5 + 4 + 3 + 2 + 1​
15 COMPARISONS​
Algorithm: n(n-1)/2
https://visualgo.net/en/sorting
INSERTION SORT
Takes an unsorted set of
values and sorts it in a
new set by “inserting” one
value at a time.
INSERTION
SORT
Algorithm:
1. Take the first card in the unsorted set and put it in
the back of the new sorted set.
2. If it’s lower than the one before it, put it in front. If it is
higher, put it behind.
3. Repeat step 2 until the card is in its proper place.
4. Repeat steps 1-3 until all cards are sorted.
Each new value is “inserted” into the
correct spot in the order, one at a time.
Insertion Sort
3 1 6 2 5 4
● Pass #1: 1 3 6 2 5 4
● Pass #2: 1 3 6 2 5 4
● Pass #3: 1 2 3 6 5 4
● Pass #4: 1 2 3 5 6 4
● Pass #5: 1 2 3 4 5 6
Number of Comparisons
● 1
● 1
● 3
● 2
● 3
Remember, you can only compare
two items at a time.
1 + 1 + 3 + 2 + 3
10 COMPARISONS​
https://visualgo.net/en/sorting
EXTRA CREDIT
Receive up to 20 extra credit points by:
1. Creating 2 videos, 1 for selection sort
and 1 for insertion sort.
2. You are verbally explaining the
difference as you show the difference,
similar to the provided example but
with a verbal explanation.
3. Be creative and use whatever
supplies you have around your house
to sort. Playing cards, paper, jersey
numbers, etc.
Agenda
● 2.4 Do Now
● Unit 2 Tracker
● Unit 2 Test/Study Guide
● 2.4 Lecture
○ SWBAT use various sorting algorithms to sort data
● 2.4 Activity
○ With a partner
● 2.4 Exit Ticket
○ 15 minutes timed
● Finish Early?
○ Revises from Unit 1/Unit 2 Tracker
○ Typing Homework
○ Unit 2 Extra Credit Opportunities

More Related Content

Similar to 2.4 Lecture.pptx

8:00 GED Math Week 1 Tue
8:00 GED Math Week 1 Tue8:00 GED Math Week 1 Tue
8:00 GED Math Week 1 Tue
Clark College ABE/GED Math
 
Lecture 1 computing and algorithms
Lecture 1  computing and algorithmsLecture 1  computing and algorithms
Lecture 1 computing and algorithms
alvin567
 
Merge sort analysis and its real time applications
Merge sort analysis and its real time applicationsMerge sort analysis and its real time applications
Merge sort analysis and its real time applications
yazad dumasia
 
Ns1.4 A Factors & Primes
Ns1.4 A Factors & PrimesNs1.4 A Factors & Primes
Ns1.4 A Factors & Primes
Mr. M
 
Agent tic tac-toe - an interactive game for algorithmic and computational th...
Agent tic tac-toe  - an interactive game for algorithmic and computational th...Agent tic tac-toe  - an interactive game for algorithmic and computational th...
Agent tic tac-toe - an interactive game for algorithmic and computational th...
LorennRuster
 
Algorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 5: Sorting Algorithms IIAlgorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 5: Sorting Algorithms II
Mohamed Loey
 
16807097.ppt b tree are a good data structure
16807097.ppt b tree are a good data structure16807097.ppt b tree are a good data structure
16807097.ppt b tree are a good data structure
SadiaSharmin40
 
Function tables
Function tables Function tables
Function tables
msfochler
 
Stanford splash spring 2016 basic programming
Stanford splash spring 2016 basic programmingStanford splash spring 2016 basic programming
Stanford splash spring 2016 basic programming
Yu-Sheng (Yosen) Chen
 
Denver MuleSoft Meetup Feb 24, 2021 - What's Batch Got to Do with It
Denver MuleSoft Meetup Feb 24, 2021 - What's Batch Got to Do with ItDenver MuleSoft Meetup Feb 24, 2021 - What's Batch Got to Do with It
Denver MuleSoft Meetup Feb 24, 2021 - What's Batch Got to Do with It
Brian Statkevicus
 
MySQL Query Optimisation 101
MySQL Query Optimisation 101MySQL Query Optimisation 101
MySQL Query Optimisation 101
Federico Razzoli
 
Stage 6 fraction
Stage 6  fractionStage 6  fraction
Stage 6 fraction
Deklay Nainggolan
 
Adding and subtracting
Adding and subtractingAdding and subtracting
Adding and subtracting
Diana Pineda
 
Chapter 2 Study Guides
Chapter 2  Study  GuidesChapter 2  Study  Guides
Chapter 2 Study Guides
♥Moriah♥
 
Decision Science.pdf
Decision Science.pdfDecision Science.pdf
Decision Science.pdf
pandeyaman577
 
Algebra Foundations Series- 1.2 Order of Operations
Algebra Foundations Series- 1.2 Order of OperationsAlgebra Foundations Series- 1.2 Order of Operations
Algebra Foundations Series- 1.2 Order of Operations
Dee Black
 
Week 1
Week 1Week 1
Week 1
EasyStudy3
 
Java Helpa4.pdfASSIGNMENT 4 A game and an email system.docx
Java Helpa4.pdfASSIGNMENT 4  A game and an email system.docxJava Helpa4.pdfASSIGNMENT 4  A game and an email system.docx
Java Helpa4.pdfASSIGNMENT 4 A game and an email system.docx
priestmanmable
 
Writing Tests Effectively
Writing Tests EffectivelyWriting Tests Effectively
Writing Tests Effectively
Paul Boocock
 
Chapter 7 Notes
Chapter 7 NotesChapter 7 Notes
Chapter 7 Notes
Bryan Corcoran
 

Similar to 2.4 Lecture.pptx (20)

8:00 GED Math Week 1 Tue
8:00 GED Math Week 1 Tue8:00 GED Math Week 1 Tue
8:00 GED Math Week 1 Tue
 
Lecture 1 computing and algorithms
Lecture 1  computing and algorithmsLecture 1  computing and algorithms
Lecture 1 computing and algorithms
 
Merge sort analysis and its real time applications
Merge sort analysis and its real time applicationsMerge sort analysis and its real time applications
Merge sort analysis and its real time applications
 
Ns1.4 A Factors & Primes
Ns1.4 A Factors & PrimesNs1.4 A Factors & Primes
Ns1.4 A Factors & Primes
 
Agent tic tac-toe - an interactive game for algorithmic and computational th...
Agent tic tac-toe  - an interactive game for algorithmic and computational th...Agent tic tac-toe  - an interactive game for algorithmic and computational th...
Agent tic tac-toe - an interactive game for algorithmic and computational th...
 
Algorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 5: Sorting Algorithms IIAlgorithms Lecture 5: Sorting Algorithms II
Algorithms Lecture 5: Sorting Algorithms II
 
16807097.ppt b tree are a good data structure
16807097.ppt b tree are a good data structure16807097.ppt b tree are a good data structure
16807097.ppt b tree are a good data structure
 
Function tables
Function tables Function tables
Function tables
 
Stanford splash spring 2016 basic programming
Stanford splash spring 2016 basic programmingStanford splash spring 2016 basic programming
Stanford splash spring 2016 basic programming
 
Denver MuleSoft Meetup Feb 24, 2021 - What's Batch Got to Do with It
Denver MuleSoft Meetup Feb 24, 2021 - What's Batch Got to Do with ItDenver MuleSoft Meetup Feb 24, 2021 - What's Batch Got to Do with It
Denver MuleSoft Meetup Feb 24, 2021 - What's Batch Got to Do with It
 
MySQL Query Optimisation 101
MySQL Query Optimisation 101MySQL Query Optimisation 101
MySQL Query Optimisation 101
 
Stage 6 fraction
Stage 6  fractionStage 6  fraction
Stage 6 fraction
 
Adding and subtracting
Adding and subtractingAdding and subtracting
Adding and subtracting
 
Chapter 2 Study Guides
Chapter 2  Study  GuidesChapter 2  Study  Guides
Chapter 2 Study Guides
 
Decision Science.pdf
Decision Science.pdfDecision Science.pdf
Decision Science.pdf
 
Algebra Foundations Series- 1.2 Order of Operations
Algebra Foundations Series- 1.2 Order of OperationsAlgebra Foundations Series- 1.2 Order of Operations
Algebra Foundations Series- 1.2 Order of Operations
 
Week 1
Week 1Week 1
Week 1
 
Java Helpa4.pdfASSIGNMENT 4 A game and an email system.docx
Java Helpa4.pdfASSIGNMENT 4  A game and an email system.docxJava Helpa4.pdfASSIGNMENT 4  A game and an email system.docx
Java Helpa4.pdfASSIGNMENT 4 A game and an email system.docx
 
Writing Tests Effectively
Writing Tests EffectivelyWriting Tests Effectively
Writing Tests Effectively
 
Chapter 7 Notes
Chapter 7 NotesChapter 7 Notes
Chapter 7 Notes
 

Recently uploaded

BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
S. Raj Kumar
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
National Information Standards Organization (NISO)
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
ssuser13ffe4
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
National Information Standards Organization (NISO)
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
سمير بسيوني
 

Recently uploaded (20)

BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
 

2.4 Lecture.pptx

  • 1. Do Now ● 2.4 Do Now ○ On your own ○ 5 minutes
  • 2. Agenda ● 2.4 Do Now ● Unit 2 Tracker ● Unit 2 Test/Study Guide ● 2.4 Lecture ○ SWBAT use various sorting algorithms to sort data ● 2.4 Activity ○ With a partner ● 2.4 Exit Ticket ○ 15 minutes timed ● Finish Early? ○ Revises from Unit 1/Unit 2 Tracker ○ Typing Homework ○ Unit 2 Extra Credit Opportunities
  • 4. Do Now Sort the following numbers from lowest to highest. Then answer, the two questions. 15 6 8 34 5 26 17 18 41 22 1. What was your strategy in sorting?
  • 5. DISCUSSION a) Think of a time when you were using a computer application or website that sorted values for you. b) Think about how you sorted the numbers in the Do Now. Would you use the same method to sort a set of 5000 numbers? i) What might you change? ii) What if you had a buddy to help you sort?
  • 6. ALGORITHMS ● An algorithm is a specific process or set of rules followed to get to a solution. Examples: ● Recipes ● handshake problem ● Directions ● fencepost problem ● -n-1
  • 7. SORTING ALGORITHMS ● Algorithms computers use to help it sort data ● Computer can only compare two items at a time ● We are going to learn TWO sorting algorithms. ○ SELECTION SORT ○ INSERTION SORT
  • 8. SELECTION SORT Sort a set of data by continuously “selecting” the next lowest value from the unsorted list and adding it to the sorted list (new set)
  • 9. SELECTI ON SORT Algorithm: 1. Take the first item. Compare it to the second item. The lower one is your current minimum. 2. Continue to compare current min with the rest of the values, always keeping the lower number. 3. Once minimum is found, move to new set. 4. Repeat. EACH TURN, IT IS FINDING THE LOWEST NUMBER AND THEN MOVING IT TO THE LEFT (SORTED LIST)​
  • 10. Selection Sort 3 1 6 2 5 4 ● Pass #1: 1 3 6 2 5 4 ● Pass #2: 1 2 3 6 5 4 ● Pass #3: 1 2 3 6 5 4 ● Pass #4: 1 2 3 4 5 6 ● Pass #5: 1 2 3 4 5 6 Number of Comparisons ● 5 ● 4 ● 3 ● 2 ● 1 Remember, you can only compare two items at a time. 5 + 4 + 3 + 2 + 1​ 15 COMPARISONS​ Algorithm: n(n-1)/2 https://visualgo.net/en/sorting
  • 11. INSERTION SORT Takes an unsorted set of values and sorts it in a new set by “inserting” one value at a time.
  • 12. INSERTION SORT Algorithm: 1. Take the first card in the unsorted set and put it in the back of the new sorted set. 2. If it’s lower than the one before it, put it in front. If it is higher, put it behind. 3. Repeat step 2 until the card is in its proper place. 4. Repeat steps 1-3 until all cards are sorted. Each new value is “inserted” into the correct spot in the order, one at a time.
  • 13. Insertion Sort 3 1 6 2 5 4 ● Pass #1: 1 3 6 2 5 4 ● Pass #2: 1 3 6 2 5 4 ● Pass #3: 1 2 3 6 5 4 ● Pass #4: 1 2 3 5 6 4 ● Pass #5: 1 2 3 4 5 6 Number of Comparisons ● 1 ● 1 ● 3 ● 2 ● 3 Remember, you can only compare two items at a time. 1 + 1 + 3 + 2 + 3 10 COMPARISONS​ https://visualgo.net/en/sorting
  • 14. EXTRA CREDIT Receive up to 20 extra credit points by: 1. Creating 2 videos, 1 for selection sort and 1 for insertion sort. 2. You are verbally explaining the difference as you show the difference, similar to the provided example but with a verbal explanation. 3. Be creative and use whatever supplies you have around your house to sort. Playing cards, paper, jersey numbers, etc.
  • 15. Agenda ● 2.4 Do Now ● Unit 2 Tracker ● Unit 2 Test/Study Guide ● 2.4 Lecture ○ SWBAT use various sorting algorithms to sort data ● 2.4 Activity ○ With a partner ● 2.4 Exit Ticket ○ 15 minutes timed ● Finish Early? ○ Revises from Unit 1/Unit 2 Tracker ○ Typing Homework ○ Unit 2 Extra Credit Opportunities