begin
initialize count
total the list
n = list total
repeat n times
read 1st character
if that character = K
add to count
print yes
else
print no
move to the next character
print ( "this list had " + count + " k's" )
end
This Algorithm will total a list and repeat a search n times. after n times it will print the count. It will stop because it wont repeat longer than the list is big. We'll this is a totally fit algorithm, because it has a finite amount of repeats. It also leaves the option for no ks and multiple ks.
No comments:
Post a Comment