Algorithms

0.0(0)
studied byStudied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/7

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 5:11 PM on 9/30/24
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

8 Terms

1
New cards

Binary Search

Starting at the middle item of the list and repeatedly dividing the list in half

2
New cards

Linear Search

Going through all the items in a list until the target item is found

3
New cards

Binary search pseudocode

found = false

first = 0

last = items.length - 1

while first <= last and Found == false

midpoint = (first + last) DIV 2

if items [midpoint] == item_to_find then

found = true

else

if items [midpoint] = item_to_find then

first = midpoint + 1

else

last = midpoint - 1

end if

end if

end while

4
New cards

Bubble sort

Continuously goes through a list until the list has been sorted.

  • It looks at the current value and checks it with the adjacent value. If the adjacent value is higher, the numbers are swapped

  • Each swap is called a pass

5
New cards

Bubble sort pseudocode

numbers = [9, 5, 4, 15, 3, 8, 11]

numItems = len(numbers

while i < (numItems - 1) and (flag=true)

flag = false

for j = 0 to (numItems - i - 2)

if number [j] > numbers [j+1]

temp = numbers [j]

numbers [j] = numbers [j+1]

numbers [j+1] = temp

flag = true

end if

print (numbers)

next i

6
New cards

Linear Search pseudocode

choice = input

found = false

counter = 0

while counter < len (names) and Found = false

if array [counter] = choice:

Found = true

position = counter

end if

counter = counter + 1

end while

7
New cards

Insertion Sort

Sorting into two columns, sorted & unsorted

  • The items from the unsorted column are moved to the sorted column in every pass

8
New cards

Insertion Sort pseudocode

First = 0

last = MaxItems

for count2 = First + 1 to last

currentItem = list(count2)

count = count2 - 1

do while list(count) > currentItem and count2 > 0

list (count+1) = list (count)

count = count - 1

loop

list(count + 1 = currentItem)

Next