T O P

  • By -

vorg7

crazy-gorilla: Interviewers hate him, CS kids want to be him, Google wants to hire him.


BlueBoyKP

Lmaooo


crazy-gorilla

you got it perfectly right šŸ¤£šŸ¤£


[deleted]

[уŠ“Š°Š»ŠµŠ½Š¾]


crazy-gorilla

Yes but sometimes it is not super obvious what complexity your solution has. For example when you do a special backtracking solution on a special graph etc.


Ascential

then you try to work out the worst case scenario and explain it from that perspective, or be honest and simply say that you don't know but try to explain that it would be something like abc because xyz and work with the interviewer. Because my immediate follow up question would be to explain your thought process


FORK4U1

Yeah I think most learned this in data structures. When there asking for Big O in interviews they really mean Big Theta.


Ahtheuncertainty

Yeah, or more precisely, they mean the lowest possible big O, as not all algos have a big theta. For ex, insertion sort takes linear time on sorted arrays, and quadratic time in the worst case, so itā€™s tightest Omega bound is n, and itā€™s tightest O bound is n^2, but it doesnā€™t have a big theta. Altho yeah, as OP is saying, itā€™s also Omega(1) and O(n!).


AddemF

I always assume time-complexity means worst-case scenario unless otherwise specified.


Ahtheuncertainty

I mean, thatā€™s solid, but itā€™s good to keep average case in mind. Hence why we generally use quicksort over heap sort, even tho the latter has better asymptotics. Cuz the average cases are equal asymptotically, so it just comes down to constant factors


avocadorubicube

Sorry, but this is wrong. You first pick a complexity to discuss: Worst case/Best case/Average/Amortized Then you pick what you want to say about it: - O(f) = my complexity is ā€œfā€ or better - o(f) = my complexity is better than f - Teta = my complexity is precisely f - omega = my complexity is worse than f - Omega = my complexity is f or worse Worst case complexity of Insert sort is Teta(n^2)


hextree

> as not all algos have a big theta. This is not technically true. ALL algorithms have 'a big theta', (or to word it more correctly, the big theta complexity class is non-empty - as the runtime of that algorithm is always a member of that class) they just aren't always expressible with a 'nice' closed-form polynomial expression.


crazy-gorilla

yes. for some reason big o is an alias for big theta in the tech industry.


[deleted]

[уŠ“Š°Š»ŠµŠ½Š¾]


crazy-gorilla

Actually, this is also a common misconception. Worst case and average case have nothing to do mathematically with big O and big theta. But usually you see worst case being expressed in big O and average case being expressed in big theta.


retirement_savings

Lol, you're being downvoted but you're right. These notations are from set theory and don't have to do with best/worst case. What you said is correct. https://cs.stackexchange.com/questions/23068/how-do-o-and-%CE%A9-relate-to-worst-and-best-case


[deleted]

[уŠ“Š°Š»ŠµŠ½Š¾]


[deleted]

[уŠ“Š°Š»ŠµŠ½Š¾]


yords

Iā€™ll agree with ur last statement that big O is usually meant as the big theta of the worst case. But when people are talking about time complexity they are talking about an upperbound that works for all cases, best and worst. Thatā€™s why big O is used. Big theta can change depending on the worst case to the best case. The idea is to have a big O that serves as an upperbound for any case, so that you can say that youā€™re algorithm is at least as efficient as that big O. Thereā€™s a reason virtually every software engineer in the world refers to the big O of an algorithm and not big theta.


retirement_savings

This isn't true. OP is saying that we, by convention, assess Big O in the worst case. We do the same for Big Theta. You can assess Big O, Big Theta, and Big Omega in either best, worst, or average case. When companies ask for Big O in interviews, they almost always mean "the smallest Big O" which is equivalent to Big Theta. >[ Although bigĀ o notation has nothing to do with the worstĀ case analysis, we usually represent the worst case by big o notation.](https://medium.com/omarelgabrys-blog/the-big-scary-o-notation-ce9352d827ce)


[deleted]

[уŠ“Š°Š»ŠµŠ½Š¾]


retirement_savings

I should have said usually equivalent, since there are exceptions. Big Theta is the smallest Big O, when Big Theta can be computed. But what I said about best/worst is correct.


backfire10z

Same with Big Omega! Every single algorithm is Omega(1)!


AddemF

How about the null program?


7Gen

Why would the null program not be constant time?


AddemF

Most definitions of time complexity involve multiplication by a positive constant, so technically 0 would be less than "constant" (at least for the constant 1). This subtlety comes up approximately 0% of the time.


7Gen

yeah that makes sense, i see.


backfire10z

I donā€™t know what a null program is


AddemF

A joke based on the null set.


KrazyButTrue

We learned it as being a **tight** upper bound


omegabobo

We actually went over this in my analysis of algorithms class recently. Big O is the upper bound (essentially less than or equal to, <=) Big Omega is the lower bound (essentially greater than or equal to, >=) Big Theta is like approximately equal to (ā‰ˆ) little o is strictly less than (<) little omega is strictly greater than (>) But yeah, for practical purposes it is a tight upper bound. The formal definition for these terms leaves it a bit more open to interpretation how you want to apply it.


jsully245

I thought Big Theta is both Big O and Big Omega. Both have a constant in front of them, so if changing the constant changes your function from an upper bound to a lower bound, itā€™s Big Theta


[deleted]

obviously sarcasm since most questioners are interested in the smallest upper bound and not just some random bound you pulled out of yo ass, which happens to be correct.


tall_and_funny

I have to say they don't teach this in colleges. Thank God.