The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> What is an algorithm?
pandy
post Jul 22 2018, 02:07 AM
Post #1


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,064
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
CharlesEF
post Jul 22 2018, 11:18 PM
Post #2


Programming Fanatic
********

Group: Members
Posts: 1,549
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



I will admit that I don't know the 'official' meaning but I have always understood that a algorithm is a mathematical formula to perform a specific task. I wouldn't consider a computer program or script an algorithm.

Think about the day of the week. You could write a program or script to determine the day of the week. However, that program/script may be quite large. If you used an algorithm then you would only need a few lines of code. The algorithm would be the function call in that program/script.

I hope I haven't confused you more.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jul 23 2018, 12:41 PM
Post #3


.
********

Group: WDG Moderators
Posts: 7,947
Joined: 10-August 06
Member No.: 7



laugh.gif Clear as mud:

https://en.wikipedia.org/wiki/Algorithm#Computer_algorithms
https://en.wikipedia.org/wiki/Script_(computer_programming)
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jul 23 2018, 12:48 PM
Post #4


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,064
Joined: 9-August 06
Member No.: 6



QUOTE(CharlesEF @ Jul 23 2018, 06:18 AM) *

I will admit that I don't know the 'official' meaning but I have always understood that a algorithm is a mathematical formula to perform a specific task. I wouldn't consider a computer program or script an algorithm.

Think about the day of the week. You could write a program or script to determine the day of the week. However, that program/script may be quite large. If you used an algorithm then you would only need a few lines of code. The algorithm would be the function call in that program/script.

I hope I haven't confused you more.


Well, I was already confused so... tongue.gif

So you mean an algorithm is part of a program rather than a standalone program? But in that case, isn't it just a subroutine?

BTW I know there were math algorithms before there were computers, but I have no ambitions to understand those. tongue.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jul 23 2018, 12:49 PM
Post #5


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,064
Joined: 9-August 06
Member No.: 6



QUOTE(Christian J @ Jul 23 2018, 07:41 PM) *



Yeah, I've read that. And look at the example they give. That's a program/script to me. wacko.gif

https://en.wikipedia.org/wiki/Algorithm#Algorithm_example
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Jul 23 2018, 02:57 PM
Post #6


Programming Fanatic
********

Group: Members
Posts: 1,549
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(Christian J @ Jul 23 2018, 12:41 PM) *

I agree, those links make me confused. sad.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Jul 23 2018, 03:09 PM
Post #7


Programming Fanatic
********

Group: Members
Posts: 1,549
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(pandy @ Jul 23 2018, 12:48 PM) *

So you mean an algorithm is part of a program rather than a standalone program? But in that case, isn't it just a subroutine?

Yes, it would be considered a subroutine. And I see how easy it is to confuse an algorithm with a computer program. My understanding of an algorithm comes from a math background. If I were to translate that into computer talk then I would say a computer program could be converted into an algorithm if you can use mathematical formulas to reduce the code to only a few lines. That would be an algorithm.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jul 23 2018, 03:16 PM
Post #8


.
********

Group: WDG Moderators
Posts: 7,947
Joined: 10-August 06
Member No.: 7



QUOTE(pandy @ Jul 22 2018, 09:07 AM) *

I've never understood the difference between a (computer) algorithm and a short procedural program or script.

But is there a distinct difference, maybe the terms belong to different categories, or overlap?

According to Wikipedia:
The term "scripting language" is also used loosely to refer to dynamic high-level general-purpose languages [...] with the term "script" often used for small programs (up to a few thousand lines of code) in such languages

--so a script is a small program in a high-level general-purpose language.

QUOTE
look at the example they give. That's a program/script to me. wacko.gif

Seems an algo can be written as a program/script (but also in English prose, like in the example), and a program can be a script? In other words, an algo can be a script? unsure.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jul 23 2018, 03:49 PM
Post #9


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,064
Joined: 9-August 06
Member No.: 6



QUOTE(Christian J @ Jul 23 2018, 10:16 PM) *

But is there a distinct difference, maybe the terms belong to different categories, or overlap?

If not, why don't we ever hear someone talk about Google's scripts?

QUOTE
According to Wikipedia:
The term "scripting language" is also used loosely to refer to dynamic high-level general-purpose languages [...] with the term "script" often used for small programs (up to a few thousand lines of code) in such languages

--so a script is a small program in a high-level general-purpose language.


But what is an algorithm? tongue.gif

QUOTE

QUOTE
look at the example they give. That's a program/script to me. wacko.gif

Seems an algo can be written as a program/script (but also in English prose, like in the example), and a program can be a script? In other words, an algo can be a script? unsure.gif


Nah, the prose is pseudo code, or a verbal description of the intention and procedure of the script/algorithm.

About programs vs. scripts. I tend to generally call them scripts if they aren't compiled. And if they are stand alone and not huge. Like this forum I would call a program rather than a script. Or I guess it could be called a system of scripts or something like that, but not "a script". "What forum script do you prefer?" - sounds batty. Compiled stuff I always call programs, no matter how small they are. But that's me - I have no idea if I use the terms in a totally kosher way.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jul 23 2018, 03:54 PM
Post #10


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,064
Joined: 9-August 06
Member No.: 6



QUOTE(CharlesEF @ Jul 23 2018, 10:09 PM) *

QUOTE(pandy @ Jul 23 2018, 12:48 PM) *

So you mean an algorithm is part of a program rather than a standalone program? But in that case, isn't it just a subroutine?

Yes, it would be considered a subroutine. And I see how easy it is to confuse an algorithm with a computer program. My understanding of an algorithm comes from a math background. If I were to translate that into computer talk then I would say a computer program could be converted into an algorithm if you can use mathematical formulas to reduce the code to only a few lines. That would be an algorithm.


I can see that. That pretty much sums up what I know about math algorithms. But if we stay in the computer world it gets muddy, I think.

Or has algorithm become a buzz word? Makes things sound fancy and a little mysterious maybe?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jul 23 2018, 04:06 PM
Post #11


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,064
Joined: 9-August 06
Member No.: 6



If this is true, even I use algorithms. cool.gif
https://www.youtube.com/watch?v=PY82qqyWJJs

There are several other YouTube clips trying to explain it, but this was the only one I saw I understood. But it can't be that simple, can it?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jul 23 2018, 05:11 PM
Post #12


.
********

Group: WDG Moderators
Posts: 7,947
Joined: 10-August 06
Member No.: 7



QUOTE(pandy @ Jul 23 2018, 10:49 PM) *

If not, why don't we ever hear someone talk about Google's scripts?

I'd say Google's original algorithm is their link popularity idea (probably patched as a house of cards by now), not the exact program code that's used for calculating it.

BTW Googlebot is probably a compiled program, not a script. tongue.gif

QUOTE
Nah, the prose is pseudo code, or a verbal description of the intention and procedure of the script/algorithm.

Isn't the latter the definition of an algorithm? Wikipedia: "An unambiguous specification of how to solve a class of problems". Imagine you tried to give instructions to Alexa/Siri/Cortana, wouldn't such instructions qualify as an algorithm? cool.gif

QUOTE
About programs vs. scripts. I tend to generally call them scripts if they aren't compiled. And if they are stand alone and not huge.

#metoo

QUOTE
Like this forum I would call a program rather than a script. Or I guess it could be called a system of scripts or something like that

I wouldn't call it neither "a program" nor "a script". A system of scripts sounds reasonable, or just "forum software".

QUOTE
Compiled stuff I always call programs, no matter how small they are.

Same here.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Jul 23 2018, 08:29 PM
Post #13


Programming Fanatic
********

Group: Members
Posts: 1,549
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



Since the advent of computers the waters have indeed become muddy. Let me try to explain it differently.
x = 5 MOD 2
Convert this into PHP
$x = 5 % 2;
Is this an algorithm? According to the PHP manual the modulo command returns the remainder of 5 divided by 2. So, exactly what is that line of code used for? You could turn it into a function, like this:
CODE

function isOddOrEven(input)
{
  return input % 2;
}

Anyway, none of that code makes this an algorithm, IMHO.
What I would consider an algorithm is the implementation of the modulo command itself.

I hope I make some sense. I've tried to convert my math background into computer talk, maybe not too well.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Jul 26 2018, 09:06 PM
Post #14


WDG Member
********

Group: Root Admin
Posts: 8,283
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 #15


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,064
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 #16


WDG Member
********

Group: Root Admin
Posts: 8,283
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 #17


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 18,064
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

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

 



- Lo-Fi Version Time is now: 19th November 2018 - 07:52 PM