An array is a random access data structure; a stack is not. a. true b. false In
ID: 3722421 • Letter: A
Question
An array is a random access data structure; a stack is not.
a. true
b. false
In a linked list implementation of a stack, the reference variable to the top of the stack is set to NULL.
a. true
b. false
What is the time-complexity of the copy constructor?
a. O(1)
b. O(n)
c. O(log n)
d. O(n2)
The elements at the top of the stack have been in the stack the longest.
a. true
b. false
Adding an element to a full stack and removing an element from an empty stack generate errors or exceptions called stack overflow exception and stack underflow exception.
a. true
b. false
Explanation / Answer
An array is a random access data structure; a stack is not.
A) True.
array is index based, if we want to access any element at a particular index we can using that index.
But as per stack we can access only trough top.
In a linked list implementation of a stack, the reference variable to the top of the stack is set to NULL.
A)True
In array implementation of stack top will be pointed to -1 which means that there are no elements in stack.
But in case of linked list top will be a pointer so here we set top to NULL initially when there are no elements.
What is the time-complexity of the copy constructor?
A) O(1)
by using one statement we can copy the constructor to another variable
The elements at the top of the stack have been in the stack the longest.
A) false
Element at the top of the stack is the one that is getting deleted first as it follows Last in first out scheme
Adding an element to a full stack and removing an element from an empty stack generate errors or exceptions called stack overflow exception and stack underflow exception.
A) True
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.