Bookdiscusses two implementations of stacks in detail: Array (stackType- pages 4
ID: 3616639 • Letter: B
Question
Bookdiscusses two implementations of stacks in detail: Array (stackType- pages 410-420) and Linked List (linkedStackType - pages 428-439).Review their definitions and methods closely. Identify theoperations for which time complexities differ between twoimplementations.
Bookdiscusses two implementations of stacks in detail: Array (stackType- pages 410-420) and Linked List (linkedStackType - pages 428-439).Review their definitions and methods closely. Identify theoperations for which time complexities differ between twoimplementations.
initializeStack
destroyStack
isEmptyStack
isFullStack
push
top
pop
Explanation / Answer
In array stack initialization take O(n) time and inlink list case it will be O(n2) time. in destory stack both will also take equal time=O(n)time is empty Stack is constant time operation in both cases. isfull stack is available in array, in linklist if thememory is available then you can add more elements and stack willnever full. push is costly in linklist. and will take O(n2) time to movethe elements backward and add in front of the list. In array it isO(n) operation just add the element at the end of array.. top is constant time operation for both cases. PoP is also a constant time opertion in both cases.Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.