Algorithms: Difference between revisions

From Helpful
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
===What does algorithm mean?===
<!--
<!--
===What does algorithm mean?===


A mechanical, fairly detailed description of getting a particular thing done, a particular method towards a particular goal  
A mechanical, fairly detailed description of getting a particular thing done, a particular method towards a particular goal  
Line 33: Line 33:




-->


====What do they look like?====
<!--
Depends, mainly on the complexity, and on what it does.




===What do they look like?===
There are a lot of things you can describe fully with words, and a little math.


Depends, mainly on the complexity, and on what it does.
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>


There are a lot of things you can describe fully with words, and a little math.
...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 .


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, and might include some more edge cases the above does not explicitly mention, even if you would need to rewrite it into ''actual'' code before it actually would run.




Line 60: Line 69:




-->


===="The algorithm"====


==="The algorithm"===
<!--
"The algorithm", to most, ranges from ''extremely specific'':
"The algorithm", to most, ranges from ''extremely specific'':
: the way that the video site figures which video you might want to see next,
: the way that the video site figures which video you might want to see next,

Latest revision as of 20:02, 28 June 2024

What does algorithm mean?

What do they look like?

"The algorithm"