Discuss the effect on all operations on a stack if there were not a count variable in the implementation.

What will be an ideal response?

Push and pop would be minimally affected. The only difference would be that the count variable would not have to be updated. Peek would not be affected at all. The isEmpty operation would have to check the contents of the stack to see if anything is on the stack, instead of looking at the count variable. The biggest impact would be on the size operation, which would have to count the number of elements in the stack one by one; instead of a O(1) operation, size would become a O(n) operation.

Computer Science & Information Technology

You might also like to view...

In Step 3 of Business Writing, if the ________ is to make a recommendation, the recommendation needs to be expressed very clearly

Fill in the blank(s) with correct word

Computer Science & Information Technology

Where is the Remote Desktop Connection link (used to access a remote computer) found on a Windows 7 computer?

A) System and Security B) Network and Sharing Center C) Programs D) Accessories

Computer Science & Information Technology