The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> What is an algorithm?
pandy
post Jul 22 2018, 02:07 AM
Post #1


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Well, I know what it is, sort of. But I've never understood the difference between a (computer) algorithm and a short procedural program or script. Thought it's about time I find out. cool.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
 
Reply to this topicStart new topic
Replies
Darin McGrew
post Jul 26 2018, 09:06 PM
Post #2


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



QUOTE(pandy @ Jul 22 2018, 12:07 AM) *
Well, I know what it is, sort of. But I've never understood the difference between a (computer) algorithm and a short procedural program or script. Thought it's about time I find out. cool.gif
The way I learned it, a program or a script or a subroutine or whatever you want to call it is an actual implementation of something. In contrast, an algorithm is the high-level concept that you're trying to implement.

For example, if you're trying to sort a list of items, there are a number of different ways to sort them.

One basic algorithm is a bubble sort. The concept is to compare the first item with the second item, and swap them if they're out of order. Then repeat with the second and third, the third and fourth, the fourth and fifth, and so on, until you've processed the entire list. At this point, the last item is correct, but the others may or may not be correct, so you repeat the whole process for the entire list except the last item. And then you repeat the whole process for the entire list except for the last two items, and except for the last three items, and so on.

The concept of how to sort a list of items this way is the algorithm. But the concept doesn't let you sort anything, any more than the concept of an automobile lets you drive down the street.

An actual program/script/function/procedure/subroutine/whatever may implement this algorithm. To sort something, you can run the program/script/function/procedure/subroutine/whatever. In the same way, a particular minivan or coupe or sedan may implement the concept of an automobile, and you can use that implementation to drive down the street.

Anyway, does this help?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jul 27 2018, 06:14 AM
Post #3


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Oh! So an algorithm isn't actual code? More a description of what should be done? Or maybe rather a description of the method that should be used.

But then how is this "concept" described, surely not in plain English?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Jul 28 2018, 12:43 AM
Post #4


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



QUOTE(pandy @ Jul 27 2018, 04:14 AM) *
Oh! So an algorithm isn't actual code? More a description of what should be done? Or maybe rather a description of the method that should be used.
It's a description of the method. For example, there are many, many algorithms for sorting a list. The "what should be done" is the same for all of them: the list should be sorted when you're done. But it's the "method" or the "how" that differs, and that makes one algorithm better than another in a given situation.

QUOTE(pandy @ Jul 27 2018, 04:14 AM) *
But then how is this "concept" described, surely not in plain English?
There isn't really a special "algorithm language". An algorithm is supposed to be understood by humans, so it's described in human languages. The implementations/programs/whatever are written in computer languages, because they need to be understood by computers.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jul 28 2018, 08:29 AM
Post #5


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Wow, that simple... Thanks Darin, I had no idea. smile.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 02:04 AM