Jump to content

Google is a bit**!


Lucandrake

Recommended Posts

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Algorithms, my C++ teacher said to know that it is part of the basics of a computer, but he never explained what it was, time to use the power of google <_<

 

Well, I knida figured it was hard

 

Edit: I don't get it... http://en.wikipedia.org/wiki/Algorithm :rofl:

Edited by Drake
Link to comment
Share on other sites

Algorithms, my C++ teacher said to know that it is part of the basics of a computer, but he never explained what it was, time to use the power of google :P

 

Well, I knida figured it was hard

 

Edit: I don't get it... http://en.wikipedia.org/wiki/Algorithm :P

An algorithm is a finite set of well-defined instructions for accomplishing some task which, given an initial state, will result in a corresponding recognisable end-state.
Is that so hard to understand? Do you really want to be a programmer?

Use your head, for Ada Byron's sake.

Link to comment
Share on other sites

Algoriths, a structure or basis of the way a program works, kinda like how a blueprint is, is that what it means?

What that means is that an algorithm is:

-an initial state (can be variables, or pretty much anything else)

-instructions to be carried out in a precise order

-a final state.

With the same initial state, an algorithm will always give the same output (final state).

 

An example of algorithm could be cooking an egg:

initial state :

- 1 uncooked egg

- a pan

- water

- a gaz burner

 

instructions:

1 - fill the pan with water

2 - light the burner

3 - put the pan on the burner

4 - wait for the water to boil

5 - put the egg in the water

6 - wait 3 minutes

7 - turn off the burner

8 - take the egg out of the water

 

final state:

- 1 cooked egg

- a pan filled with water

- a gaz burner

 

Note that an algorithm is usually one of many solutions to solve a problem. In this example, you could make another algorithm by inverting steps 1 and 2. With computer programs it is very important to take that into account; given the same problem, an algorithm can solve it very quickly, while another could take centuries.

 

Another example more linked with programming would be an addition:

ADD ( integer A, positive integer B )

if B>0 ADD ( A,B )=ADD ( A+1, B-1 )

if B=0 ADD ( A,B )=A

 

This particular example (of course not the best way to make an addition) shows an important feature of today's programming languages: recursivity. In this example, ADD would be executed (B+1) times.

 

Also note that an algorithm is independant from the (programming) language it is written in.

 

So basically, a computer program is a set of algorithms.

I hope that will help, even if it's not really clear.

Feel free to ask any question, as long as you think twice about it (and it is written in correct english).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...