Please enable JavaScript.
Coggle requires JavaScript to display documents.
ITP 365 Final Prep (Data Types (Vector (Functions and their Big Os (push…
ITP 365 Final Prep
Data Types
-
-
-
-
Tree
-
To insert, if the item is larger than the current node, go right. If it is smaller go left
If can go no deeper, add the item at the empty space
-
Graph
Similar to a tree with nodes connecting to other nodes, bot nodes can have cycles
-
Can be weighted, where paths have a value
-
-
Iterators
-
Used for erase, insert, and ranged based For Loops
Requires a Begin pointing to the first item and an End pointing to after the last item to be used for a For Loop
Both are functions which are part of the list, but are not the iterator. They return the iterator, but are not the Iterator itself
-
Functions and syntax
-
-
erase: iterator = list.erase(iterator); Erases a specific item and returns the next item, or end if no such item exists
insert: list.insert (iterator); Inserts an item or items into the list, and returns the first of the newly inserted items
-
Pointers
-
-
-
-
nullptr = sets the point to null (NOT 0, because 0 would be a valid memory address)
Types of copies
-
Deep Copy: Copies the values, and creates new instances of variables on the heap
-
Algorithms
Insertion Sort
-
Each new item to be sorted is placed in the appropriate place in the sorted sublist until the entire list is sorted
Example : 5,9,6 > (5) 9,6 > (5,9) 6 > (5, 6. 9)
-
Compare the new item to the sublist starting at the beginning. If it is lower then check the next higher item. If it is larger then insert before the item. If it is smaller are there are no higher items, then add at the end
Binary Search
-
-
-
-
If the retrieved item is the item being searched for, then return that item
-
If begin > item being searched for, then the item was not found
-
-
Dijkstra's Algorithm
-
Uses a hashmap for fast lookup for the Closed Sort and a priority_queue for the Open Set, where the item with the lowest value is the first in the queue
-
-
Quicksort
Loop through all the remaining items, take the smallest one, and add it to the end of the sublist
-
-
-
Rule of 3
If you need to implement any one of these three functions, you are working with dynamic memory and so should implement the other two
-
-
-
Operator Overloading
-
Output Operator
friend ostream& operator<<(ostream& os, const T& t)
ostream& operator<<(ostream& os, const T& t)
-
-
-
-
-