News for hackers. Stuff that matters.
Re:A beginner's guide to Big O notation (2009) by stcredzero on Thursday May 05, 2016 @07:37PM (#11640537)
If something puzzles you, don't be afraid to start drawing yourself a diagram. O(n^2) vs. O(n) amortized for naive string concatenation vs. growing a buffer by doubling:

  x
  xx
  xxx
  xxxx
  xxxxx
  xxxxxx
  xxxxxxx
  xxxxxxxx

  x
  xx
  xxxx
  xxxxxxxx
This can be a good way of getting an intuitive feel for what's going on. Note in the 2nd case, you can stack all of 1st two rows representing cost into the 3rd row. In fact, you can always stack the execution costs into row (n-1) and never exceed the size of row n.
Re:A beginner's guide to Big O notation (2009) by curiousDog on Thursday May 05, 2016 @08:13PM (#11640725)
Looks like you're alluding to the recurrence tree method for solving recurrences mentioned in CLRS. And you're right, it's a great way to visualize and get an intuitive feel of big-oh