Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Algorithms for Dummies Cheat Sheet, Cheat Sheet of Advanced Algorithms

A list of algorithms and descriptions to help you to choose whichever algorithm you need.

Typology: Cheat Sheet

2020/2021

Uploaded on 04/23/2021

shailen_555cell
shailen_555cell 🇺🇸

4.7

(19)

264 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Algorithms for Dummies Cheat Sheet
Locating the Algorithm You Need
The following table describes algorithms and algorithm types that you might find useful for
various types of data analysis.
Algorithm Description
A * Search The algorithm tracks the cost of nodes as it explores them using the
equation: f(n) = g(n) + h(n), where:
n is the node identifier
g(n) is the cost of reaching the node so far
h(n) is the estimated cost to reach the goal from the node
f(n) is the estimated cost of the path from n to the goal
The idea is to search the most promising paths first and avoid expensive paths.
Balanced Tree A kind of tree that maintains a balanced structure through reorganization so that it
can provide reduced access times. The number of elements on the left side differs
from the number on the right side by one at most.
Bidirectional
Search
This technique searches simultaneously from the root node and the goal node until
the two search paths meet in the middle. An advantage of this approach is that it’s
time efficient because it finds the solution faster than many other brute-force
solutions. In addition, it uses memory more efficiently than other approaches and
always finds a solution. The main disadvantage is complexity of implementation.
Binary Tree This is a type of tree containing nodes that connect to zero (leaf nodes), one, or
two (branch nodes) other nodes. Each node defines the three elements that it must
include to provide connectivity and store data: data storage, left connection, and
right connection.
Breadth-First
Search
This technique begins at the root node, explores each of the child nodes first, and
only then moves down to the next level. It progresses level by level until it finds a
solution. The disadvantage of this algorithm is that it must store every node in
memory, which means that it uses a considerable amount of memory for a large
number of nodes. This technique can check for duplicate nodes, which saves time,
and it always comes up with a solution.
Brute Force This is a technique of problem solving in which someone tries every possible
solution, looking for the best problem solution. Brute-force techniques do
guarantee a best-fit solution when one exists but are so time consuming to
implement that most people avoid them.
Depth-First
Search
This technique begins at the root node and explores a set of connected child nodes
until it reaches a leaf node. It progresses branch by branch until it finds a solution.
The disadvantage of this algorithm is that it can’t check for duplicate nodes, which
means that it could traverse the same node paths more than once. In fact, this
algorithm may not find a solution at all, which means that you must define a
pf3
pf4
pf5

Partial preview of the text

Download Algorithms for Dummies Cheat Sheet and more Cheat Sheet Advanced Algorithms in PDF only on Docsity!

Algorithms for Dummies Cheat Sheet

Locating the Algorithm You Need The following table describes algorithms and algorithm types that you might find useful for various types of data analysis. Algorithm Description A * Search The algorithm tracks the cost of nodes as it explores them using the equation: f(n) = g(n) + h(n) , where: n is the node identifier g(n) is the cost of reaching the node so far h(n) is the estimated cost to reach the goal from the node f(n) is the estimated cost of the path from n to the goal The idea is to search the most promising paths first and avoid expensive paths. Balanced Tree A kind of tree that maintains a balanced structure through reorganization so that it can provide reduced access times. The number of elements on the left side differs from the number on the right side by one at most. Bidirectional Search This technique searches simultaneously from the root node and the goal node until the two search paths meet in the middle. An advantage of this approach is that it’s time efficient because it finds the solution faster than many other brute-force solutions. In addition, it uses memory more efficiently than other approaches and always finds a solution. The main disadvantage is complexity of implementation. Binary Tree This is a type of tree containing nodes that connect to zero (leaf nodes), one, or two (branch nodes) other nodes. Each node defines the three elements that it must include to provide connectivity and store data: data storage, left connection, and right connection. Breadth-First Search This technique begins at the root node, explores each of the child nodes first, and only then moves down to the next level. It progresses level by level until it finds a solution. The disadvantage of this algorithm is that it must store every node in memory, which means that it uses a considerable amount of memory for a large number of nodes. This technique can check for duplicate nodes, which saves time, and it always comes up with a solution. Brute Force This is a technique of problem solving in which someone tries every possible solution, looking for the best problem solution. Brute-force techniques do guarantee a best-fit solution when one exists but are so time consuming to implement that most people avoid them. Depth-First Search This technique begins at the root node and explores a set of connected child nodes until it reaches a leaf node. It progresses branch by branch until it finds a solution. The disadvantage of this algorithm is that it can’t check for duplicate nodes, which means that it could traverse the same node paths more than once. In fact, this algorithm may not find a solution at all, which means that you must define a

cutoff point to keep the algorithm from searching infinitely. An advantage of this approach is that it’s memory efficient. Divide and Conquer This is a technique of problem solving in which the problem is broken into the smallest possible pieces and solved using the simplest approach possible. This technique saves considerable time and resources when compared to other approaches, such as brute force. However, it doesn’t always guarantee a best-fit result. Dijikstra This is an algorithm used for finding the shortest path in a directed, weighted (having positive weights) graph. Graph A graph is a sort of a tree extension. As with trees, you have nodes that connect to each other to create relationships. However, unlike binary trees, a graph can have more than one or two connections. In fact, graph nodes often have a multitude of connections. You see graphs used in places like maps for GPS and all sorts of other places for which the top-down approach of a tree won’t work. Greedy Algorithms Thistechnique of one of problem solving in which the solution relies on the best answer for every step of the problem-solving process. Greedy algorithms generally make two assumptions: Making a single optimal choice at a given step is possible. By choosing the optimal selection at each step, finding an optimal solution for the overall problem is possible. Greedy Best- First Search (BFS) The algorithm always chooses the path that is closest to the goal using the equation: f(n) = h(n). This particular algorithm can find solutions quite quickly, but it can also get stuck in loops, so many people don’t consider it an optimal approach to finding a solution. Hashing This is a method of predicting the location of a particular data item in the data structure (whatever that structure might be) before actually looking for it. This approach relies on the use of keys placed into an index. A hash function turns the key into a numeric value that the algorithm places into a hash table. A hash table provides the means to create an index that points to elements in a data structure so that an algorithm can easily predict the location of the data. Heap This is a sophisticated tree that allows data insertions into the tree structure. The use of data insertion makes sorting faster. You can further classify these trees as max heaps and min heaps, depending on the tree’s capability to immediately provide the maximum or minimum value present in the tree. Heuristics This is a technique of problem solving that relies on self-discovery and produces sufficiently useful results (not necessarily optimal, but good enough) to address a problem well enough that a better solution isn’t necessary. Self-discovery is the process of allowing the algorithm to show you a potentially useful path to a solution (but you must still count on human intuition and understanding to know whether the solution is the right one). MapReduce This is a framework for making algorithms work using computations in parallel (using multiple computers connected together in a network), allowing algorithms to complete their solutions faster.

Academy tells how this works). Generally, a formula shows the relationship between two or more variables. Most people see a formula as a special kind of equation. Algorithm A sequence of steps used to solve a problem. The sequence presents a unique method of addressing an issue by providing a particular solution. An algorithm need not represent mathematical or logical concepts, even though the presentations in this book often do fall into that category because people most commonly use algorithms in this manner. Some special formulas are also algorithms, such as the quadratic formula. For a process to represent an algorithm, it must be the following: Finite: The algorithm must eventually solve the problem. Well-defined: The series of steps must be precise and present steps that are understandable, especially by computers, which must be able to to create a usable algorithm. Effective: An algorithm must solve all cases of the problem for which someone defined it. An algorithm should always solve the problem it has to solve. Even though you should anticipate some failures, the incidence of failure is rare and occurs only in situations that are acceptable for the intended algorithm use. Amazing Ways to Use Algorithms People actually use algorithms all the time. For example, making toast is an example of an algorithm. Making toast isn’t an amazing algorithm, but the ones in the following table, which use a computer to perform tasks, are. Task Why It’s Amazing Cryptography Keeping data safe is an ongoing battle with hackers constantly attacking data sources. Algorithms enable you to analyze data, put it into some other form, and then return it to its original form later. Graph analysis The capability to decide on the shortest line between two points finds all sorts of uses. For example, in a routing problem, your GPS couldn’t function without this particular algorithm because it could never direct you along city streets using the shortest route from point A to point B. Pseudorandom number generation Imagine playing games that never varied. You start at the same place and perform the same steps in the same manner every time you play. Boring! Without the capability to generate seemingly random numbers, many computer tasks become pointless or impossible. Scheduling Making the use of resources fair to all concerned is another way in which algorithms make their presence known in a big way. For example, timing lights at intersections are no longer simple devices that count down the seconds between light changes. Modern devices consider all sorts of issues, such as the time of day, weather conditions, and flow of traffic. Scheduling comes in many forms, however. Consider how your computer runs multiple tasks at the same time. Without a scheduling algorithm, the operating system

might grab all the available resources and keep your application from doing any useful work. Searching Locating information or verifying that the information you see is the information you want is an essential task. Without this capability, many tasks you perform online wouldn’t be possible, such as finding the website on the Internet that sells the perfect coffee pot for your office. Sorting Determining the order in which to present information is important because most people today suffer from information overload, and need to reduce the onrush of data. Imagine going to Amazon, finding more than a thousand coffee pots for sale, and yet not being able to sort them according to price or most positive review. Moreover, many complex algorithms require data in the proper order to work dependably, so sorting is an important requisite for solving more problems. Transforming Converting one kind of data to another kind of data is critical to understanding and using the data effectively. For example, you might understand imperial weights just fine, but all your sources use the metric system. Converting between the two systems helps you understand the data. Likewise, the Fast Fourier Transform (FFT) converts signals between the time domain and the frequency domain, enabling things like your WiFi router to work. Dealing with Algorithm Complexity You already know that algorithms are complex. However, you need to know how complex an algorithm is because the more complex one is, the longer it takes to run. The following table helps you understand the various levels of complexity presented in order of running time (from fastest to slowest). Complexity Description Constant complexity O(1) Provides an unvarying execution time, no matter how much input you provide. Each input requires a single unit of execution time. Logarithmic complexity O(log n) The number of operations grows at a slower rate than the input, making the algorithm less efficient with small inputs and more efficient with larger ones. A typical algorithm of this class is the binary search. Linear complexity O(n) Operations grow with the input in a 1:1 ratio. A typical algorithm is iteration, when you scan input once and apply an operation to each element of it. Linearithmic complexity O(n log n) Complexity is a mix between logarithmic and linear complexity. It is typical of some smart algorithms used to order data, such as Mergesortsort, Heapsort, and Quicksort. Quadratic complexity O(n^2 ) Operations grow as a square of the number of inputs. When you have one iteration inside another iteration (called nested iterations in computer science), you have quadratic complexity. For instance, you have a list of names and, in order to find the most similar ones, you