CP104 Lecture Notes - Lecture 6: Double-Ended Queue, Data Element, Iterator

172 views6 pages
17 Jun 2017
School
Course
Professor
hayjayshay and 38575 others unlocked
CP104 Full Course Notes
2
CP104 Full Course Notes
Verified Note
2 documents

Document Summary

__updated__ = 2017-03-03 from copy import deepcopy class _dequenode: def __init__(self, value, _prev, _next): Preconditions: value - data value for node (?) Initializes a deque node that contains a copy of value and links to the previous and next nodes in the deque. self. _data = deepcopy(value) self. _prev = _prev self. _next = _next return class deque: def __init__(self): Initializes an empty deque. self. _front = none self. _rear = none self. _next = none self. _count = 0 return def is_empty(self): True if the deque is empty, false otherwise. return self. _front is none def __len__(self): Postconditions: returns the number of values in the deque. return self. _count def insert_front(self, value): Inserts a copy of value into the front of the deque. Inserts a copy of value into the rear of the deque. Removes and returns value from the front of the deque. Removes and returns value from the rear of the deque.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents