Question: Consider the pseudo code: S := an empty stack push N items onto S a) If S is implemented as a linked list, what is

Consider the pseudo code:

S := an empty stack

push N items onto S

a) If S is implemented as a linked list, what is the runtime of the pseudocode?

A. O(logN)

B. O(N)

C. O(NlogN)

D. O(N^2 )

E. None of the above

b) If S is implemented as an array that is re-sized by quadrupling each time an item is pushed onto a full Stack and if N is a power of 4, what is the total number of array accesses for the pseudocode?

A. 5N-2

B. 5N-2/3

C. 3N - 2

D. 2N -1

E. None of the above

c) If S is implemented as an array that is re-sized by adding 500 to the capacity each time an item is pushed onto a full Stack, what is the runtime of the pseudocode?

A. O(logN)

B. O(N)

C. O(NlogN)

D. O(N^2)

E. None of the above

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!