Data Structures
Created by Mike Chase and Josh Cowden
Created by Mike Chase and Josh Cowden
Before the exam:
After the exam:
All PowerPoint slides on and after 3-24-20
JOSH EMAIL YOUR ADVISOR AND GET THE CODE
This website was created for CPS 350 as a review for everything we've learned as of March 25, 2020. Because of the corona virus, this test became open-note so if we put in the work now we can use this on the test!
This website is organized into __ different sections, all outlined below.
Logical Operators
Loops: For each, while, do-while, for-each.
Primitive Variables
Getting User Input
Classes: subclasses and superclasses usage, abstract classes/methods, concrete classes (stuff you can make objects of)
Inheritance, Dynamic Lookup Method, Polymorphism, Overloading/Overriding
Objects (String) (Nuke++)
Methods:
private, package, public, protected (child can access it, but not public).
Return types: objects, primitives, a class, strings
Packages (Our autcomplete has its own package of classes; like java.util... we import it).
Interfaces (Mike Chase is terrible with them)
Make Sure to Hyperlink to Comparable/Comparator under Data Structures
Variables: Instance, Local Primitives, References, Default Values, Scope
Integer overflow.
Memory Allocation: Stacks vs. Heaps, Address Space (1-21-20), Lifetime of Objets)
Generic Classes & Components (ie. Type <T>, <Key>), Generic Stacks, Tight Type Checks, Type Safety, Type Casts, Unchecked Cast, Generic Array Implementation, Type Erasure, Autoboxing (Automatic Cast), Wrapper Object Type
Post-Fix
Exceptions: Dealing with unexpected errors
Catching exceptions
Errors vs. Exceptions
Try/Catch Blocks
throws keyword & Postpone handling.
The finally block
Extending existing exception classes & defining your own.
Iterators (from 1-28-20 powerpoint)
The Iterator interface (methods: hasNext(), next()
The Iterable interface
ArrayLists
LinkedLists
TreeMap
PriorityQueue
Methods: add, contains, etc.
Proof by Induction
Show examples
Prove the base case, Something with P(k), prove the induction case
How to prove the running time of recursive functions (like MergeSort 2-18-20)
Formal Proofs
Computing Discrete Sums
Big Oh Notation
Recurrence Relations (How to do proof by induction); see #1.
How to solve for them.
Show examples
Eliminating low-order terms and coefficients
Space Complexity
Object References are 8-bytes
Chars are 2 bytes
Ints are 4 bytes
How to calculate space for arrays & addition entries.
Calculating space for obects
What is padding
Arrays
Circular Arrays- Start Index and End Index
Array Lists
Linked Lists & Nodes
Queues (Impelemented via Arrays and Linked Lists)
Priority Queues: (As trees)
Binary Search Trees- Binary Trees that use a binary sort algorithm
Self-Balancing Binary Search Trees
Heaps
Hash Tables
Graphs
Disjoint Sets
Trees
Complete vs. Incomplete (what that means)
How heaps use complete binary trees
Height
Leafs
Binary min-heap (aka binary heap)
Binary Heap API Public Methods
Requirement: items are generic and comparable
Duplicate keys are allowed.
"Heap property" (Percolate up)
Operations: min (returns root.data), insert, deleteMin, insert
How to insert one more node & the trace.
How to restore the heap property.
Array representation of the binary heap
In a complete binary tree, you can specify parent/children/left and right childs by using multiplication and division. (ie. left child is i*2) "No left child behind."
Terminology: Abstract Data Types
What does In-Place & Stable Mean
Insertion Sort
Selection Sort:
Merge Sort
Divide and Conqueor
Partitioning
Merging
3-Way Partitioning
Show the recursion somehow
Practical Improvements
Bottom-Up Mergesort
Use insertion sort for small subarrays (<10 items).
Quick Sort
Terminology: Pivot, Partition, lows and hi's,
Improvements
Chose the median of the sample.
Three Way Quicksort Dijkstra (Improves efficiency if there are many duplicates).
Linear Sort
Has to be a primitive (number or character).
What are keys?
Deals with the frequency
Radix Sort (doesn't matter) (specialization of lexiciographic-sort; uses bucket sort) 2-27.
Bucket Sort
Key-Indexed counting
Heap Sort (Related to priority queues?)
Smaller keys mean higher priority
Operations insert(Key k); Key deleteMin(); boolean isEmpty();
Run time when ordered & unordered for which sort.
What does a comparison sort mean?
Types of orders: Standard (numbers), Chronological (dates or times), Lexicographic (Strings)
The Comparable Interface (Using default, natural ordering)
Bult-In Types: Integer, Double, String, Date
User-Defined Comparable Types: Date data type
Implementing the Comparable Interface
The Comparator Interface (Using an alternative ordering)
Implemting an interface
Compare() Methods
Arrays.sort
Stable & Unstable Sorts: Preserves the Relative Order; talk about each algorithm
In-Place: Making more arrrays or not
Auxillary Arrays
Does it use extra space (yes if not stable).
For Each Algorithm, list:
Best-case
Worst-case
Average-case
Time complexity
Space Complexity
Stabe/Instable
In-place: (A sorting algorithm is in-place if it uses ≤ c log(N) extra memory.
Linear Search: Run time, implementations
Binary Search
Binary Search Trees
For the future!