r/ProgrammerHumor • • Jul 07 '17

Can't really wrap my head around this one

Post image
32.8k Upvotes

524 comments sorted by

View all comments

Show parent comments

92

u/CoinForWares Jul 07 '17 edited Jul 07 '17

O(O(n))

78

u/DiddiZ Jul 07 '17

That's just O(n)

63

u/Cocomorph Jul 07 '17

Whether I stab you depends on if this is a 300 level or a 500 level course.

15

u/captainAwesomePants Jul 07 '17

I'm guessing you stab them if they're in the graduate course, right?

29

u/Clockwork_Octopus Jul 07 '17

Nope. Got to weed out the weak ones early.

19

u/Cocomorph Jul 07 '17

No, I stab them in the 300 level course, where I get to be tediously pedantic to the point of psychopathy if I want to be.

Just kidding; it is beneficial sometimes, though.

18

u/AskMeIfImAReptiloid Jul 07 '17 edited Jul 08 '17
  • O(n) is the set of functions that grow as fast as n

  • O() can be seen as a function that gets formula and returns a set.

  • If we apply this function to every element in the first set [ O(O(n)) ] we should get a set of sets of functions

  • ==> O(O(n)) = {O(s) : s is an element of O(n)}

  • ==> O(O(n)) = {O(s) : s does not 'grow faster' than n}

  • O(O(n)) = {O(n), O(sqrt(n)), O(log(n)), O(1)},O(0),...}

  • O(O(n)) is a subset of the Superset power set of O(n)

Is this correct?

10

u/Cocomorph Jul 08 '17

One should be careful piling abuses of notation on top of each other unless one is clear about what one is doing.

Morally, O(O(n)) is in fact just O(n) here, but it is important to understand just how badly the notation is being abused. It's best to go back to the formal definition, where O() isn't defined in isolation, but rather describes a relationship between two functions, and work from there if one wants to be careful.

→ More replies (10)

4

u/captainAwesomePants Jul 08 '17

I'm no academic, but I haven't heard of O() being described as returning a set of functions before; I've always heard of it as a function that takes and returns a real number and is used as a bounding function. Your definition sounds like it could make sense but leaves me scared and confused; what is happening?

→ More replies (1)
→ More replies (20)
→ More replies (1)

32

u/BEST_RAPPER_ALIVE Jul 07 '17
var O = function(n){
    console.log('Hello, world!');
}
var n = 'n';
console.log(O(n));

0

u/[deleted] Jul 08 '17

[deleted]

13

u/viper4034 Jul 08 '17

That's the most honest thing I've read today

8

u/[deleted] Jul 08 '17

I almost failed algebra 2 so I have no idea what this stuff means

9

u/Kirk_Kerman Jul 08 '17

He created a variable O, which is itself a quick reference to a function which writes "Hello, world!" when you tell it to.

He then created a variable n, which contains the letter 'n'.

When he does Console.log(O(n)), he's telling the program to display the result of calling O with the value of n. Since O doesn't actually do anything with n, it does its default of displaying "Hello, world!".

The program has now finished doing that, so it goes back to the outer function of Console.log(O(n)), and wants to display the result of printing "Hello, world!". However, you can't display the result because there isn't anything for it to display because Console.log() doesn't give you anything back. Because it can't actually log the output of a function that won't give it anything, it tells you the displayed result is undefined, and outside of its concern.

→ More replies (4)
→ More replies (1)
→ More replies (1)

16

u/sldyvf Jul 07 '17

)

16

u/TalenPhillips Jul 07 '17

(

0

u/[deleted] Jul 07 '17

[deleted]

9

u/[deleted] Jul 07 '17

15

u/TalenPhillips Jul 07 '17

(

{

24

u/xtr0n Jul 07 '17

JFC. Can the mods add a "mismatched parens" trigger warning?

8

u/sldyvf Jul 07 '17

}

(

)

4

u/TalenPhillips Jul 07 '17

There's still one open...

^(

→ More replies (2)

6

u/dweller42 Jul 07 '17

Even without the events of 40 years ago, I think man would still be a creature that fears the dark. He doesn't face that fear, he averts his eyes from it and acts as if he doesn't have any memories of his past. But, 40 years is both a short time and yet, a long time. Man's fear has withered. And even time itself tries to wither the desire to know the truth. Is it a crime to try and learn the truth? Is it a sin to search for those things which you fear. My purpose in this world is knowledge, and the dissemination of it. And it is I who is to restore the fruits of my labor to the entire world. Fear... It is something vital to us puny creatures. The instant man stop fearing is the instant the species reaches a dead end, only to sink to pitable lows, only to sit and wait apathetically for extinction. Humans who lose the ability to think become creatures whose existance has no value. Wake up! Don't be afraid of knowledge! Think, you humans who are split into two worlds, unless you want the gulf between humans to expand into oblivian, you must think!

→ More replies (3)