CPSC 350 Final Exam Graded A+
Array benefits - ANSWER-It is better and convenient way of storing the data of same
datatype with same size. It allows us to store known number of elements in it.
Array Big-O runtimes (access, insert, search, delete) - ANSWER-access = O(1)
insert = O(n)
search = O(n)
delete = o(n)
Array disadvantages - ANSWER-- is a static Data structure
-We must know in advance that how many elements are to be stored in array. Only
elements of same data types can be stored in an array. We cannot store elements of
multiple data types in a single array.
Arrays - ANSWER-a collection of items stored in a contiguous memory location and
addressed using one or more indices
AVL trees - ANSWER-- Adelson-Velskii & Landis: Any pair of sibling nodes have a
height difference of at most
- not commonly used in industry
Balanced/Unbalanced BST's - ANSWER-- We will say that a tree is height-balanced if
the heights of the left and right subtrees of each node are within 1
- A tree is perfectly height-balanced if the left and right subtrees of any node are the
same height
Big-O for Linked List (access, insert, search, delete) - ANSWER-access = O(n)
insert = O(1)
search = O(n)
delete = o(1)
Binary Search Tree BST - ANSWER-- Each internal node has at most two children
- Values smaller than the root, left subtree
- Values greater than the root, right subtree
- Each node (vertex) must have exactly one path (edge) to another node
If not, then it's a graph
- The number of children of a given node is called a degree
- Is allows for efficient sorting and searching of data.
- log(N)
Breadth-first search - ANSWER-- We examine all nodes at the same level of the tree
before moving on to the next level
- Finding shortest paths
, - Used for disconverting spanning trees
- Requires more memory than DFS
- uses a Queue
- divides graph into levels
- better for broader graphs
BST advantages - ANSWER-- BST has fast insertion and deletion when balanced
- very efficient
BST disadvantages - ANSWER-- shape of tree determines on insertion and can be
degenerated
- search takes a long time
BubbleSort - ANSWER-- compares 2 numbers
- if the one on the left is bigger, swap
- performance, pretty lousy O(N^2)
- best O(n)
- use when you don't have access to internet and not a large data set
circular Queues - ANSWER-The used memory locations, when free are reused so no
memory is leaked
ex: round Robin schedulers
Depth-first search - ANSWER-- useful for finding whether there is a path from one
vertex to another and whether or not the graph is connected
- in terms of running time, DFS is an efficient method for transversing a graph
- use stack
- checks graph for cycles
- traverses deep into graph by visiting children nodes before sibling/neighbor nodes
- requires less memory
difference between Graphs and trees - ANSWER-- trees are a type of graph
- no loops in trees
- numerous rules in spelling out connections in trees, graph has not rules dictating
connections among nodes
Dijkstra's algorithm - ANSWER-- finds the optimal path from a source vertex to and
endpoint,
Single source
- graph can be a directed or undirected weight graph
- graph needs to have a nonnegative weight on every edge
- used in Google Maps
Dijkstra's algorithm disadvantages - ANSWER-- It do blind search so wastes lot of time
while processing.
Array benefits - ANSWER-It is better and convenient way of storing the data of same
datatype with same size. It allows us to store known number of elements in it.
Array Big-O runtimes (access, insert, search, delete) - ANSWER-access = O(1)
insert = O(n)
search = O(n)
delete = o(n)
Array disadvantages - ANSWER-- is a static Data structure
-We must know in advance that how many elements are to be stored in array. Only
elements of same data types can be stored in an array. We cannot store elements of
multiple data types in a single array.
Arrays - ANSWER-a collection of items stored in a contiguous memory location and
addressed using one or more indices
AVL trees - ANSWER-- Adelson-Velskii & Landis: Any pair of sibling nodes have a
height difference of at most
- not commonly used in industry
Balanced/Unbalanced BST's - ANSWER-- We will say that a tree is height-balanced if
the heights of the left and right subtrees of each node are within 1
- A tree is perfectly height-balanced if the left and right subtrees of any node are the
same height
Big-O for Linked List (access, insert, search, delete) - ANSWER-access = O(n)
insert = O(1)
search = O(n)
delete = o(1)
Binary Search Tree BST - ANSWER-- Each internal node has at most two children
- Values smaller than the root, left subtree
- Values greater than the root, right subtree
- Each node (vertex) must have exactly one path (edge) to another node
If not, then it's a graph
- The number of children of a given node is called a degree
- Is allows for efficient sorting and searching of data.
- log(N)
Breadth-first search - ANSWER-- We examine all nodes at the same level of the tree
before moving on to the next level
- Finding shortest paths
, - Used for disconverting spanning trees
- Requires more memory than DFS
- uses a Queue
- divides graph into levels
- better for broader graphs
BST advantages - ANSWER-- BST has fast insertion and deletion when balanced
- very efficient
BST disadvantages - ANSWER-- shape of tree determines on insertion and can be
degenerated
- search takes a long time
BubbleSort - ANSWER-- compares 2 numbers
- if the one on the left is bigger, swap
- performance, pretty lousy O(N^2)
- best O(n)
- use when you don't have access to internet and not a large data set
circular Queues - ANSWER-The used memory locations, when free are reused so no
memory is leaked
ex: round Robin schedulers
Depth-first search - ANSWER-- useful for finding whether there is a path from one
vertex to another and whether or not the graph is connected
- in terms of running time, DFS is an efficient method for transversing a graph
- use stack
- checks graph for cycles
- traverses deep into graph by visiting children nodes before sibling/neighbor nodes
- requires less memory
difference between Graphs and trees - ANSWER-- trees are a type of graph
- no loops in trees
- numerous rules in spelling out connections in trees, graph has not rules dictating
connections among nodes
Dijkstra's algorithm - ANSWER-- finds the optimal path from a source vertex to and
endpoint,
Single source
- graph can be a directed or undirected weight graph
- graph needs to have a nonnegative weight on every edge
- used in Google Maps
Dijkstra's algorithm disadvantages - ANSWER-- It do blind search so wastes lot of time
while processing.