Sunday, September 26, 2010

Newly Sorted

begin
count list
repeat n times
is an1 < An to the right
move to the next
else
print no
end repeat print yes
end

This solution will work for any number of ns because it count's the list first before setting the repeat. It will work for any set of numbers because it just goes from left to right. The time it will take is set by the list only an infinite amount of numbers in the list will make it not finite. Any Permutation works


AZ Marketing  

Sunday, September 19, 2010

Select K

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.

Friday, September 10, 2010

Compute the Max

 define o_max and assign i_intaryTb[0];
  looping from 0 to i_intaryTb.length -1 ,index += i_one_stepLength
      if ( index >= i_intaryTb.length ) then
          break the looping;
      if ( i_intaryTb[index] > o_max ) then
          o_max = i_intaryTb[index];
      end if
  end looping
  return o_max;


So, I got a lot of help with this from my friend Google. I'm not necessarily anywhere near good at programming, but it seems that I can understand this enough to argue that it will terminate and produce the correct results. 

i is assigned the length once it reaches i it stops. 

it will keep going until the max is found, or i is reached.


Phoenix AZ Marketing


Tuesday, September 7, 2010

Sorting - Computer Science

Two rules for sorting

  • The output is in a non decreasing order. 
  • The output is a reordering of the input. 
Pseudo-code
Begin
Repeat five times
Prompt user for number 
End repeat

Take first number
 if
  number is smaller than number to the right leave it.
 else
  switch with  the first number to that right that is smaller.
 End if
End

So I didn't really know what you expected but I worded the process out as best as I could.