Algorithms and Data Structures Final(14, 15, and 2)
Solutions for Storing B-Trees
. Think of each node as a pair of arrays . 1st Array = array of M - 1 elements . 2nd Array = Array of M Children . think of the tree as one large array of nodes . Elements stored in the array of children are integer indexes into the array of Nodes
Rules for B-Trees
1) The root has at least 2 subtrees, unless it is a leaf 2) Each non-root internal node holds K - 1 elements and K children where [m/2] <= K <= M 3)Each leaf holds K - 1 elements where [M/2] <= K <= M 4) All leaves are on the same level
3 properties of a Directed Tree
1. no connections from other vertices to root (single direction) 2. every non-root element has one connection to it 3. there is path from root to every other vertex
t(n) = 17 | O(1) | constant
1st level of Growth Function
Adjacent
2 vertices are _______ if there is an edge connecting them
3 forms of Multi-Way Search Tree
2-3 Trees, 2-4 Trees, and B Trees
t(n) = 3 log n | O(log n) | logarithmic
2nd level of growth function
t(n) = 20n - 4 | O(n) | linear
3rd level of growth function
t(n) = 12n log n + 100n | O(n log n) | n log n
4th level of growth function
t(n) = 3n^2 + 5n - 2 | O(n^2) | quadratic
5th level of growth function
t(n) = 8n^3 + 3n^2 | O(n^3) | cubic
6th level of growth function
Directed Graph
A Graph where ordered pairs of Vertices, and the direction is specified by the ordering of nodes (A,B from A to B)
Minimum Spanning Tree
A Spanning tree where the sum of the weights of edges is <= the sum of the weights of others.
B-tree
A _______ extends the concept of 2-3 trees and 2-4 trees so that nodes can have an arbitrary maximum number of elements.
3 Node
A _________ Contains two elements, one designated as the smaller element and one designated as the larger element. contains either no children or 3 children. the order of children is least on the left, and greatest on the right.
Multi-way Search Tree
A _____________ can have more than two children per Node, and can store more than one element in each Node.
Undirected Graph
A graph where pairings represent the edge(which are unordered); (AB/BA are the same)
Acyclic
A graph with no cycles
Dijkstra
A method for determining the shortest path, uses a minheap(or priority queue) storing vertex and weight pairs based on total weight so that we always traverse the cheapest path.
How to solve the Empty tree case of a 2-3 tree
A new node is created with a new element, and that element becomes the root.
Cycle
A path with the first and last vertices being the same, and where none of the edges are repeated
Multi-Way Search Tree
A search tree where each node might have more than two child nodes and there is a specific ordering relationship among the elements
How to solve the Inserting a new element that is a 2 Node case
A) Search the tree to find an appropriate leaf(Finding the leaf to be a 2 Node containing 1 element) B) The new element is added to a 2 Node making it a 3 Node. (making sure to put it into the proper element slot)
Secondary Storage
Access to ____ is very slow relative to access to primary storage, which is motivation to use structures such as B trees.
Secondary Storage
B-Trees were developed to address the problem of moving in and out of primary memory from _______
logM^n (M is equal to n - # of elements)
Big O for B-Trees
O(log2^n)
Big O notation for Balanced Binary Search Trees
Traversals
Can start at any vertex A) Breadth first(level order) B) Depth First(like pre-order traversal)
B Tree
Extends the concept of 2-3 trees and 2-4 trees so that Nodes can have an arbitrary maximum number of elements.
Spanning
For some Graphs, the graph itself is the ________ Tree.
Connectivity
Graph is connected if for any 2 vertices there is a path between them
Network(Weighted Graph)
Graph with weights or costs associated with each edge
Graph
Has nodes and connectors
complete graph
Has the maximum number of edges connecting vertices - 1st vertex takes n - 1 edges to connect to others - 2nd takes n - 2 - 3rd takes n - 3
Vertices
Have a name/label
Ripple Effect
Inserting an Element into a 2-3 tree can have a _____
Arrays
May Provide A better solution both within a B-tree node and for collecting B-tree nodes, because they are effective in both primary memory and secondary storage.
2-3 Trees
Multi-way search tree where each node has 0, 2, or 3 children, and each Node contains 1 or 2 elements.
Insertion/Removal of a 2-4 Tree
Similar to the Insertion and Removal for a 2-3 Tree
Triple representation
Starting Vertex, Ending Vertex, and Weight
Edges
The lines between vertices
How to solve the Inserting of a new element into a three node containing 2 elements case
The node becomes split, and the middle element is moved up, checking the balance of each node, and promoting the proper element all the way up to the root.
Sequential Access
The potential problem with B+-Trees is ________
Weight of Path
The sum of weights of edges in a path
Spanning Tree
Tree that includes all the vertices of a graph, and some (possibly not all) Edges.
B*-trees
______ have all of the same properties as a B-tree except that, instead of each node having k children where [m/2] <= K <= M. in a B*-tree, each node has K children where [(2m - 1) / 3] <= k <= m.
Nodes
________ Are called Vertices
tree
________ is a special case of a graph
Connectors
_________ Are called Edges
networks
____________ can be directed or undirected
Insertions
____________ will search the tree to see where the new element will go, then it will be inserted there.
order 3 B-tree
a 2-3 tree is a _______
order 4 B-tree
a 2-4 tree is a ________
Bi-Directional
a Directed path is not ___________
4 Node
a _______ contains three elements and has either 0 children or 4 children.
underflow
a situation in which we must rotate the tree and/or reduce the tree's height in order to maintain the properties of a 2-3 tree.
application of directed network
airfares/flights
leaves
all ______ of 2-3 trees are on the same level
leaves
all insertions into a 2-3 tree occur as _________ of the tree
Connected
an Undirected graph is ______ if for any two vertices there is a path between them
self loop
an edge connects a vertex to itself
2 Node
contains one element and, as in a Binary search tree, the left subtree contains elements that are less than that element, and the right subtree contains elements that are greater than or equal to that element.
Directed Tree
directed graph that has an element designated as a root
B*-Tree
each non-root of a _____ is at least 2/3 full. -Accomplished by delaying the splitting of nodes by re-balancing across siblings. once the siblings are full, split 2 Nodes into 3 Nodes.)
2-4 Tree
expands on the concept of 2-3 trees to include the use of 4 nodes and each node can contain 3 elements.
t(n) = 2^n + 18n^2 + 3n | O(2^N) | Exponential
final level of growth function
Propogation Effect
if the _________ of a 2-3 tree insertion causes the root to split, the tree increases in Height
B+-trees
in a _______, each element appears in a leaf, regardless of whether or not it appears in an internal node. Elements appearing in an internal node will be listed again as the in-order successor(which is a leaf) of their position in the internal node.each leaf node will be a pointer for the the following leaf node, which allows for indexing and sequential access through a linked list of leaves.
Ordering Property of a 2-4 Tree
left Child < Left most element of Node <2nd < 3rd < 4th
Element is a 3 Node Leaf, 2 Node leaf, or an internal node.
the 3 cases for removing an element from a 2-3 Tree.
B-tree, B*-tree, and B+-tree
the 3 types of B-tree are _______
connected
the graph is _________ if, and only if, for each vertex in the graph of n vertices, the size of the result of breadth first traversal is N.
length of path
the number of edges in a path
path
the sequence of edges that connect 2 seperate vertices
Empty tree, Inserting 2-node, and Inserting an element into a 3 Node that has two elements.
the three special cases of inserting into a 2-3 Tree
n(n - 1)/2
undirected graphs with n vertices require ________ edges to be complete
Consideration
use of a secondary storage device - no longer is time to access element function of comparison - we must consider access time
Topological Order
when the graph is ordered so that one node Proceeds another(like pre-reqs)