1.A stack implemented with an array has what performance?
Select one:
a.
O(n3)
b.
O(n log n)
c.
O(n)
d.
O(n2)
2.
A stack uses the first in first out insertion and deletion method.
Select one:
True
False
3. Match the following stack operations with their meaning.
object pop();
boolean isEmpty();
push (object);
integer size();
object top();
meanings are:
- returns the number of elements stored
-just removes the last inserted elements
- returns the last inserted elements without removing it
-inserts an element
-indicates whether no elements are stored
-removes snd returns the last inserted element
Solution 1: Option C is the correct option as the stack could be implemented using an array in O(n) of time.
Solution 2: It is False as the Stack actually uses the Last In First Out mode of operation while a Queue actually uses the First In First Out mode of operation.
Solution 3: Given below is the correct match for each and every stack operation:
Here's the solution to your question and it is absolutely correct, please please please provide it a 100% rating. Thanks for asking and happy learning!!
Get Answers For Free
Most questions answered within 1 hours.