The Naked Scientists

The Naked Scientists Forum

Author Topic: how to write a algorithm  (Read 17985 times)

Offline Dege

  • Full Member
  • ***
  • Posts: 67
    • View Profile
how to write a algorithm
« on: 12/01/2009 03:55:34 »
I have been haveing some trouble learning how to write algorithms. can anyone help me?


 

Offline Chemistry4me

  • Neilep Level Member
  • ******
  • Posts: 7709
    • View Profile
how to write a algorithm
« Reply #1 on: 12/01/2009 03:57:21 »
Are you talking maths or computers?
 

Offline Dege

  • Full Member
  • ***
  • Posts: 67
    • View Profile
how to write a algorithm
« Reply #2 on: 12/01/2009 23:24:54 »
computers
 

Offline DoctorBeaver

  • Naked Science Forum GOD!
  • *******
  • Posts: 12656
  • Thanked: 3 times
  • A stitch in time would have confused Einstein.
    • View Profile
how to write a algorithm
« Reply #3 on: 12/01/2009 23:37:40 »
You have to break it down to single, linear steps. What do you want your algorithm to do?
 

Offline Dege

  • Full Member
  • ***
  • Posts: 67
    • View Profile
how to write a algorithm
« Reply #4 on: 14/01/2009 01:31:46 »
just to predict the next outcome of a numer sequence just somethiing simple like that can you tell me how to do that
 

Offline DoctorBeaver

  • Naked Science Forum GOD!
  • *******
  • Posts: 12656
  • Thanked: 3 times
  • A stitch in time would have confused Einstein.
    • View Profile
how to write a algorithm
« Reply #5 on: 14/01/2009 02:12:04 »
You have got to be joking! Do you realise how complicated that is? In order to predict the next number you first have to work out what the connection is between the numbers you have to start with.

Can't you start with something simple like an atmospheric model!?  :P
 

Offline RD

  • Neilep Level Member
  • ******
  • Posts: 8134
  • Thanked: 53 times
    • View Profile
how to write a algorithm
« Reply #6 on: 14/01/2009 12:18:34 »
just to predict the next outcome of a number sequence just something simple like that can you tell me how to do that

If the numbers are points on a smooth line it should be possible to extrapolate to the next number.
 

Offline dentstudent

  • Neilep Level Member
  • ******
  • Posts: 3146
  • FOGger to the unsuspecting
    • View Profile
how to write a algorithm
« Reply #7 on: 14/01/2009 12:30:37 »
just to predict the next outcome of a number sequence just something simple like that can you tell me how to do that

If the numbers are points on a smooth line it should be possible to extrapolate to the next number.


Certainly, if you are dealing with standard linear relationships. But that assumes that the number sequence consists of numbers that are "related" and dependent. If they are entirely independent, you have no chance. But let's assume that we're dealing with a dependent variable. Curve fitting is rather difficult unless, as Eth says, you already know what the relationship is.

It would be easier to comment if we knew what numbers we were dealing with, and what sort of prediction is required.
 

Offline dentstudent

  • Neilep Level Member
  • ******
  • Posts: 3146
  • FOGger to the unsuspecting
    • View Profile
how to write a algorithm
« Reply #8 on: 14/01/2009 12:32:13 »
just to predict the next outcome of a numer sequence just somethiing simple like that can you tell me how to do that

I can however show you where the capital letters are, as well as commas, question marks and full-stops!
(FOG)
 

Offline Dege

  • Full Member
  • ***
  • Posts: 67
    • View Profile
how to write a algorithm
« Reply #9 on: 14/01/2009 20:53:55 »
haha ok sorry guys can yall start me off with just the basics of algorithms and lets work from there
 

Offline RD

  • Neilep Level Member
  • ******
  • Posts: 8134
  • Thanked: 53 times
    • View Profile
how to write a algorithm
« Reply #10 on: 14/01/2009 23:54:13 »
Draw a flow diagram.
 
If you told us the intended function we may be able to tell you if it is possible and how complex the programme would have to be,
 e.g. if you are looking to create a programme which can predict lottery numbers you're wasting your time.

http://en.wikipedia.org/wiki/Software_development_process
« Last Edit: 14/01/2009 23:56:13 by RD »
 

Offline Dege

  • Full Member
  • ***
  • Posts: 67
    • View Profile
how to write a algorithm
« Reply #11 on: 15/01/2009 02:56:11 »
no its  not for anything like that ok just forget the predictions and just start me off with the simplest thing a algorithm can do, if you dont mind please.
 

Offline RD

  • Neilep Level Member
  • ******
  • Posts: 8134
  • Thanked: 53 times
    • View Profile
how to write a algorithm
« Reply #12 on: 15/01/2009 05:05:59 »
Here is a simple flow diagram ...

 

Offline Chemistry4me

  • Neilep Level Member
  • ******
  • Posts: 7709
    • View Profile
how to write a algorithm
« Reply #13 on: 15/01/2009 05:07:35 »
Haha, very good RD! Top notch!
 

Offline DoctorBeaver

  • Naked Science Forum GOD!
  • *******
  • Posts: 12656
  • Thanked: 3 times
  • A stitch in time would have confused Einstein.
    • View Profile
how to write a algorithm
« Reply #14 on: 15/01/2009 11:37:59 »
RD - don't start him on iterative loops!  :D
 

Offline Dege

  • Full Member
  • ***
  • Posts: 67
    • View Profile
how to write a algorithm
« Reply #15 on: 15/01/2009 22:33:50 »
OK thanks allot that helps me out a great deal. OK now one last thing is there any article or download that you know of that can take me through the basics and help me out.thanks again
 

Offline RD

  • Neilep Level Member
  • ******
  • Posts: 8134
  • Thanked: 53 times
    • View Profile
how to write a algorithm
« Reply #16 on: 16/01/2009 04:04:00 »
Here is an article...

Quote
How to describe software design using diagrams and pseudo-code
http://www.scienceprog.com/how-to-describe-embedded-software-design-using-diagrams-and-pseudo-code/

Pseudo-code is a list of stepwise instructions in plain English, like DoctorBeaver mentioned above, it resembles computer code (a.k.a. computer programme).
 

Offline Chemistry4me

  • Neilep Level Member
  • ******
  • Posts: 7709
    • View Profile
how to write a algorithm
« Reply #17 on: 16/01/2009 05:14:42 »
Don't you ever go to sleep RD?
 

Offline chrisn

  • First timers
  • *
  • Posts: 4
    • View Profile
how to write a algorithm
« Reply #18 on: 17/01/2009 09:08:45 »
Fibonacci numbers are generated by an algorithm which is easily converted into a computer program.

The first fibonacci numbers are:

0    1    1    2    3    5    8    13    21    34    55    

The ninth number is 21, which is the sum of the two previous numbers, 8 + 13.
Likewise, 55 = 34 + 21.
By definition, the first two are 0, 1.

If you want to generate the 100'th fibonacci number, it's easy to say that it is the sum of the 99'th and the 98'th number, but what their value is, being tedious fast.

If you want to generate these numbers in a programming language (there is example fibonacci code for basically every language), you define a function (my example is in python, a programming language):

def fibonacci(n): # Returns the n'th fibonacci number
   if n < 2:
     return n # The zero'th fibonacci number is 0, the first one is 1, by definition.
   else:
     return fibonacci(n - 1) + fibonacci(n - 2)

This is quite similar to the explanation in English. If you can describe an algorithm in English (or in math), converting it into a computer-language is quite simple, although you'll have to learn the language first. Describing in English (or in math), what the algorithm does, with all the corner-cases, that's the hard part.
 

Offline Dege

  • Full Member
  • ***
  • Posts: 67
    • View Profile
how to write a algorithm
« Reply #19 on: 23/01/2009 00:40:10 »
OK i would like to thank you all. i am finally starting to get i :)[img] t. thanks again and i am sorry for the wast of time>
 

The Naked Scientists Forum

how to write a algorithm
« Reply #19 on: 23/01/2009 00:40:10 »

 

SMF 2.0.10 | SMF © 2015, Simple Machines
SMFAds for Free Forums