|
Published:
May 3, 2022

Algorithms For Dummies

Overview

Your secret weapon to understanding—and using!—one of the most powerful influences in the world today

From your Facebook News Feed to your most recent insurance premiums—even making toast!—algorithms play a role in virtually everything that happens in modern society and in your personal life. And while they can seem complicated from a distance, the reality is that, with a little help, anyone can understand—and even use—these powerful problem-solving tools!

In Algorithms For Dummies, you'll discover the basics of algorithms, including what they are, how they work, where you can find them (spoiler alert: everywhere!), who invented the most important ones in use today (a Greek

philosopher is involved), and how to create them yourself.

You'll also find:

  • Dozens of graphs and charts that help you understand the inner workings of algorithms
  • Links to an online repository called GitHub for constant access to updated code
  • Step-by-step instructions on how to use Google Colaboratory, a zero-setup coding environment that runs right from your browser

Whether you're a curious internet user wondering how Google seems to always know the right answer to your question or a beginning computer science student looking for a head start on your next class, Algorithms For Dummies is the can't-miss resource you've been waiting for.

Read More

About The Author

John Mueller has published more than 100 books on technology, data, and programming. John has a website and blog where he writes articles on technology and offers assistance alongside his published books.

Luca Massaron is a data scientist specializing in insurance and finance. A Google Developer Expert in machine learning, he has been involved in quantitative analysis and algorithms since 2000.

Sample Chapters

algorithms for dummies

CHEAT SHEET

Algorithms are fun! Algorithms are beautiful! Algorithms are even better than your favorite pastime! Well, perhaps not the last one. In fact, algorithms surround you in many ways you might not have thought about, and you use them every day to perform important tasks.However, you need to be able to use algorithms in a way that doesn’t involve becoming a mathematician.

HAVE THIS BOOK?

Articles from
the book

Algorithms have indeed been around for centuries, so you'd think that scientists would have discovered and solved every algorithm by now. Unfortunately, the opposite is true. Solving a particular algorithm often presents a few more questions that the algorithm doesn't solve and that didn't seem apparent until someone did come up with the solution.
Algorithms today appear everywhere, and you might not even realize just how much effect they have on your life. Most people realize that online stores and other sales venues rely on algorithms to determine which add-on products to suggest based on previous purchases. However, most people are unaware of the uses of algorithms in medicine, many of which help a doctor decide what diagnosis to provide.
Structure is an essential element in making algorithms work. An essential need to meet as part of working with data is to understand the data content. A search algorithm works only when you understand the dataset so that you know what to search for using the algorithm.Looking for words when the dataset contains numbers is an impossible task that always results in errors.
Algorithms are fun! Algorithms are beautiful! Algorithms are even better than your favorite pastime! Well, perhaps not the last one. In fact, algorithms surround you in many ways you might not have thought about, and you use them every day to perform important tasks.However, you need to be able to use algorithms in a way that doesn’t involve becoming a mathematician.
Often, you find that a heuristic approach, one that relies on self-discovery and produces sufficiently useful results (not necessarily optimal, but good enough) is the method you actually need to solve a problem. Getting the algorithm to perform some of the required work for you saves time and effort because you can create algorithms that see patterns better than humans do.
People actually use algorithms all the time. For example, making toast is an example of an algorithm, as explained in this blog post. 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.
Streaming data needs streaming algorithms, and the key thing to know about streaming algorithms is that, apart a few measures that it can compute exactly, a streaming algorithm necessarily provides approximate results. The algorithm output is almost correct, guessing not the precisely right answer, but close to it.
Greedy reasoning is often used as part of an optimization process. The algorithm views the problem one step at a time and focuses just on the step at hand. Every greedy algorithm makes two assumptions: You can make a single optimal choice at a given step. By choosing the optimal selection at each step, you can find an optimal solution for the overall problem.
A brute-force solution is one in which you try each possible answer, one at a time, to locate the best possible answer. It's thorough, this much is certain, but it also wastes time and resources in most cases. Testing every answer, even when it's easy to prove that a particular answer has no chance of success, wastes time that an algorithm can use on answers that have a better chance of success.
Scientists began fighting against impressive amounts of data for years before anyone coined the term big data. At this point, the Internet didn’t produce the vast sums for data that it does today. It’s useful to remember that big data is not just simply a fad created by software and hardware vendors but has a basis in many of the following fields: Astronomy: Consider the data received from spacecraft on a mission (such as Voyager or Galileo) and all the data received from radio telescopes, which are specialized antennas used to receive radio waves from astronomical bodies.
A special kind of tree structure is the binary heap, which places each of the node elements in a special order. Search trees enable you to look for data quickly. Obtaining data items, placing them in sorted order in a tree, and then searching that tree is one of the faster ways to find information.In a binary heap, the root node always contains the smallest value.
People tend to form communities — clusters of other people who have like ideas and sentiments. By studying these clusters, attributing certain behaviors to the group as a whole becomes easier (although attributing the behavior to an individual is both dangerous and unreliable).The idea behind the study of clusters is that if a connection exists between people, they often have a common set of ideas and goals.
Learning to count objects in a stream can help you find the most frequent items or rank usual and unusual events. This algorithm leverages hash functions and approximate sketches. It does so after filtering duplicated objects and counting distinct elements that have appeared in the data stream.You use this technique to solve problems like finding the most frequent queries in a search engine, the bestselling items from an online retailer, the highly popular pages in a website, or the most volatile stocks (by counting the times a stock is sold and bought).
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.
If you're like most people, you often find yourself scratching your head when it comes to math structures because no one seems to know how to use the terms correctly. It's as though people are purposely trying to make things hard! After all, what is an equation and why is it different from an algorithm? Well, fear no more: The following table provides the definitive guide to math structures that you might encounter but have been afraid to ask about.
Generally, you create Bloom filters for algorithms of a fixed size (recently developed versions allow you to resize the filter). You operate them by adding new elements to the filter and looking them up when already present. It's not possible to remove an element from the filter after adding it (the filter has an indelible memory).
The human race is now at an incredible intersection of unprecedented volumes of data, generated by increasingly smaller and powerful hardware, and analyzed by algorithms that this same process helped develop. It's not simply a matter of volume, which by itself is a difficult challenge.As formalized by the research company Gartner in 2001 and then reprised and expanded by other companies, such as IBM, big data can be summarized by four Vs representing its key characteristics: Volume: The amount of data Velocity: The speed of data generation Variety: The number and types of data sources Veracity: The quality and authoritative voice of the data (quantifying errors, bad data, and noise mixed with signals), a measure of the uncertainty of the data Each big data characteristic offers a challenge and an opportunity.
In 1965, Gordon Moore, cofounder of Intel and Fairchild Semiconductor (two giant companies that produce electronic components for electronics and computers), stated in an Electronics magazine paper titled "Cramming More Components Onto Integrated Circuits" that the number of components found in integrated circuits would double every year for the next decade.
Graphs are a form of common data structure used in algorithms. You see graphs used in places like maps for GPS and all sorts of other places where the top down approach of a tree structure won't work.A graph is a sort of a tree extension. As with trees, you have nodes that connect to each other to create relationships.
Greedy algorithms come in handy for solving a wide array of problems, especially when drafting a global solution is difficult. Sometimes, it's worth giving up complicated plans and simply start looking for low-hanging fruit that resembles the solution you need. In algorithms, you can describe a shortsighted approach like this as greedy.
Even though a Bloom filter can track objects arriving from a stream, it can't tell how many objects are there. A bit vector filled by ones can (depending on the number of hashes and the probability of collision) hide the true number of objects being hashed at the same address.Knowing the distinct number of objects is useful in various situations, such as when you want to know how many distinct users have seen a certain website page or the number of distinct search engine queries.
You use the command line to install Anaconda on Linux — you're given no graphical installation option. Before you can perform the install, you must download a copy of the Linux software from the Continuum Analytics site. The following procedure should work fine on any Linux system, whether you use the 32-bit or 64-bit version of Anaconda: Open a copy of Terminal.
The Mac OS X installation comes in only one form: 64-bit. Before you can perform the install, you must download a copy of the Mac software from the Continuum Analytics site.The installation files come in two forms. The first depends on a graphical installer; the second relies on the command line. The command-line version works much like the Linux version.
Anaconda comes with a graphical installation application for Windows, so getting a good install means using a wizard, as you would for any other installation. Of course, you need a copy of the installation file before you begin. The following procedure should work fine on any Windows system, whether you use the 32-bit or the 64-bit version of Anaconda.
When faced with a new difficult problem, it's not hard to come up with a greedy solution using the four steps described in the previous section. All you have to do is divide your problems into phases and determine which greedy rule to apply at each step. That is, you do the following: Choose how to make your decision (determine which approach is the simplest, most intuitive, smallest, and fastest) Start solving the problem by applying your decision rule Record the result of your decision (if needed) and determine the status of your problem Repeatedly apply the same approach at every step until reaching the problem conclusion No matter how you apply the previous steps, you must determine whether you're accomplishing your goal by relying on a series of myopic decisions.
The following table describes algorithms and algorithm types that you might find useful for various types of data analysis. (You can find discussions of all these algorithms in Algorithms For Dummies.) Algorithm Description Helpful Link 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 identifierg(n) is the cost of reaching the node so farh(n) is the estimated cost to reach the goal from the nodef(n) is the estimated cost of the path from n to the goalThe idea is to search the most promising paths first and avoid expensive paths.
Interacting with data from a single source is one problem; interacting with data from several sources is quite another. However, datasets today generally come from more than one source, so you need to understand the complications that using multiple data sources can cause. When working with multiple data sources, you must do the following: Determine whether both datasets contain all the required data.
The more operations an algorithm requires, the more complex it is. Complexity is a measure of algorithm efficiency in terms of time usage because each operation takes some time. Given the same problem, complex algorithms are generally less favorable than simple algorithms because complex algorithms require more time.
At the heart of many streaming algorithms are Bloom filters. Created almost 50 years ago by Burton H. Bloom, at a time when computer science was still quite young, the original intent of this algorithm's creator was to trade space (memory) and/or time (complexity) against what he called allowable errors. His original paper is titled Space/Time Trade-offs in Hash Coding with Allowable Errors.
When data flows in huge amounts, storing it all may be difficult or even impossible. In fact, storing it all might not even be useful. Here are some figures of just some of what you can expect to happen within a single minute on the Internet: 150 million e-mails sent 350,000 new tweets sent on Twitter 2.4 million queries requested on Google 700,000 people logged in to their account on Facebook Given such volumes, accumulating the data all day for incremental analysis might not seem efficient.
Humans think about data in nonspecific ways and apply various rules to the same data to understand it in ways that computers never can. A computer's view of data is structured, simple, uncompromising, and most definitely not creative. When humans prepare data for a computer to use, the data often interacts with the algorithms in unexpected ways and produces undesirable output.
A tree structure looks much like the physical object in the natural world. Using trees helps you organize data quickly and find it in a shorter time than using other data-storage techniques. You commonly find trees used for search and sort routines, but they have many other purposes as well.Building a tree works much like building a tree in the physical world.
Algorithms are all about finding solutions, and the speedier and easier, the better. Even though people have solved algorithms manually for literally thousands of years, doing so can consume huge amounts of time and require many numeric computations, depending on the complexity of the problem you want to solve.
Imagine trying to find an item in a list without sorting it first. Every search becomes a time-consuming sequential search. But, a case can be made for not sorting data for algorithms. After all, the data is still accessible, even if you don't sort it — and sorting takes time.Of course, the problem with unsorted data is the same problem as that junk drawer in your kitchen (or wherever you have your junk drawer — assuming that you can find it at all).
A function in mathematics is simply a way to map some inputs to a response. Expressed in a different way, a function is a transformation (based on math operations) that transforms (maps) your input to an answer.For certain values of input (usually denoted by the letters x or n), you have a corresponding answer using the math that defines the function.
https://cdn.prod.website-files.com/6630d85d73068bc09c7c436c/69195ee32d5c606051d9f433_4.%20All%20For%20You.mp3

Frequently Asked Questions

No items found.