Q8. Consider the Stack ADT implemented using a Python list (called items) such that push() and pop() are defined as follows: def push(self, item): self.items.insert(0, item) def pop(sell): return...


question 8 i just need answer  please quikly thanks !


Q8. Consider the Stack ADT implemented using a Python list (called items) such that push() and<br>pop() are defined as follows:<br>def push(self, item):<br>self.items.insert(0, item)<br>def pop(sell):<br>return self.items.pop(0)<br>What is the big-O complexity of push() and pop()?<br>(A) both push() and pop() are O(n)<br>(B) pop() is O(1) but push() is O(n)<br>(C) push() is O(1) but pop() is O(n)<br>(D) both push() and pop() are O(n)<br>

Extracted text: Q8. Consider the Stack ADT implemented using a Python list (called items) such that push() and pop() are defined as follows: def push(self, item): self.items.insert(0, item) def pop(sell): return self.items.pop(0) What is the big-O complexity of push() and pop()? (A) both push() and pop() are O(n) (B) pop() is O(1) but push() is O(n) (C) push() is O(1) but pop() is O(n) (D) both push() and pop() are O(n)

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here