Algorithms itself

13 flashcardspar Sabs2023
Réviser ces flashcardsGratuit · répétition espacée · iPhone, Android, Mac et web

Toutes les cartes

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:
Réviser les 13 cartes gratuitement

Plus de flashcards : Informatique

Concepts of Programming Languages86 cartesInformatique · AnglaisLuluWindows Administration: Active Directory and Accounts70 cartesInformatique · AnglaisJaySection 1.1-1.3: Windows Commands/OS58 cartesInformatique · Anglaispzxlimemory 48 cartesInformatique · AnglaiserikaCS 325 T7 L4,5,641 cartesInformatique · AnglaisClementSecurity Plus Ports35 cartesInformatique · AnglaisJohnComputer Networks Part 230 cartesInformatique · AnglaisSgPt. 123 cartesInformatique · AnglaisCornyNa+- és vízháztartás zavarai18 cartesInformatique · HongroisRitikeMicrosoft Azure Administrator (AZ-104)150 cartesInformatique · AnglaisIsmaealITEC 110: Information Technology and Cybersecurity147 cartesInformatique · AnglaismackNetwork Security and Cryptography Quiz97 cartesInformatique · AnglaisDiandrei

Tous les decks : Informatique

Révise ces decks dans l’app

Gratuit sur iPhone, Android, Mac et le web. Ajoute n’importe quel deck à ton compte en un tap.

Télécharger dans l’App StoreDisponible sur Google Play
Réviser les 13 cartes gratuitement