Talk:Algorithm: Difference between revisions

Content deleted Content added
BTW
Refilwe: new section
Tags: Reverted Mobile edit Mobile web edit New topic
(905 intermediate revisions by more than 100 users not shown)
Line 1:
{{Article history
Where does the new cryptographic algorithm that is supposed to be unbreakable and was developed by a faculty member at M.I.T., I believe, belong here. It works by keys picked up from some random source, like a satellite, that are processed in the encryption but never stored anywhere. The inventor has proved that it is unbreakable with current computational power, and no one contests this apparently. Do you know what I am referring to? RoseParks
|action1=RBP
----
|action1date=12:29, 19 January 2004
Yes, but it isn't really an encryption algorithm itself so much as a novel means of key exchange. Most modern cryptography techniques are like that: everyone has known about [[:one-time pad|one-time pad]]s for a long time, and that they are unbreakable. Modern techniques like RSA and Diffie-Helmann are just ways to safely exchange keys, which can then be used as one-time pads. RSA and DH key exchange protocols can themselves be broken, while professor Rabin's method theoretically cannot be, but it is not yet practical for other reasons.
|action1link=Wikipedia:Archive/Refreshing brilliant prose - Science
----
|action1result=kept
Thank you. You may remove or do what you want with this. Perhaps other people have read about it and could use your explanation on these pages...maybe a page itself, or
|action1oldid=2206762
somewhere on these pages. RoseParks
|action2=FAR
----
|action2date=02:21, 16 May 2006
Most of the discussion above is pretty confused. Rabin's method isn't theoretically unbreakable, RSA and Diffie-Hellman are essentially never used to exchange one-time pad keys, RSA is not normally thought of as a key-exchange protocol, properly applied RSA may in fact be impossible to break, etc. But I don't have the time to write a section on cryptography just yet. --[[:Kragen|Kragen]]
|action2link=Wikipedia:Featured article removal candidates/Algorithm
----
|action2result=demoted
I think it would be a great idea if we came to some sort of standard on writing pseudocode. I've used a sort of hybrid procedural style for the algorithms in [[:Linear search|Linear search]] and [[:Binary search|Binary search]] but I'm wondering if there's a better standard out there. Can we borrow a style from a textbook like Intro to Algorithms? (is this copyrighted or is style a public ___domain thing like an idea?). Only a fairly small set of control structures is needed -- something to define functions, if-statements, loops, list access, mathematical operators and probably a few more. Comments? [[user:Mark Jeays|Mark Jeays]]
|action2oldid=53436000
|action3=GAN
|action3date=13:16, 13 July 2006
|action3result=listed
|action3oldid=63594141
|action4=GAR
|action4link=Talk:Algorithm/GA2
|action4date=17:47, 17 February 2010 (UTC)
|action4result=delisted
|action4oldid=344644436
|maindate=July 20, 2004
|topic=Math
|currentstatus=FFA
}}
{{WikiProject banner shell|vital=yes|class=c|1=
{{WikiProject Computing|importance=top}}
{{WikiProject Mathematics|importance=top | portal=true}}
{{WikiProject Computer science|importance=Top}}
}}
{{User:MiszaBot/config
| algo=old(365d)
| archive=Talk:Algorithm/Archive %(counter)d
| counter=5
| maxarchivesize=75K
| archiveheader={{Automatic archive navigator}}
| minthreadsleft=5
| minthreadstoarchive=1
}}
{{Archives|bot=Lowercase sigmabot III|age=365}}
== Where to cover "algorithms" as used in discussions about social media, big tech, etc? ==
 
I think this article should have some reference to the fact that "algorithms" are now being discussed in the context of social media platforms, "Big Tech", and related Internet technologies. As governments in Europe, the US, and other regions are discussing whether to regulate social platforms and companies such as Twitter, Facebook, and Google, the discussion often comes back to "algorithms". For instance, this is coming up quite often in discussions around [[Section 230]] in the US. In Europe there is an EU activity of "Algorithm Awareness-Building."<ref>{{cite web |url=https://ec.europa.eu/digital-single-market/en/algorithmic-awareness-building}}</ref> Just recently, two representatives introduced the "Protecting Americans from Dangerous Algorithms Act"<ref>{{cite web |url=https://eshoo.house.gov/media/press-releases/reps-eshoo-and-malinowski-introduce-bill-hold-tech-platforms-liable-algorithmic}}</ref>.
:I do think we should try to do standard pseudocode. I have no idea what that pseudocode should be however. CLR's style is usually clear, but sometimes I find it confusing (often because I do not parse the <code>A <- B</code> assignment syntax properly). I don't think things like pseudocode style are copyrightable... We should make a [[:pseudocode|pseudocode]] article that defines whatever we use (in addition to explaning what pseudocode is in general), then link to that from every pseudocode example. In addition, we could include examples in other languages (see [[:bubble sort|bubble sort]] for example) by putting them in subpages like [[:bubble sort/C++|bubble sort/C++]]. --BlckKnght
 
Given that many people may turn to Wikipedia to help understand what an "algorithm" is, I feel like there should be some mention of this usage on the page. But given the amount of detailed and academic info on the current page, I'm not sure how to best integrate this other content. Perhaps something brief in the lead paragraph and then a mention under "Informal definition"? Or a new section about "Algorithms in current politics"? Or a new section under "History" (although that seems mostly about the refinement of algorithms)? Any thoughts? - [[User:Dyork|Dyork]] ([[User talk:Dyork|talk]]) 17:25, 20 October 2020 (UTC)
----
We definitely need code samples for all the algorithms; I think there should be one language (pseudocode or otherwise) on the main page, and implementations in other languages on subpages, as [[:BlckKnght|BlckKnght]] suggested above.
 
: I agree that there should be some mention of the social media usage on this page. However I think it's wrong to conflate that usage with the real meaning of the word "algorithm". In the social-media context, "algorithm" usually just means that some kind of processing has been done; it doesn't mean that the processing was in accordance with any kind of clear procedure, which is what an algorithm is supposed to be. I don't want this page to be about any old data-processing. That's not an algorithm. That's just what journos refer to as "algorithm". If we let that go, then we'll need a new term to refer to real algorithms: e.g. "Explicit procedure for performing transformations on data", which is a bit unwieldy.
I think some executable language would be far preferable to pseudocode, for the following reasons:
* it's possible to test executable implementations of algorithms to see if they're buggy
* executable languages tend to be more rigorous than pseudocode; people writing in pseudocode tend to gloss over relevant details (like whether the range ''n..m'' includes ''n'', ''m'', both, or neither --- this is a huge difficulty with, for example, binary search)
 
: Can we have our word back please, mister?
My current favorite languages for this are [[:Scheme programming language|Scheme]], [[:C programming language|C]], and [[:Python programming language|Python]].
 
: 12:30, 27 October 2021 (UTC)
Python is the most readable of the three; it reads like pseudocode itself. It's also the least standardized of the three, the most rapidly changing, and the one with the most "hidden" stuff going on behind the scenes. (<tt>arr.append(item)</tt> in Python may allocate new space for the array if the space it's in isn't big enough; that really screws with algorithmic complexity analysis.)
 
: Absolutely. I'm surprised there isn't a separate article [[Algorithm (social media)]] that's written for a much more lay audience. Social media algorithms are usually more complex and aren't talked about in terms of big-O or anything like that. Instead, it's on the social impact of various choices of what to hilight -- things like the [[filter bubble]], [[algorithmic radicalization]], and even allegations that some social media company's decisions can [[Big Tech|sway political elections]]. And there are [https://news.google.com/search?q=social%20media%20algorithm&hl=en-US&gl=US&ceid=US%3Aen many news articles] about this topic. --[[Special:Contributions/Hirsutism|Hirsutism]] ([[User talk:Hirsutism|talk]]) 18:45, 24 August 2021 (UTC)
C is the most widely-used of the three, probably the one with the most complex and irregular syntax, the most standardized of the three, the least rapidly changing, and the one with the least "hidden" stuff going on behind the scenes. It's also the most verbose and the least readable for people who aren't familiar with the language or one derived from it. (Although, since it is so widely used, almost anyone who knows how to program is familiar with the language or one derived from it.)
 
:: Or perhaps an article about the [[Social impact of algorithms]], with a heavy emphasis on social media algorithms? Because there are articles about algorithms being used to [https://www.bbc.com/news/technology-56515827 hire and fire people], for [https://www.bbc.com/news/technology-53806038 insurance and policing], and [https://www.vox.com/recode/2020/2/18/21121286/algorithms-bias-discrimination-facial-recognition-transparency several other places they can introduce bias], and those should probably also be addressed in the for-a-lay-audience article. --[[Special:Contributions/Hirsutism|Hirsutism]] ([[User talk:Hirsutism|talk]]) 20:18, 24 August 2021 (UTC)
Scheme is intermediate between C and Python, in my opinion, except that it is the least widely used.
::''"In the social-media context, "algorithm" usually just means that some kind of processing has been done; it doesn't mean that the processing was in accordance with any kind of clear procedure, which is what an algorithm is supposed to be. I don't want this page to be about any old data-processing. That's not an algorithm. That's just what journos refer to as "algorithm". If we let that go, then we'll need a new term to refer to real algorithms: e.g. "Explicit procedure for performing transformations on data", which is a bit unwieldy."''
::Thank you! I've been trying to understand what news/social media means by algorithms. But none of the actual definitions help. Now I see that that is because the popular use of algorithm is similar to the popular use of 'metaphysics.' It means something different and sillier.
::We Social impact of algorithms: I see that there is already a wiki dealing with [[Algorithmic Bias]] that probably accounts for this. [[User:Jesseraekern|Jesseraekern]] ([[User talk:Jesseraekern|talk]]) 18:14, 2 December 2022 (UTC)
: I've written a bit of an article at [[User:Hirsutism/Algorithm (social media)]]. Could someone take a look at it, and tell me if they think the article should be expanded to cover all AI-with-a-social-impact, or should it focus only on social media algorithms? On the other side, there's quite a few articles about this already, I don't know whether we even ''need'' a new separate article, other than a short summary in this article? --[[Special:Contributions/Hirsutism|Hirsutism]] ([[User talk:Hirsutism|talk]]) 20:41, 29 August 2021 (UTC)
 
{{reflist-talk}}
For now, I'm going to add implementations in Python to the algorithm pages, and when I have time, I'll add implementations in C and Scheme on subpages.
 
:: The "algorithms" that are discussed in the context of social media are usually not algorithms as discussed in this article; the social media "algorithms" that are derived from big datasets by training ML systems are not transparent, and can't even really be expressed. I think it's incorrect to call these systems "algorithms".
-- [[:Kragen|Kragen]]
 
:: However I do appreciate that journalists and ML promoters do refer to these systems as "algorithms". Therefore I support the creation of a page for "algorithms" in a social media context. That might make it easier to keep this page focused on the subject of real algorithms.
: Kragen, have a look at the [[:pseudocode|pseudocode]] page, we thrashed out a "standard pseudocode" for Wikipedia a while ago (though feel free to make suggestions/improvements). The trouble with providing actual implementations of algorithms in real languages is that the trees start to get in the way of the forest. This is less of a problem in Python and Scheme, of course. --[[:Robert Merkel|Robert Merkel]]
 
:: [[User:MrDemeanour|MrDemeanour]] ([[User talk:MrDemeanour|talk]]) 08:56, 15 September 2021 (UTC)
----
An algorithm is not a rough form of a computer program. This is an example (among many) of the distinct Computer-science bias of the Wikipedia.
 
:::Agreed: "algorithm" as used in a social-media context is an important concept, quite distinct from this article's focus. The content of Hirsutism's draft at [[User:Hirsutism/Algorithm (social media)]] looks like a good start, but I'd argue that social media algorithms are simply a special case of a [[recommender system]]s, both on the technical and on the social/behavioral side. The social and behavioral aspects of recommender systems are mostly covered in the [[filter bubble]] article, but that's only one aspect. I'm not sure how to organize this better.... --[[User:Macrakis|Macrakis]] ([[User talk:Macrakis|talk]]) 14:14, 27 October 2021 (UTC)
Not every computer program is an algorithm either, at least according to some of the definitions of algorithm.
 
'Algorithm' as used by non-computer-scientists / non-experts to discuss recommender systems in social media (which, surely, are implemented by large numbers of algorithms) is a technically-incorrect use of the word almost entirely unrelated to this article. <!-- Template:Unsigned IP --><small class="autosigned">—&nbsp;Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/72.200.126.73|72.200.126.73]] ([[User talk:72.200.126.73#top|talk]]) 12:52, 23 August 2022 (UTC)</small> <!--Autosigned by SineBot-->
I don't have a reference handy, but I have seen '''algorithm''' defined to mean, roughly, a finite set of rules that is supposed to produce an answer in a finite number of steps. Therefore, infinite loops (which can occur in computer programs) cannot occur in algorithms according to this definition.
 
=== Page tidy up needed.===
This is, by the way, one of the motivations for the study of the [[halting problem]]. How do you prove that a certain method is in fact an algorithm?
This page is quite long and rambling and seems to have some content that could go to other pages such as the section on Euclid's algorithm and the conversation between Turing etc. This is a gateway concept to many related issues and it would be good if it was easier for the general reader to navigate. I can get started on some of this. [[User:AmandaSLawrence|Amanda Lawrence]] 01:16, 27 October 2021 (UTC)
 
:I whole-heartedly agree that this article strays off topic in many places. In particular, there is a paragraph in the "Expressing algorithms" section that talks about Turing machines. I have no problem with that idea, but it seems to come out of nowhere to me as currently written. I would either delete it or add a transitional phrase to the beginning of the first sentence. But I'm not going to do that right now, since there is no need to fine-tune this section if it is likely to be significantly modified in line with some of the other discussion on this Talk page.
:[[User:Mike-c-in-mv|Mike-c-in-mv]] ([[User talk:Mike-c-in-mv|talk]]) 23:44, 18 June 2023 (UTC)
::@[[User:AmandaSLawrence|AmandaSLawrence]] [[Special:Contributions/117.20.112.19|117.20.112.19]] ([[User talk:117.20.112.19|talk]]) 00:25, 6 January 2024 (UTC)
:::The whole section on Euclid's algorithm apart from the first para could be cut which would really help the flow - the examples could be quite short if they have their own page. But I'm not sure if all that long text should be added to the Euclid page or just cut. [[User:AmandaSLawrence|Amanda Lawrence]] 11:12, 25 January 2024 (UTC)
 
== Merge "[[Algorithmics]]" into this page ==
----
 
Anyone against merging [[Algorithmics]] into [[Algorithm]]? That page seems almost completely useless. [[User:Weebney|Weebney]] ([[User talk:Weebney|talk]]) 19:55, 23 January 2024 (UTC)
I removed the following example algorithm, because I think it is incorrect. Starting with the words zzz,yyy,xxx, it will in step one produce yyy,zzz,xxx and then it will produce yyy,xxx,zzz and then it will stop. [[User:AxelBoldt|AxelBoldt]] 00:33 Oct 8, 2002 (UTC)
 
:In favour - go for it. I don't think we need the illustration - not for the term anyway. [[User:AmandaSLawrence|Amanda Lawrence]] 10:57, 25 January 2024 (UTC)
An example of an algorithm is this rule (or method or procedure) for alphabetizing a list of names by repeating the specified steps until the job is done:
:It is finished. [[User:Weebney|Weebney]] ([[User talk:Weebney|talk]]) 06:02, 7 February 2024 (UTC)
 
== Contrast with heuristics ==
* Step 1. Compare the first 2 names on the list:
** a. If the 1st one is alphabetically ahead of the 2nd one, go to step 2.
** b. If the 2nd one is alphabetically ahead of the 1st one, swap the two of them and then go to step 2.
* Step 2. Pretend the 2nd and 3rd names on the list are the 1st and 2nd ones, and repeat step 1.
 
While I understand the thought behind contrasting algorithms with heuristics, I think it makes the page longer than it needs to be. It doesn't add new information about algorithms nor does it clear up common misconceptions. It seems like more of a detour in what should be a concise article. Any thoughts on keeping or removing the heuristics paragraph? [[User:Clubspike2|Clubspike2]] ([[User talk:Clubspike2|talk]]) 11:56, 25 June 2024 (UTC)
 
== Definition of heuristic ==
:No, it doesn't stop then -- you forgot to "repeat[] the specified steps until the job is done." The second time thru, you get xxx,yyy,zzz and then you stop, because "the job is done." -- [[User:Isis|isis]] 06:33 Oct 8, 2002 (UTC)
 
The statement that "a heuristic is an approach to solving problems that do not have well-defined correct or optimal results" is simply wrong. A heuristic is an approximate and often unproved method, independent of whether there exist well-defined correct of optimal results. See [[Heuristic]] in WP: "a technique designed for problem solving more quickly when classic methods are too slow for finding an exact or approximate solution, or when classic methods fail to find any exact solution". [[User:Zaslav|Zaslav]] ([[User talk:Zaslav|talk]]) 00:16, 19 December 2024 (UTC)
We have to formulate the algorithm clearer then. The whole point of an algorithm is to give unambiguous instructions for a process, and these are hardly unambiguous. Step two for instance talks about the 2nd and 3rd names, but doesn't say what to do if there is no 3rd name. I thought it should stop then, but you actually want a loop. If you say "until the job is done", does that imply that after each step 2, I have to scan through the whole list of names to check if it is already alphabetically ordered, and stop if it is? If so, the algorithm should say that clearly (and it wouldn't be bubblesort).
 
== Refilwe ==
Also, please don't mark your edits as "minor" if you make major changes to an article.
[[User:AxelBoldt|AxelBoldt]] 14:25 Oct 8, 2002 (UTC)
 
Mo di se@ [[Special:Contributions/105.245.126.148|105.245.126.148]] ([[User talk:105.245.126.148|talk]]) 11:03, 30 August 2025 (UTC)
:The whole idea of an encyclopedia is to explain basic concepts to people who don't know '''anything''' about them, including (or especially) 10 or 12 year-old-olds. I respectfully submit that anyone who knows what a "greatest common divisor" is (and probably anybody who knows what an "integer" is) '''already knows''' what an "algorithm" is. It's okay to put in the stuff that reads like a math textbook, but before that you need introductory material for the ordinary people that are never going to read past that expanded definition in lay terms. What you should really do is write something dynamic that would show a bubble sort of a short alpha list that wouldn't take an explanation at all but would show the items swapping and bubbling up the list. -- [[User:Isis|isis]] 22:46 Oct 8, 2002 (UTC)
 
 
:: GCD and HCF are usually covered at junior school level (10-12). Integers are probably called "whole numbers" at that stage, but the concept is graspable. I'm not sure at what age one encounters a term like "algorithm". Later, I think. -- [[User:Tarquin|Tarquin]] 22:50 Oct 8, 2002 (UTC)
 
There's no question those concepts are taught in math classes at that level, but that's irrelevant to the topic under discussion. My point is that the purpose of an encyclopedia article is to define/introduce its subject to someone who doesn't yet know anything about it. Unless this article explains "algorithm" in terms someone who doesn't already know what one is can understand, it is useless for its intended purpose. Ordinary people (of any age, but I'm talking about only the U.S., and it may be different elsewhere in the world) don't know what GCDs and integers are, and they don't need to know what they are to understand what an algorithm is, so the article should be written (at least at the beginning, and you can put in the technical stuff farther down) in terms they do understand -- that could have been accomplished by using the example of putting a list of numbers in numerical order, for example.
 
But there's a largerr issue I consider pertinent here, and that's that Americans are innumerate, not so much because they're incapable of understanding numerical concepts as that they've acquired a fear of math, and that's the fault of generations of math teachers who didn't understand or couldn't explain the concepts in terms that made them accessible. Those of us who are teaching math now (including teaching it thru the 'pedia) have an obligation to do better by the ones we teach, because math is so much more important a tool than it has ever before been in society. The more non-numerical examples we use to explain the concepts, the less math resistance we have to overcome, and the better (and easier) we get our job done. Therefore "word problems" of practical, everyday matters are better than sets of equations for illustrating mathematical principles, and therefore a list to be alphabetized is better than numbers to be sorted for explaining "algorithm," because it makes the readers comfortable with the concept before they realize it's math and resist it. (I have yet to see a 'pedia article on a mathematical topic that didn't look like it came from a math textbook instead of an encyclopedia.)
 
So I respectfully insist that the example in this article needs to be of a simple sorting algorithm (and there is none simpler than a bubble sort, so I'm still voting for that) that anyone can understand. I'd like for it to be of alphabetizing items, because that would obviate math anxiety, but if it has to be numerical, make it something like putting checks or invoices in serial-number order. I'd like for it to be dynamic, showing the items swapping in pairs, but I don't know how to program anything that moves, although I've started introducing animated gifs to encourage contributors that do know how to animate illustrations to do so. It is ridiculous not to take advantage of the capabilities of this medium, especially when equations are so deadly dull, and instead of showing the transformations in a mind-numbing list of them, you could have the elements moving in and out of the equations on the screen, and the novelty of that would suck your readers in, so they would pick up the concept before they realized it. -- [[User:Isis|isis]] 00:17 Oct 9, 2002 (UTC)
 
I completely agree with you that the first example should be as simple and intuitive as possible, and sorting names is simpler than computing gcd's. I just didn't like the bubblesort description since it wasn't explicit enough. By the way, I always thought [[selection sort]] is simpler: pick the smallest element, put it at the top. Pick the next smallest element, put it at position two, etc. That's how I usually sort things.
 
As to your contention that Wikipedia articles are too technical for an encyclopedia: here is the start of Encyclopedia Britannica's algorithm article, (fair use):
 
:''systematic procedure that produces—in a finite number of steps—the answer to a question or the solution of a problem. The name derives from the Latin translation, Algoritmi de numero Indorum, of the 9th-century Muslim mathematician al-Khwarizmi's arithmetic treatise “Al-Khwarizmi Concerning the Hindu Art of Reckoning.” ''
 
:''For questions or problems with only a finite set of cases or values an algorithm always exists (at least in principle); it consists of a table of values of the answers. In general, it is not such a trivial procedure to answer questions or problems that have an infinite number of cases or values to consider, such as “Is the natural number (1, 2, 3, . . .) a prime?” or “What is the greatest common divisor of the natural numbers a and b?” The first of these questions belongs to a class called decidable; an algorithm that produces a yes or no answer is called a decision procedure. ''
 
And it gets worse from there; not a single example. [[User:AxelBoldt|AxelBoldt]] 00:33 Oct 9, 2002 (UTC)
 
Articles should of course start with good definition/introduction paragraphs that give a person of average intelligence a good idea what the subject is and why it is important but we shouldn't dumb things down to the point where articles are not useful to people who already know the basics. BTW, we should also aim to be better than Britannica in depth, breadth and accessibility. Just my 2 cents. --[[User:Maveric149|mav]] 00:37 Oct 9, 2002 (UTC)