[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 97 KB, 1266x784, fastalgorithm.png [View same] [iqdb] [saucenao] [google]
8676004 No.8676004 [Reply] [Original]

You can't find an algorithm that runs faster than O(-1/12) time.

>> No.8676211

>sum [1..]

Why are most languages such shit? Just say what you need to say.

>> No.8676216

>>8676211

Because languages that aim for simple syntax like you describe usually turn out to be unweildy on more complex problems than summing the natural numbers.

Naturally there are languages that are way much better than what OP posted, but the more terse notation will still look like a programming language

>> No.8676234

exactly what do you expect will happen when i reaches MAX_INT ?

>> No.8676237

>>8676211
Because a computer doesnt know what sum[1..] means.

High level programming languages are useless for doing things that require lots of optimization and speed.

C/C++ is so popular because it found a point where it is fast enough to do everything you could possibly want and it provides abstraction so what you are writing is understandable.

Try writing an OS in Haskell.

>> No.8676258

your code doesn't even work the way you want it to, better just end it all.

>> No.8676261

>>8676234
integer overflow causes i to become -1/12

>> No.8676278

>>8676237
A computer doesn't know what "for" means either your retard.

CS freshmen get the fuck back to /g/.

>> No.8676286

does anyone even get the joke? I hate all of you except OP

>> No.8676290

>>8676278
Read what I said you idiot.

C/C++ provides abstractions which can be, compared to something like Haskell, easily compiled into machine code.

Implementing a for loop in assembly isnt that fucking hard, try doing the same for sum[1..] even the 1.. part requires an extensive amount of data structures and effort.

You obviously have not even slightest clue about anything CS related because you retard claimed that low level languages have no use.
Have you gone beyond fizzbuzzing in Haskell?

>> No.8676304

>>8676290
You're right about the advantages of C/C++ but still, >>8676278 has a valid point when he says
>A computer doesn't know what "for" means either your retard.

>> No.8676311

>>8676304
Yes he has. But figuring out what a for loop is for a computer is significantly more easy then figuring out what sum[1..] might mean.

>> No.8676315

>>8676311
Yea so what? Just cause something is not as easy is no reason not to do it.

>> No.8676326

This is a java code.
What is this program suposed to do?

>> No.8676329

>durr abstraction is bad!!!
The state of modern CS education.

>> No.8676335

>>8676004
Nice meme, but that code runs in O(n^2) time.

>> No.8676347

>>8676004
Cashmeout side and my algorythm will have you dropped on the ground before you know it.

>> No.8676356

>>8676286
I guess the 'joke' has something to do with a negative runtime implying it ran backwards in time? Does your runtime analysis method require the code to be executed? You seem to imply it since you make a point of it not being called? Or is that an error code, since the logic is flawed and the first variable to overflow is res?

>> No.8676361

>>8676315
High level programming languages most of the time are less efficient, make it harder to optimize and removes the programmer from what is actually going on (this is often (but not always) a good thing).
There are also some things (eg. OSs) where low level languages are needed.

There is no reason why generally languages with high levels of abstraction are supperior. The best choice is always depended on what you actually want to achive.

>> No.8676966

>>8676004
This function calculates the value of 1+1+1+... rather than 1+2+3+... so it should return -1/2 and not -1/12
Also
>-1/12
>int

>> No.8676969

>>8676286
No it's a reference to the meme 1+2+3+...= -1/12

>> No.8676984
File: 239 KB, 520x638, Yaranaika.jpg [View same] [iqdb] [saucenao] [google]
8676984

>>8676286
mfw CS autists don't recognize /sci/'s worst meme on sight

>> No.8676997

>>8676966
this

>> No.8677073

hold on. It calculates
1+
1+2+
1+2+3+
1+2+3+4+
:
1+2+...n
until an overflow error in res occurs.
how, in what world does this relate in any way to negative one half or -1/12??
what is this? and what has the result to do with the running speed of the algorithm?

>> No.8677080

>>8676004
According to human language yes.

There's no physical law that prevents algorithms from running any time. Hell, there's aliens that can run algorithms with energy only and zero expenditure of time.

>> No.8677106
File: 73 KB, 450x796, 1486861760697.jpg [View same] [iqdb] [saucenao] [google]
8677106

>>8677073

Was it OP all along ? Yes ? I knew it was him, he keeps on fucking with people, I don't know what to do with him. I guess we'll have to get him killed.

>> No.8677117

>>8676004
>>8676261
I really really like this meme!

>> No.8677895

>>8676356
gtfo of /sci/

>> No.8677928
File: 132 KB, 680x680, image.png [View same] [iqdb] [saucenao] [google]
8677928

>ITT taking an obvious troll post seriously

>> No.8678022

>>8676278
it's still a whole levels of abstraction closer, don't be such moron

>> No.8678044
File: 109 KB, 342x421, mfw.png [View same] [iqdb] [saucenao] [google]
8678044

THank you op for this meme
Rumanjin sum at best