Algorithms itself

13 Karteikartenvon Sabs2023
Diese Karteikarten lernenKostenlos · Spaced Repetition · iPhone, Android, Mac & Web

Alle Karten

1
Linear search?
Starts at first item and checks each item one by one:
-Doesnt need to be ordered/sorted
-Can be efficient in small data sets but NOT in large data sets
2
Example of python inplementation
3
Binary search?
Find an item in SORTED data set via divide and conquer:
Need sorted list and is efficient for large data sets
Discards HALF of the data set per time
4
Actual steps?(lets say find y)
1)Front and rear pointers point to first and last item
2)Calculate midpoint by n//2, if its y output it BUT:
2.5A) IF mid point is larger then y, rear pointer becomes n-1 and discard right side.
2.5B) IF midpoint is smaller then y, front pointer becomes n+1 discard left side.
3)REPEAT UNTIL MIDPOINT EQUALS AND IS Y
5
Implementation of binary search in python:
6
Bubble sort
Compares an item to next and swaps if not in order,repeat with next pairs until reach end which is called a pass.
-Repeat this whole process again until all items are ordered
-"Bubbles" the largest/smallest unsorted item to the top per pass
7
Implimentation of bubble sort in python:
8
Insertion sort?
Inserts an item into correct spot at one time each
Starts at the 2nd item(then 3 etc) and compares items to the left and sees if they should swap or not
9
Implimentation of insertion sort in python:
10
Merge sort ?
Divide and conquer: Splits items all into individual lists then compares,sorts and combines adjacent lists. Repeat for the other lists.
Then compares,sorts,combines adjacent 2 item lists. Repeat for others
Do this until you have one sorted list
11
Implimentation of merge sort
12
Quick sort?
1)Uses a pivot(1st item) in which items smaller are placed to the left side sublist and items larger on right sublist. Pivot is then sorted.
2)Repeat same steps for the left and right sublists.
3)Do this until all items become pivots in which then it becomes sorted
13
Implimentation of quick sort:
Alle 13 Karten kostenlos lernen

Mehr Karteikarten: Informatik

Concepts of Programming Languages86 KartenInformatik · EnglischLuluWindows Administration: Active Directory and Accounts70 KartenInformatik · EnglischJaySection 1.1-1.3: Windows Commands/OS58 KartenInformatik · Englischpzxlimemory 48 KartenInformatik · EnglischerikaCS 325 T7 L4,5,641 KartenInformatik · EnglischClementSecurity Plus Ports35 KartenInformatik · EnglischJohnComputer Networks Part 230 KartenInformatik · EnglischSgPt. 123 KartenInformatik · EnglischCornyNa+- és vízháztartás zavarai18 KartenInformatik · UngarischRitikeMicrosoft Azure Administrator (AZ-104)150 KartenInformatik · EnglischIsmaealITEC 110: Information Technology and Cybersecurity147 KartenInformatik · EnglischmackNetwork Security and Cryptography Quiz97 KartenInformatik · EnglischDiandrei

Alle Decks: Informatik

Lerne diese Decks in der App

Kostenlos auf iPhone, Android, Mac und im Web. Füge jedes Deck mit einem Tipp zu deinem Konto hinzu.

Laden im App StoreJetzt bei Google Play
Alle 13 Karten kostenlos lernen