How do you test for an empty priority queue?
Check if the size of the queue is 0 or if the front pointer is equal to the rear pointer.
How do you test for a full priority queue?
Check if the rear pointer is at the last index of the array (size - 1)
uses of graphs
differences between tree and graph
what are edges/arcs
the paths that link nodes together
a graph with more edges than vertices is called
a graph with less edges than vertices is called
a dense graph
a sparse graph
directed vs undirected graphs
where the edges go in one direction
undirected - all the edges are biderectional (arrowheads on both heads)
how to represent:
- vertices
- edges
- edges with weights
vertices - inside curly brackets, eg {A,B,C,D,E,F}
edges - {(A,B),(A,C), (B,E), (C,A)}
edges with weights -
{ (A,B,8), (A,C,2), (B,E,4) }
adjacency matrix
adjacency list
advantages and disadvantages of adjacency matrixes
however:
- if theres many nodes and few edges, it may result in empty space (wasted memory) and problem gets worse as size of the graph increases
- if matrix is implemented as a static 2D array, it can be hard to add or delete nodes
advantages of adjacency lists
what is a tree
a connected, unweighted, undirected graph with no cycles
what is a root node
the node at the top of the tree
what are the children of a tree
the node next down the structure
what are branches
the lines that join nodes together
what are leaf nodes
nodes without any sub nodes/children
describe the operations of a binary tree
explain the circumstances in which it is more appropriate to represent a graph using an adjacency list instead of an adjacency matrix
what is a weighted graph
a graph where each edge has a value associated with it
what is a directed graph
a graph where edges have a direction, going from one vertex (node) to another.
whys bubble sort seen as inefficient
It is inefficient because it repeatedly compares adjacent elements and has O(n²) time complexity
Bubble sort uses nested loops to compare and swap adjacent elements. The outer loop iterates through the list multiple times
what is a data structure
a way of organizing and storing data