What should be the time complexity of the isEmpty(), size(), and toString() methods?
What will be an ideal response?
Using the count variable, the size method is O(1) and simply returns the value of count. The isEmpty() method simply checks to see if size is equal to zero, so it is also O(1). The toString() method looks at each element in the stack once, so its time complexity is O(n), where n is the number of elements in the stack.
You might also like to view...
Which of the following statements is not true about group headers and footers?
A) They appear once for each unique value in the group. B) They are named after the field on which the group is based. C) They cannot be added to forms. D) You need to use caution when adding them to forms.
__________ is the encoding technique used to store negative numbers in the computer's memory.
a. Unicode b. ASCII c. floating-point notation d. two's complement