DSA 3: Algorithms & Strategies
Selection sort
In this algorithm, the smallest value in the array is located and moved to index 0. Then the next smallest value is located and moved to index 1. This process continues until all of the elements have been placed in their proper order.
Linear search
Finds an element in a list by sequentially checking each item until a match is found.
Brute-force
Algorithm strategy consisting of systematically enumerating and testing every possible candidate solution.
Bucket sort
This algorithm works by distributing the elements of an array into a number of containers. Each container is then sorted individually, and the sorted contents are then gathered, in order, to build the sorted array.
Merge sort
This divide and conquer algorithm sorts an array (or list). It recursively divides an input array in two halves, sorts them individually, then merges the sorted halves.
Bubble sort
This is a brute force algorithm that repeatedly swaps adjacent elements of an array or list that are out of order, until the list is ordered.
Heap sort
Iteratively shrinks an unsorted set of values by extracting the smallest element and moving it into the sorted region. It will make use of a heap structure to find the minimum.
brute-force
This algorithm strategy tries to find the correct solution by trying every possible solution until it happens to find a correct one.
Hash search
Finds an element in a collection by producing a unique index based on the element key and retrieving the element at the produced index of the collection.
Binary search
Finds an element in a sorted list by dividing it in half and comparing the target value with the middle value. If not equal, repeat recursively on the left/right half, until a match or null is found.
Depth-first search
Finds an element in a tree or graph by starting at a root and exploring elements as far as possible along each branch before backtracking.
Breadth-first search
Finds an element in a tree or graph by starting at a root and exploring elements at the same level before moving to another depth level.
greedy
Identify the algorithm strategy employed by Dijkstra's shortest path algorithm.
greedy
Identify the algorithm strategy employed by Prim's minimum spanning tree algorithm.
brute-force
Identify the algorithm strategy employed by a program that attempts to crack a password by trying every possible combination of characters.
brute-force
Identify the algorithm strategy employed by a program that enumerates all integers from 1 to n, in order to find all of the integer divisors of n.
greedy
Identify the algorithm strategy employed by an algorithm that finds the shortest path between a given source node and every other node in the graph. The algorithm builds a set of vertices by repeatedly selecting the vertex with the minimum shortest-path estimate, adding this vertex to the set, and "relaxing" all edges leaving that vertex, until all vertices have been included.
divide-and-conquer
Identify the algorithm strategy employed by the Merge Sort algorithm.
Radix sort
This algorithm can sort a list of numbers by following this three step process. (1) Start with the least significant digit of each key. (2) Group the keys based on that digit, but otherwise keep the original order of keys. (3) Collect the groups in the order of the digits and repeat the grouping process with each more significant digit.
Linear search
This algorithm finds an element within a list. It sequentially checks each element of the list until a match is found or the whole list has been searched.
Dijkstra's SPF algorithm
This algorithm solves the single-source shortest-paths problem on a weighted, directed graph in which all edge weights are nonnegative. The algorithm finds the shortest path between a given source node and every other node in the graph. The algorithm builds a set of vertices by repeatedly selecting the vertex with the minimum shortest-path estimate, adding this vertex to the set, and "relaxing" all edges leaving that vertex, until all vertices have been included.
Insertion sort
This algorithm sorts an array (or list) one item at a time. At each iteration, the algorithm moves one element from its initial position in the list, to the location it belongs within the sorted list.
Quicksort
A divide and conquer algorithm that partitions two empty arrays to hold elements less than the pivot value and elements greater than the pivot value, and then recursively sort the sub arrays.
Prim's MST algorithm
A greedy algorithm for producing a minimum-spanning tree from an undirected weighted graph by picking an arbitrary vertex, then repeatedly picking the subsequent smallest weight edge to the next unvisited vertex until all vertices are connected.
Kruskal's MST algorithm
A greedy algorithm for producing a minimum-spanning tree from an undirected weighted graph by repeatedly picking the smallest weight edge without creating a cycle until all vertices are connected.
Dijkstra's SPF algorithm
A greedy algorithm that determines the shortest path from one vertex to all other vertices in a graph by repeatedly picking the subsequent smallest weight edge to an unvisited vertex and memoizing the smallest total cost to reach each vertex until all vertices are connected.
Dynamic programming
Algorithm strategy that divides the main problem into smaller/similar subproblems but also memoizes the solutions to overlapping subproblems and applies stored solutions to subsequent repeat subproblems.
Divide-and-conquer
Algorithm strategy that divides the main problem into smaller/similar subproblems, recursively solves them, and combines them into a main solution.
Greedy
Algorithm strategy that finds the locally optimal solution at each step in an attempt to find the globally optimal solution.
greedy
This algorithm strategy always makes a locally optimal choice in the hope that this choice will lead to a globally optimal solution, but it does not always yield a globally optimal solution.