standard algarithms Flashcards

1
Q

find min pseudocode (parallel arrays)

A

SET Lowest = array[0]

FOR counter FROM 1 to length(array)

IF array[counter] < lowest

SET Lowest = array [counter]

END IF

END FOR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

find min python (parallel arrays)

A

def FindMin(times):
minimum = times[0]
for counter in range(1,len(times)):
if times[counter] < minimum:
minimum = times[counter]
return minimum

fastestTime = FindMin(times)
print (“Fastest time is”, fastestTime)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

linear search pseudocode (parallel arrays)

A

choice = input from USER

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

linear search python (parallel arrays)

A

def LinearSearch(items,goal):
found = False
choice = input(“Enter search item: “)
while counter < len(items) and found == False:
if items[counter] == choice:
found = True
position = counter
counter += 1

if found == False:
    print("No item found in list”)
else:
    print(“Item details: ",items[position])
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

counting occurrences pseudocode (parallel arrays)

A

GET SearchItem FROM KEYBOARD

Total = 0

FOR counter = 0 TO Length(array)

IF array(counter) = SearchItem

Total = total +1

END IF

END FOR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

counting occurrences python (parallel arrays)

A

def CountOccurences(passes):
occurences = 0
for counter in range(len(passes)):
if passes[counter] == “Pass”:
occurences += 1
return occurences

amount = CountOccurences(passes)
print(“There were” + str(amount) + “ of passes”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

find min pseudocode (records)

A

SET lowest = pupils[0].mark

FOR counter FROM 1 to length(pupils)

IF pupils[counter].mark < lowest

SET Lowest = pupils [counter].mark

END IF

END FOR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

find min/max python (records)

A

def FindMin(pupils):
minimum = pupils[0].mark
for x in range(1,len(pupils)):
if pupils[x].mark < minimum:
minimum = pupils[x].mark
return minimum

lowmark = LinearSearch(pupils)
print(“Lowest mark is “ + str(lowmark))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

linear search pseudocode (records)

A

choice = input from USER

found = FALSE

counter = 0

WHILE counter <len(pupils) AND found = FALSE

   IF array [counter].name = choice:

      found = TRUE

      position = counter

END IF

counter = counter +1

END WHILE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

linear search python (records)

A

found = False
choice = input(“Enter search Name: “)
while counter < len(pupils) and found == False:
if pupils[counter].name == choice:
found = True
position = counter
counter += 1

if found == False:
print(“No pupil found in list”)
else:
print(“Pupil details: “,pupils[position].name)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

record structure python

A

from dataclasses import dataclass

@dataclass
class pupil:
name : str = “”
mark : float = 0.0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

create a data structure called pupils for 40 records called pupil

A

pupils = pupil * 40

How well did you know this?
1
Not at all
2
3
4
5
Perfectly