$ py.test
Resources: Wikipedia - Binary Heap - Max-Heapify Pop Algorithm
BinaryHeap([iterable=(), btype='max' or 'min'])
Functions:
- insert(val) - Insert a value to add to the heap which places it in the correct location
- pop() - Return and remove the top-most value of the heap
Insertions and deletions will cause the tree to check whether it is currently balanced and rotate if necessary to rebalance.
Resources: Interactive Python, Wikipedia
BinarySearchTree([value=None])
Functions:
- insert(val) - Insert a value into the BST, creating a new BST node and placing it in the correct location. If the tree becomes imbalanced, tree will rotate until it becomes balanced.
- contains(val) - Return True or False whether val is contained in the BST
- size() - Return size (or number of nodes) in the BST
- depth() - Return depth/height of the BST
- balance() - Return integer indicating balance of BST: 0 for balanced, negatives for left-leaning, positive for right-leaning
- delete(val) - Remove specified value from BST if it exists. If the tree becomes imbalanced, tree will rotate until it becomes balanced.
DoublyLinkedList()
Functions:
- insert(val) - Add a node to the beginning of the DLL
- append(val) - Add a node do the end of the DLL
- pop() - Remove and return first node of the list
- shift() - Remove and return the last node of the list
- remove(val) - Remove and return the first node in the list with the specified value
Create a hash table with specified size using a hash algorithm based off the ordinal character number, the inded of the list, and the size of the list
HashTable(size)
Functions:
- get(key) - return hashed value associated with key
- set(key, val) - set a value to a key by adding it to a hashed list
insertion_sort(array) - Returns sorted array
Linked_list([*args]) - initial list optional
Functions:
- pop() - Remove first node of linked list
- insert(data) - insert data to head of linked list
- size() - Return size of linked list
- search(data) - Return node containing data in linked list if exists, otherwise None
- remove(data) - Remove first node with this data value in this list.
- print_tuple() - Print entire linked list as a tuple literal
merge_sort(array)
parentheses(text)
- 1 - if input text has open parentheses (more are open than closed)
- 0 - if input text has closed parentheses (there are an equal number)
- -1 - if the input text has broken parentheses (there are more closed than open)
PriorityQ()
Functions:
- insert(priority, value) - Insert a value with specified priority into the queue
- peek() - Return highest priority value without removing from the queue
- pop() - Return and remove the highest priority valuue from the queue
Functions:
- enqueue(value) - add value to the end of the queue
- dequeue() - removes and returns first value in queue
- size() - returns the size of the queue
quick_sort(array)
radix_sort(array)
Resources: Bellman-Ford, Dikstra's algorithm
Graph()
Functions:
- nodes() - Return list of all node values in graph
- edges() - Return list of all edges' node values as tuples
- add_node(node_val) - Add a new node value to the graph if it does not yet exist
- add_edge(n1, n2[, weight=None]) - add an edge with given node vals and optional weight
- del_node(n) - Remove node with given value from graph
- del(edge(n1, n2) - Remove edge connecting two node values
- has_node(n) - Return True or False whether graph contains node with specified value
- neighbors(n) - Return values of nodes connected to given node
- adjacent(n1, n2) - Return True or Faulse whether nodes are connected or not
- depth_first_traversal(start) - Returns traversal path from start to finish by searching depth first
- breadth_first_traversal(start) - Return traversal path from start to finish by searching breadth first
- weight_edge(n1, n2) - Return the weight of the edge connecting given nodes
- dikstra(start) - Return shortest path by following Dikstra's algorithm
- bellman_ford(start) - Return weight and predecessors of following a Bellman-Ford path
Stack()
Functions:
- push(data) - Add data to the stack
- pop() - Remove top item from the stack