Talk:Euclidean algorithm

This article is nice, but it would have been nicer, had the reader been not expected to know javascript or python. At least I do not know Javascript and Python, though I'm interested in what is happening in the implementation. It would be great if these things are replaced by a pseudo code, which will be more readable. Thanks.

-- Ramesh, India.

Contents

I Agree

I agree to Ramesh, PsudoCode is the better way to discribe an algorithm. In special: what means a, b = b, a % b I don't think it's a = b b = a modulo b that doesn't make any sense, after this b would be 0 (in any case it was before) b = a modulo b a = b is also a bit confusing, because in the next run b would become 0 whatever a and b are before. Greetings from Germany

Actually, the real Euclid's Algorithm didn't use division but subtraction - a lot easier with the arithmetic tools available to the classical Greeks, and just as easy to reason about. Division is just an early optimisation. PML.

Time Complexity

Could someone please tell me the time complexity of the original euclids algorithm. This is the one which uses subtraction only. Thanks.

Asymptotically or Worst-Case?

The article states that the binary GCD algorithm is asymptotically <math>O(n^2)<math>. Does this mean that the algorithm's performance degrades as the numbers become larger? It seems like this should be the "worst case" behavior and not the general asymptotic behavior. If not, another sentence about why the asymptotic complexity is so high would help.

You have some confusion over the meaning of asymptotic. Asymptotically simply means "as n becomes very large", and is in fact redundant here, because it's already implied by the big-O notation. The big-O notation also implies worst-case, because <math>O(n^2)<math> means precisely that, for large enough n, it runs in time at most a constant times n2. See Big-O notation for more of the formal details; I hope this helps. Deco 01:59, 19 Nov 2004 (UTC)

I understand what asymptotic means. I also understand that the big-O already implies both "asymptotic" and "worst case". However, the intent of the sentence, I believe, is to say that the binary GCD algorithm is fast for most inputs, but there are still some pathological inputs (of all sizes) that trigger <math>O(n^2)<math> behavior. This might be better explained by redundantly stressing "worst case" instead of "asymptotic". By stressing "asymptotic", it implies that the algorithm is fast up until a certain input size; after that, it slows down (which I don't think is the case; is it?).

Optimization

In fact Euclid's origonal argorithm is faster. Modulo is implemented by iterated subtraction, so the loop overhead is cut by the origonal method. While it may not seem that way, examining the assembler produced by a C implementation will show Euclid to be correct.

Navigation
  • Home Page (https://academickids.com/)
  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (https://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (https://academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (https://academickids.com/encyclopedia/index.php/Clipart)
  • Geography (https://academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (https:/academickids.com/encyclopedia/index.php/Countries)
    • Maps (https://academickids.com/encyclopedia/index.php/Maps)
    • Flags (https://academickids.com/encyclopedia/index.php/Flags)
    • Continents (https://academickids.com/encyclopedia/index.php/Continents)
  • History (https://academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (https://academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (https://academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (https://academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (https://academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (https://academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (https://academickids.com/encyclopedia/index.php/Timelines)
    • United States (https://academickids.com/encyclopedia/index.php/United_States)
    • Wars (https://academickids.com/encyclopedia/index.php/Wars)
    • World History (https://academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (https://academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (https://academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (https://academickids.com/encyclopedia/index.php/Reference)
  • Science (https://academickids.com/encyclopedia/index.php/Science)
    • Animals (https://academickids.com/encyclopedia/index.php/Animals)
    • Aviation (https://academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (https://academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (https://academickids.com/encyclopedia/index.php/Earth)
    • Inventions (https://academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (https://academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (https://academickids.com/encyclopedia/index.php/Plants)
    • Scientists (https://academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (https://academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (https://academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (https://academickids.com/encyclopedia/index.php/Economics)
    • Government (https://academickids.com/encyclopedia/index.php/Government)
    • Religion (https://academickids.com/encyclopedia/index.php/Religion)
    • Holidays (https://academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (https://academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (https://academickids.com/encyclopedia/index.php/Planets)
  • Sports (https://academickids.com/encyclopedia/index.php/Sports)
  • Timelines (https://academickids.com/encyclopedia/index.php/Timelines)
  • Weather (https://academickids.com/encyclopedia/index.php/Weather)
  • US States (https://academickids.com/encyclopedia/index.php/US_States)

Information

  • Contact Us (https://academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (https://classroomclipart.com)
Toolbox
Personal tools