Monday, September 27, 2010

IsSorted

BEGIN
count list
Loop an-1 times
if a1<a2
move to next value
else
display no
END

This algorithm will return the correct answer because it will go through the array of numbers and check each to see if the next one is larger than the previous. It will end in infinite time because the loop is set to occur (an - 1) times.

Monday, September 20, 2010

Fidn the value

BEGIN
    Prompt User to enter a certain amount of numbers
    Set d as amount of numbers in the list
    Set k as test variable
    Assign a value v to k
    Assign k to drop down the list d amount of times
    For each variable check if k encounters a d that is the same value
    loop d amount of times.
    If k = v then return yes
    If k != v then return no
END

This will work because when k goes down the list it either will or will not encounter a v that is the same value.

This will end because when program reaches d amount of times the program will end.

  

Sunday, September 12, 2010

Computing to the Max

I am not too familiar with programming yet, but here is my attempt in PSUEDO code:

BEGIN
   Prompt user to enter 4 numbers
   Use the variable i to be your current number
   Use equation n ( i + 1 )
   Make code to go through each number and compare i to the next number n
   If i<n 
      Go to next number and compare
   If i>n 
      Replace value of i with n and compare next number
   Loop until i is not replaced with n
END

This is probably not the greatest way to go about it but it made sense to me. Once I am more familiar with coding I can come back and make any necessary corrections.

Wednesday, September 8, 2010

Sorting algorithm

I find it interesting that the algorithm can not be decreasing and how they tie this in with time. Time can never go backwards, or at least we don't know how to make that happen.

Stability is also very important.