Ask your own question, for FREE!
Computer Science 8 Online
OpenStudy (anonymous):

Ive been working with the running times of algorithms. Im trying to determine the cost for n pushes onto a stack when the stack is full. That is when a given stack of size N is full replace it with a stack of size f(N) where f(N) = N + c (a constant) or f(N) = 2N. I am to compare these 2 strategies. you can assume that a regular push is constant time but a "special push" (when the stack is full) costs f(N) + N + 1 time. That is, we assume a cost of f(N) units to create the new array, N units of time to copy the N elements and one unit of time to copy the new element. Whats bigOh?

OpenStudy (anonymous):

I believe the the first case, f(N) = N + c should run in O(n^2/c) but how do you get that answer? f(N) + N +1 = time <=> N +c + N + 1 = time <=> 2N + k = time where k = c+1

OpenStudy (anonymous):

The big O in the worst case is just \(f(n)\in O(n)\).

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!