How to find Complexities
Anonymous User
428

Hi, I know O(N) and O(N^2) and so on, I sometimes O(N), O(N^2) etc doesn't make sense.

Ex::

Lets say you have a vector or array, and you are pushing them in stack but as there are operation of pushing and poping is being done I think complexity of O(N) is not valid as operations are more than N times, also I want you to know that it is not O(N^2) too as many as porgram goes on stack is being popped and size of stack is continously changing.

Like in case of pushing smaller number to stack while popping the number larger than the current number,and pushing only number greater than stack.top() without popping.

Hey Listen I know it might not make sense but it bothers me and the internet article are not helping either.

If could explain, please do I will be really ThankFull

Comments (1)