-3

In the coursera course, below union find is implemented for numbers only: https://www.coursera.org/learn/introduction-to-algorithms/lecture/EcF3P/quick-find

public class QuickFindUF
{
 private int[] id;
 public QuickFindUF(int N)
 {
 id = new int[N];
 for (int i = 0; i < N; i++)
 id[i] = i;
 }
 public boolean connected(int p, int q)
 { return id[p] == id[q]; }
 public void union(int p, int q)
 {
 int pid = id[p];
 int qid = id[q];
 for (int i = 0; i < id.length; i++)
 if (id[i] == pid) id[i] = qid;
 }
}

At the end of the slide, how are 10^9 operations per second and other 10^x numbers calculated (including 10)? All numbers are in below image: (text is also copied below)

image

Rough standard (for now).

  • 10^9 operations per second.
  • 10^9 words of main memory.
  • Touch all words in approximately 1 second.

Ex. Huge problem for quick-find.

  • 10^9 union commands on 10^9 objects.
  • Quick-find takes more than 10^18 operations.
  • 30+ years of computer time!
wovano
  • 4,543
  • 5
  • 22
  • 49
Stacky
  • 503
  • 2
  • 6
  • 23
  • "how are 10^9 operations per second... calculated" - you have CPU working at tens of GHz, assuming operations of tens clock-ticks per op, you roughly get Gops/s - thus 10^9 ops/sec. Similar goes for the memory capacity – Adrian Colomitchi Oct 10 '16 at 02:17
  • Contact coursera? Unless the authors of this training happen to read your question I don't see how it can be answered here. Contacting coursera makes it much more likely that the authors read your question. – Erwin Bolwidt Oct 10 '16 at 02:17
  • Some of the numbers are estimates of current computing speed, others are not. Which ones are you questioning? – President James K. Polk Oct 10 '16 at 02:18
  • @AdrianColomitchi, so is 10GHz taken as maximum possible cpu frequency and similarly for RAM? – Stacky Oct 10 '16 at 02:28
  • "so is 10GHz taken as maximum possible cpu frequency" - speaking in "orders of magnitude" rather than in "exact to zillions of decimal places", but roughly it seems a plausible interpretation. – Adrian Colomitchi Oct 10 '16 at 02:44
  • Thanks! I hope someday stackoverflow prevents down voting without a reason. Or, removes these reputations (at least provide basic privileges to all). Some people just keep downvoting blindly (unless we can see the reason). IMHO, this defeats the purpose of this site. See my other question, it was on programmers exchange as was not applicable for stack overflow but was still down voted. – Stacky Oct 10 '16 at 16:39

1 Answers1

1

Those numbers are order-of-magnitude estimates of computer processing speed (GHz) and memory size (G "Words", i.e. ints, or 4GB).

If you have a memory of 1 billion ints it will take you about 1 second to look at them all, so an algorithm that is O(n) on those 4 billion ints will take 1 second. If the algorithm is O(n2) it will take 1018 operations, or 1 billion seconds, approximately equal to 31 years.

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190