Algorithms: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
===What does algorithm mean?=== | |||
<!-- | <!-- | ||
A | A mechanical, fairly detailed description of getting a particular thing done, a particular method towards a particular goal | ||
If you ask "how does this thing do X" and you get a detailed, technically satisfying answer, that could be considered an algorithm. | |||
This isn't ''exclusive'' to math or computation, but that's where we use the term most. | |||
...to differing standards. Say, | |||
* users may be happy enough when a site mentions that it presents videos based on preference | |||
* programmers may not call something an algorithm when it's only specified at the level of "and then it reweigh videos based on user tags", | |||
: but only once it is unambiguous, possibly pseudocode, or already concrete enough to just run. | |||
Around algorithmics, we try to be precise ''enough'' | |||
: and prefer simple, well-contained questions, for single tasks, such as "how similar are these two words?" or "how do we sort a list?", | |||
: over more complex such as "how do we evaluate a weather forecast for the next day?" or "how do we distribute processing power between running programs" | |||
or "how do we | |||
Note it refers to the method only -- excluding details like the data you feed into it, or the hardware it runs on. | |||
Thy don't ''have'' to be completely implemented and ready to run, | |||
but most of the work left is implementing what is already described writing it out, ''maybe'' figuring out practicalities to supporting systems - but no further architecting of how to move towards getting a result. | |||
--> | |||
====What do they look like?==== | |||
<!-- | |||
Depends, mainly on the complexity, and on what it does. | Depends, mainly on the complexity, and on what it does. | ||
Line 36: | Line 42: | ||
There are a lot of things you can describe fully with words, and a little math. | There are a lot of things you can describe fully with words, and a little math. | ||
Say, bubble sort is an algorithm that, in English, goes something like "step though a list one at a time. At each position, look at the pair. If the are not in the right order, swap them. Repeat going through the list until you didn't need to swap anything". | |||
Writing down the same in [[pseudocode]] is not much longer than that: {{verify}} | |||
<syntaxhighlight lang="python"> | |||
for i in 1 through length-of( L ) | |||
for j in length-of( L ) through i + 1 | |||
if L[j-1] > L[j] then | |||
Exchange L[j-1] with L[j] | |||
</syntaxhighlight> | |||
...and {{comment|(even if you would need to rewrite it into ''actual'' code before it actually would run)}} might include some more details, sometime edge case handling, that a worded version does not explicitly mention . | |||
Line 52: | Line 60: | ||
Note that neural nets aren't algorithms in this sense, | Note that neural nets aren't algorithms in this sense, | ||
because while we know how they function, | because while we know how they function, | ||
they entangle everything they do in one fuzzy mess. | they do not function without data - in fact they entangle everything they do in one fuzzy mess. | ||
In particular, they entangle ''what'' runs into ''how'' it is evaluted. | In particular, they entangle ''what'' runs into ''how'' it is evaluted. | ||
The software becomes part of the | The software becomes part of the execution environment in a way, | ||
which is something programmers typically kept separated. | which is something programmers typically kept separated. | ||