searches, flow charts, abstraction + decomposition, loops

0.0(0)
studied byStudied by 4 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/24

flashcard set

Earn XP

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

25 Terms

1
New cards

Ask user for an integer input

int(input()

2
New cards

When would you use a while loop?

When it is not known how many times iteration will occur.

3
New cards

while loop which will add 1 onto 0 until it reaches 8

number = 0 
while number != 8:
 number = number + 1 
 print ("The number is",number)

4
New cards

while loop

condition controlled

5
New cards

for loop

count controlled

6
New cards

count controlled meaning

you specify the number of times that you wish the iteration to be repeated

7
New cards

for loop, repeat 10 times until it reaches 5

for i in range(10):
 if i == 5:
  break
print(i)

8
New cards

MOD definition (%)

calculates the remainder of a division

9
New cards

iteration

The repetition of a block of statements within a computer program.

10
New cards

selection

the process of making a decision which result will decide which path it takes next

11
New cards

sequence

a set of instructions that follow on one from another

12
New cards

nesting

one programming construct within another

13
New cards

start/end

knowt flashcard image
14
New cards

process

<p></p>
15
New cards

input/output

knowt flashcard image
16
New cards

if

knowt flashcard image
17
New cards

flow

knowt flashcard image
18
New cards

sub program

knowt flashcard image
19
New cards

Abstraction

Removing the unnecessary parts of a problem so that you only focus on the important parts

20
New cards

Decomposition

Breaking a complex problem down into smaller problems so that it is more manageable/easier to solve

21
New cards

Binary Search: Process

1) Find the middle item in the ordered list.

2) If this is the item you’re looking for, stop the search.

3) If not, compare the item your looking for to the middle item. If it comes before the middle item, get rid of the second half of the list. If it comes after the middle item, get rid of the first half of the list.

4) Repeat steps 1-3 until the item is found.

22
New cards

Linear Search

1) Look at the first item in the unordered list.

2) If this is the item you’re looking for, stop the search.

3) If not, look at the next item in the list

4) Repeat steps 2/3 until you find the item.

23
New cards

Is a linear search as efficient as a binary search?

No

24
New cards

Should you use a linear search for smaller lists?

Yes

25
New cards

What is a benefit to a linear search?

It is simple and can be done on an unordered list.