Pseudo code Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

How do you make a program loop a set number of times?

A
for i = 0 to 4 
#contents 
next i 
or 
for i = 0 to len(list)
#contents
next i
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What do you do at the top of a pseudo code program?

A
Define all the variable data types 
e.g. 
maxNum is integer 
Mean is real 
name is string 
check is boolean
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you define an if statement?

A

if #code such as list(i) > MaxNum:
#task
endif

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

How do you define a while statement?

A

while

end while

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

What is better merge sort or bubble sort?

A

Merge sort as it is more efficient.

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

What is the pseudo code for bubble sorts?

A
Declare BubbleSort(bubbleList):
    exchanges = True
    passnum = len(bubbleList)-1
    while passnum > 0 and exchanges = True
        exchanges = False
        for i = 1 to n
            if bubbleList[i]>bubbleList[i+1]:
                exchanges = True
                temp = bubbleList[i]
                bubbleList[i] = bubbleList[i+1]
                bubbleList[i+1] = temp
            end if
         next i
         passnum = passnum-1
    end while
end Subroutine

bubbleList=[20,30,40,90,50,60,70,80,100,110]
BubbleSort(bubbleList)
print(bubbleList)

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