Jump to content
Science Forums

How Do You Write A Algorithm?


 Share

Recommended Posts

So, I know algorithms are very complicated and such, but if you would take the time, can you please give me a step by step way to make an algorithm for this problem. I'm not sure which version you need, an algebraic one or one with numbers so I'll put both.

 

(a(3+a)(bc - jk)za

(1(1+3)(2*3) - (10*11)) (26*1)

 

 

<p>

 

=) Thanks for anyone who takes the time!

 

~Clover

Link to comment
Share on other sites

  • 4 months later...

So, I know algorithms are very complicated and such, but if you would take the time, can you please give me a step by step way to make an algorithm for this problem. I'm not sure which version you need, an algebraic one or one with numbers so I'll put both.

(a(3+a)(bc - jk)za

(1(1+3)(2*3) - (10*11)) (26*1)

Clover,

 

An algorithm for above example as philip1882 showed you is trivial. So an

algorithm may need a better example.

 

Say you have twelve suits on a rack and you want to know how many you

have that are double breasted with matching pants.

 

Showing you this algorithm [in pseudocode] is thus

 

get coat rack

for each hanger in rack

- if contents of hanger is suit then

-- if contents of hanger has pants

--- if contents of hanger that is suit of type "double breasted" then

--- if contents of hanger that is suit "match" contents of hanger that is pants then

---- incr count by 1

 

print count

 

Now this is Not code of any language. One could though by defining a

few things write an actual program in any language.

 

Only increment our counter if what is found on each hanger is a suit,

that is double breasted and that has pants that match.

 

Another example is a fractal. Fractals such as the Mandlebrot set

are iteration functions that are mapped on the whole complex pane.

 

In case you do not know of complex arithmetic a brief intro

A complex number is Z = ax + iby where a, b are some constants, x, y

are your coordinates in a plane and i = sqrt(-1).

 

So an iteration function is for example Z = Z^2 + c where c is some

complex constant say (a, b ) or c = a + ib.

 

You then plot this for the whole complex plane. You get a Mandlebrot set.

 

I will leave this as an exercise for you to work out an algorithm in

pseudocode.

 

maddog

Edited by maddog
Link to comment
Share on other sites

  • 2 months later...

An algorhythm is a generic "method" one will use to design the code for a task. It would be advisable, though, to knoiw your chosen compiler first, prior to even pseudocode, because C/C++ is very different than say Pascal or Basic.

 

http://www.codingmonkeys.com/index.php?action=forum

 

 

I just put this link for another query, but you can find a lot of Basic compilers here. I think I placed a link there once to Delphi 7 PE, but Borland no longer supports it largely because Borlsnd is no more.

 

I'm saying this because D7 has so many math routines that any Delphi version makes life easy for math guys.

 

EBasic or IWBasic have floor and ceil routines that allow for integration routines, summation. So does Delphi. Delphi has string variables and converters and allow extremely long floats. An algebraist's dream

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...