Algorithms

studied byStudied by 0 people
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 7

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

8 Terms

1

Binary Search

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

New cards
2

Linear Search

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

New cards
3

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

New cards
4

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

New cards
5

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

New cards
6

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

New cards
7

Insertion Sort

Sorting into two columns, sorted & unsorted

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

New cards
8

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

New cards

Explore top notes

note Note
studied byStudied by 143 people
26 days ago
5.0(1)
note Note
studied byStudied by 3 people
813 days ago
5.0(1)
note Note
studied byStudied by 34 people
1000 days ago
5.0(1)
note Note
studied byStudied by 10 people
769 days ago
5.0(1)
note Note
studied byStudied by 98 people
506 days ago
4.5(2)
note Note
studied byStudied by 10 people
807 days ago
5.0(1)
note Note
studied byStudied by 14 people
124 days ago
5.0(1)
note Note
studied byStudied by 1837 people
269 days ago
5.0(5)

Explore top flashcards

flashcards Flashcard (222)
studied byStudied by 16 people
94 days ago
5.0(1)
flashcards Flashcard (35)
studied byStudied by 36 people
799 days ago
5.0(2)
flashcards Flashcard (22)
studied byStudied by 5 people
342 days ago
5.0(1)
flashcards Flashcard (24)
studied byStudied by 6 people
72 days ago
5.0(2)
flashcards Flashcard (23)
studied byStudied by 25 people
697 days ago
5.0(3)
flashcards Flashcard (56)
studied byStudied by 12 people
484 days ago
5.0(1)
flashcards Flashcard (27)
studied byStudied by 5 people
284 days ago
5.0(1)
flashcards Flashcard (80)
studied byStudied by 98 people
735 days ago
5.0(1)
robot