



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




"There are" tally "big apples"
Set applecount to zero Set orangecount to zero
Get a fruit from the bag
Is it an apple?
Add one to apple count
Add one to orange count
more fruit?
applecount < orangecount?
"Buy more apples"
"No more apples needed"
Stop
yes no
yes
yes
yes
yes
no
no
no
no
Stop
Start
Set tally to zero
Get an apple
Is apple larger than 3in. in diameter?
Add one to tally
more apples?
yes
yes
no
no
yes
no
yes
no
Start
Is the right apple bigger than the left?
Get an apple in left hand.
Get an apple in right hand.
Discard right apple
Discard left apple
Move right hand apple to left hand
Are there more apples?
Give friend apple in left hand
Stop
Start
Get an item from the bag
Is it an apple?
Are there more items in the bag?
Stop
Place in orange bag
Place in apple bag
yes
yes
Start
Get n, err
"sqrt is" xnew
Xold = 0
Xold =Xold+
Xold =Xold - 1
Xnew = (XoldXold+n)/(2Xold)
Xold = Xnew
Xold*Xold <= n?
yes
no
abs((Xnew- Xold)/Xnew) < err?
yes
yes
yes
no
Start
Stop
Stop
Get the table
x=
y=
numpeaks=
y=y+
numpeaks = numpeaks+
x=x+
Is x-1>0 & measurement at x,y
= 100+measurement at x-1,y?
Is x+1 <= #rows & measurement at x,y >= 100+measurement at x+1,y?
Is y-1>0 & measurement at x,y
= 100+measurement at x,y-1?
Is y+1<=#columns & measurement at x,y >= 100+measurement at x,y+1?
Is y < #columns?
Is x< #rows?
"Number of peaks is" numpeaks
no
no
no
no
yes
yes
yes
no
no
Page 5 of 7
tsum=sum of row 1 elements
dsum = sum of main diagonal elements
rsum = sum of row k elements
csum = sum of column k elements
dsum = sum of 2nd diagonal elements
9.(a)
Note:
means "predefined process" see next page for definition of the "calculate a sum" process.
α
Start
Stop
no
yes
yes
dsum = tsum?
dsum = tsum?
k=
k=k+
rsum = tsum?
α
csum = tsum?
are there more rows & cols to test?
"This is not a magic square"
no
no
no
"This square is magic"
no
yes
yes
yes
Get square to test
get a square of numbers to test
Is it a magic square?
"Not magic at all" (^) stop
k=
n=size of square
for each entry in the square
count=
entry =k?
no
yes
yes
next entry
yes
no
done
no
no
count=count+
count >= 2?
count =1?
k=k+
k>n 2
yes
no
yes
This is a perfect magic square
Square is magic but not perfect
stop
stop