subject

You're given the code (attached) for the SimpleStack class, a sample native Python implementation of a stack. Your task is to complete a modified version of this code that implements the MinStack class. MinStack works exactly the same as SimpleStack, except that It adds the min method that returns the smallest positive value currently in the stack (you can assume the stack holds only numbers) Fill in an implementation for all the methods in MinStack, and submit min_stack. py to the GradeScope autograder. You may not import any other Python code, or use try...except. The auto-grader will run 5 tests on your code, worth 5 points: 0. Given an empty stack, `min()` should thrown an exception 1. On the stack constructed by "`push(1); push(10); push(-100); push(-10)`", then `min()` should return -100 2. On the stack constructed by "`push(1); push(10); push(-100); push(-10); pop()`", then `min()` should return -100 3. On the stack constructed by "`push(1); push(10); push(-100); push(-10); pop(); pop()`", then `min()` should return 1 4. On the stack constructed by "`push(1); push(10); push(-100); push(-10); pop(); pop(); push(0)`", then `min()` should return 0 Your implementations of push(), pop(), min(), and peek() should have O(1) time complexity. After the due-date I will also grade the time complexity of your code, and this will count for another 5 points.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 02:00
For a typical middle-income family, what is the estimated cost of raising a child to the age of 18? $145,500 $245,340 $304,340 $455,500
Answers: 1
question
Computers and Technology, 23.06.2019 10:00
Hey i just logged on and one of the moderators deleted a bunch of my answers to questions, even though the answers were right and the people it doesn't make sense but if anyone wants to talk about anything just message me lol (this is super random lol)
Answers: 1
question
Computers and Technology, 23.06.2019 15:30
The processing of data in a computer involves the interplay between its various hardware components.
Answers: 1
question
Computers and Technology, 23.06.2019 19:30
Anul 2017 tocmai s-a încheiat, suntem trişti deoarece era număr prim, însă avem şi o veste bună, anul 2018 este produs de două numere prime, 2 şi 1009. dorel, un adevărat colecţionar de numere prime, şi-a pus întrebarea: “câte numere dintr-un interval [a,b] se pot scrie ca produs de două numere prime? “.
Answers: 3
You know the right answer?
You're given the code (attached) for the SimpleStack class, a sample native Python implementation of...
Questions
question
Mathematics, 26.11.2019 19:31