CPSC 319 Lecture Notes - Lecture 6: Binary Tree, Priority Queue, Increment And Decrement Operators

66 views3 pages

Document Summary

Are analogous to plate storage devices seen in restaurants. Are last in, first out (lifo) queues. Are linear data structures which can only be accessed at the top using push and pop. Push: store an element on the top of the stack. If the stack has a maximum size, you cannot push when the stack is full. Pop: remove and return the element on the top of the stack: you cannot pop an empty stack. May implement additional operations to: return the top element without popping, clear the entire stack, check if the stack is full, check if the stack is empty. Stacks may be implemented using arrays: must use a variable to point to the top. Will initially be set to -1, to indicate an empty stack. E. g. int top = -1: will have a maximum size. Unless a resizable array (vector) is used: to push, increment top, and store the element at that position in the array.

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