CP114 Lecture Notes - Lecture 3: Init, Data Element, Binary Search Algorithm

40 views4 pages
School
Course
Professor

Document Summary

Monday, january 9, 2017 (cid:374)a(cid:373)i(cid:374)g (cid:272)o(cid:374)(cid:448)e(cid:374)tio(cid:374) for (cid:858)pri(cid:448)ate(cid:859) attri(cid:271)utes is _ or __ All data structures go into data_structures project (ref this) Used to hold multiple pieces of data (all same type) where class holds 1. Programs that use an adt and should be able to use different implementations of an adt interchangeably; i. e. the internal implementation of the adt should be invisible to the external program that uses it. Methods include: push, pop, peek, initialize, is empty. Methods must be defined before using a stack. Initializing an array-based stack from copy import deepcopy class stack: def __init__(self): Initializes an empty stack. self. _values = [] return. Ho(cid:449)e(cid:448)er, (cid:449)e are restri(cid:272)ti(cid:374)g the (cid:858)list(cid:859) to o(cid:374)l(cid:455) sta(cid:272)k (cid:373)ethods. Pushing items onto an array-based stack def push(self, value): Postconditions: a copy of value is added to the top of the stack. self. _values. append(deepcopy(value)) return.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents