1.3 Fundamentals of algorithms Flashcards
Define implementation
Creating code to produce a programmed solution
Define depth first graph traversal
A method for traversing a graph that starts at a chosen node and explores as far as possible along each branch away from the starting node before backtracking to visit unvisited nodes. It is often implemented with a recursive algorithm
Define breadth first graph traversal
A method for traversing a graph that explores nodes closest to the starting node first before progressively exploring nodes that are further away. A queue is used to keep track of the nodes to visit
What are the 3 ways of traversing a binary tree and their uses?
- Pre-order: Can be used with expression trees to evaluate the expression using prefix notation
- In-order: The equivalent of a binary search of the tree
- Post-order: Will produce Reverse Polish Notation
Define traversal
The process of reading data from a tree or graph by visiting all of the nodes
Define pre-order traversal
A method of traversing a tree by visiting the root, traversing the left subtree, and traversing the right subtree
Define in-order traversal
A method of traversing a tree by traversing the left subtree, visiting the root, and traversing the right subtree
Define post-order traversal
A method of traversing a tree by traversing the left subtree, traversing the right subtree, and then visiting the root
What are base and general cases of recursion?
A base case of a recursive function is the point at which the function will stop calling itself. The general cases of a recursive function are all the other cases of the function where it calls itself
Define single source
In the Dijkstra’s algorithm it means that the shortest path is calculated from a single starting point
Define shortest path
The shortest distance between two vertices based on the weighting of the edges
Define linear search
A simple search technique that looks through data one item at a time until the search term is found
Define binary search
A technique for searching ordered data that works by splitting datasets in half repeatedly until the search data is found
Define binary tree search
A technique for searching a binary tree that traverses the tree until the search term is found - it will move down the tree depending on if the target node is expected to be found on the left or right of the current node
Define infix notation
Expressions that are written with the operators within the operands