Algorithms - Princeton University
Algorithms
ROBERT SEDGEWICK | KEVIN WAYNE
Algorithms FOURTH EDITION
ROBERT SEDGEWICK | KEVIN WAYNE
1.3 BAGS, QUEUES, AND STACKS
stacks resizing arrays queues generics iterators applications
Stacks and queues
Fundamental data types.
Value: collection of objects. Operations: insert, remove, iterate, test if empty. Intent is clear when we insert. Which item do we remove?
stack
enqueue
queue
push pop
dequeue
Stack. Examine the item most recently added. Queue. Examine the item least recently added.
LIFO = "last in first out" FIFO = "first in first out"
2
Client, implementation, interface
Separate interface and implementation. Ex: stack, queue, bag, priority queue, symbol table, union-find, ....
Benefits.
Client can't know details of implementation
client has many implementation from which to choose.
Implementation can't know details of client needs
many clients can re-use the same implementation.
Design: creates modular, reusable libraries. Performance: use optimized implementation where it matters.
Client: program using operations defined in interface. Implementation: actual code implementing operations. Interface: description of data type, basic operations.
3
Algorithms
ROBERT SEDGEWICK | KEVIN WAYNE
1.3 BAGS, QUEUES, AND STACKS
stacks resizing arrays queues generics iterators applications
Stack API
Warmup API. Stack of strings data type.
public class StackOfStrings StackOfStrings()
void push(String item) String pop() boolean isEmpty()
int size()
create an empty stack
insert a new string onto stack remove and return the string
most recently added is the stack empty?
number of strings on the stack
push pop
Warmup client. Reverse sequence of strings from standard input.
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- cmsc 341 lecture 7 stl containers iterators algorithms
- amd raid configuration guide
- javascript arrays object biggest online tutorials library
- algorithms princeton university
- csc 273 data structures adelphi university
- powershell basic cheat sheet rambling cookie monster
- mathcad tutorial university of connecticut
- lab 6k a shopping cart using the class lab 6k a shopping cart using
- java built in arrays university of san francisco
- big o arraylist carnegie mellon university
Related searches
- princeton community hospital princeton wv
- princeton university admissions staff
- princeton university hospital princeton nj
- university medical center princeton nj
- princeton hospital princeton nj
- acls algorithms 2019
- acls algorithms pdf
- university of scranton princeton review
- princeton medical center princeton nj
- princeton review university rankings
- princeton university acceptance rate
- princeton university acceptance