[ 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: 36 KB, 800x450, pepefroggie.jpg [View same] [iqdb] [saucenao] [google]
9926050 No.9926050 [Reply] [Original]

CS cucks answer me this question. Say an algorithm on input x, checks if size of input x (number of bits used to represent x) is smaller than 1 googol. If it is, it loops for [math] 2^{size(x)} [/math] steps before halting, else it halts immediately.

What is the worst case running time of this algorithm in Big O notation. JFL at any cuck saying constant.

>> No.9926072

>>9926050
Practically speaking I think this is always going to run as O(2^n) where n = size(x), because how the fuck are you going to store a googol of bits?

>> No.9926073

Lrn2meme fgt pls

>> No.9926093

>>9926050
Who cares? It's a useless algorithm

>> No.9926096

>>9926050
Worst case is O(2^n), best case is O(1)

>> No.9926139

>>9926050
No one uses big O for algorithm analysis. It's taught to freshmen because it's easy for them to understand. Implementations and models vary. From my experience big theta notation, tilde notation, and actually running the algorithm is better

>> No.9926272

>>9926139
It’s important to understand big theta, big oh, and big omega. It gives you a feel for how functions and algorithms grow
Learning what runtime and classification means goes deep into complexity theory. It’s hoenstly a beautiful subject because it’s a new way to look at traditional math and science

>> No.9926297

>>9926272
Numerical analysis is the ugliest course in math I've yet to take. Fucking real analysis felt like a breath of fresh air after that shit. Runge-Kutta can fuck off, Chad analysts solve diffEq's analytically

>> No.9926309

>>9926297
Numerical analysis wasn’t exactly what I was talking about. In any event, understanding it for some PDE’s was actually fairly enlightening. I like real analysis, but sometimes developing tools to solve algorithmically can help you get insight into how it works analytically

>> No.9926319
File: 67 KB, 1000x665, 1454278176197674710.png [View same] [iqdb] [saucenao] [google]
9926319

This is just O(1). No matter what is the input, it will never do more steps than for x=1.

>> No.9926416

>>9926050
>Big O notation is a meme because of this one unpractical dumb scenario I just thought of

>> No.9927863

>>9926139
Not to mention that when you study topics like analytical combinatorics, analysis becomes instrumental to understanding anything.

>> No.9927941

>>9926072
2^log x = x, so couldn't we say O(x)?

>> No.9928092
File: 35 KB, 530x611, brainlet20.jpg [View same] [iqdb] [saucenao] [google]
9928092

>>9927941
>2^log x = x

>> No.9928448

>>9926050
yes, lets throw out the study of asymptotics because, though it doesnt exactly what it says on the label, you were misled by the results

what happened? you didn't study, guessed your way through a shitty exam, failed and blamed teacher?

>> No.9928454

>>9926050
its like saying integration is a retarded meme because you can integrate zero but have a constant of integration = a gorillion

>> No.9928456

>>9926050
O(2^size(x))

Coincidentally, it's also the average running time, assuming all integer inputs are equally likely

>> No.9929041

>>9926297
>Chad analysts solve diffEq's analytically
sounds like you got nothing out of the course, brainlet

>> No.9929332
File: 137 KB, 500x331, 82CD3A6C-EFAC-4A1D-85BF-BF13FD05C8DA.jpg [View same] [iqdb] [saucenao] [google]
9929332

>>9926297
The study of numerical analysis is different than plug and chugging the results of methods developed by numerical analysis. The former actually does take a good understanding of how to solve analytically

Reals Chads solve analytically and then figure out how to solve numerically to challenge their understanding.

>> No.9930089

>>9928092
Yeah, I'm talking about log 2 retard. AKA ~ the number of bits used to represent the number, aka size()

>> No.9931088

>>9926050

You don't need to use big O notation because we know the worst case running time exactly, which is when x=(1 googol)-1.

>> No.9931121

>>9926050
It is constant time, you brainlet. There exists a number c such that for all input, run time is <= c

>> No.9931157

>>9928448
>>9930089
>>9931088
>>9931121
>hurr durr I study CS

>> No.9931165

>>9931157
Are you ok?

>> No.9931185

>>9931165
He’s just making to put down his daily required shitpost. Classic /sci/

>> No.9931193

>>9931185
*making sure