Version A Page 5 Name (Print please) ____________________________________________________________ Score 50 - ___________ = _____________ + ________ Bonus = _____________ / 45 points This is a closed...

Only one page


Version A Page 5 Name (Print please) ____________________________________________________________ Score 50 - ___________ = _____________ + ________ Bonus = _____________ / 45 points This is a closed note, closed book exam. No electronic devices of any kind may be used during the exam, including calculators. Please turn off any phones, etc. No looking at other papers is allowed. Write your answers on this paper. For multiple-choice questions, circle the correct answer clearly. If a result is a floating-point number, make sure you show a decimal point. String constants should look like strings. Write out Boolean constants as words, not as T or F. 1. (20 points) Implement a ‘Bank Account’ class in Python. The initial balance of an account should be zero. A bank account must be associated with a customer, who is represented by a first name and a last name. The bank account should support two operations: withdraw and deposit. Withdraw operation should decrease the bank balance by the specified withdrawal amount (make sure to check for negative balance!), and deposit should increase the balance by the specified amount. Answer: 2. (3 + 4 + 4 points) What is a Stack? Write the python code for the push and pop methods for a Stack implementation. Including the Stack class definition. Assume you are using a python list as the storage for the stack’s data items. Answer: 3. (3 + 4 + 4 points) Why are Queues called FIFO structures? Show using examples (with stack and queue operations) that (i) a Stack is a LIFO structure, and (ii) a Queue is a FIFO. Answer: 4. (8 points) You have a double-ended queue that contains (from front to rear) 9, 10, -10, 20, -20, 30, 1. Show the contents of the DeQueue after each of the following operations (assume they are being executed sequentially): enQ_rear(1), deQ_front(), enQ_front(5), enQ_front(15), deQ_front()
Apr 06, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here