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, 22.06.2019 01:00
Search the web for two examples of digital art that you like. the examples must be from different mediums (example: one digital photo and one computer animation not two computer animations). compose an essay for each example you choose about why the piece appeals to you, and identify the medium used.
Answers: 1
question
Computers and Technology, 22.06.2019 02:00
What is the largest decimal number that can be represented by a binary number with 4 place values? (remember, each place in a binary number has a value of a power of 2, starting in the ones place with 20.)
Answers: 3
question
Computers and Technology, 22.06.2019 09:50
Assume that you have an sorted array of records. assume that the length of the array (n) is known. give two different methods to search for a specific value in this array. you can use english or pseudo-code for your algorithm. what is the time complexity for each algorithm and why?
Answers: 1
question
Computers and Technology, 22.06.2019 10:50
Using least squares fitting, you are to fit the data sets to the following models and solve for the parameters ai , where i is the index of the parameter. the input/output data for the systems are linked in the bblearn site. for each of the systems use matlab to plot the supplied data vs. the model fit on one plot. include your code in the solutions. (a) linear fit "lineardata.mat" y=a1x^3 + a2x^2 + a3x + a4 (b) plant fit "plantdata.mat g(s) = a1/(s + a2)
Answers: 1
You know the right answer?
You're given the code (attached) for the SimpleStack class, a sample native Python implementation of...
Questions
question
Mathematics, 04.04.2020 17:16
question
Mathematics, 04.04.2020 17:16
question
Mathematics, 04.04.2020 17:16
question
Mathematics, 04.04.2020 17:17
Questions on the website: 13722360