I Can’t Sleep - Algorithms | Gentle Bedtime Reading for Sleep

Episode Date: August 6, 2024

Unwind with this calm bedtime reading about algorithms, the step-by-step processes that guide problem solving in mathematics, computing, and daily life. Benjamin’s soothing narration explores the hi...story of algorithms, their importance in technology, and how they shape the modern world, all delivered in a steady and peaceful cadence. With fact-filled storytelling—no whispers, no hypnosis—this episode is designed to ease insomnia, reduce stress, and quiet restless thoughts while you gently learn. Perfect for sleepless nights or calming the mind. Press play, close your eyes, and drift into rest with algorithms. Want More? Request a Topic: https://www.icantsleeppodcast.com/request-a-topic Ad-Free Episodes: https://icantsleep.supportingcast.fm/ Shop Sleep-Friendly Products: https://www.icantsleeppodcast.com/sponsors Join the Discussion on Discord: https://discord.gg/myhGhVUhn7 This content is derived from the Wikipedia article on Algorithms, available under the Creative Commons Attribution-ShareAlike (CC BY-SA) license. Read the full article: Wikipedia – Algorithms. Happy sleeping! Learn more about your ad choices. Visit megaphone.fm/adchoices

Transcript
Discussion (0)
Starting point is 00:00:03 You're listening to a Glassbox media podcast. What if I told you that most of the modern day self-help advice you've been hearing could actually make you worse? The key to a better life isn't about feel-good gimmicks that sound catchy. The Mentally Stronger Podcast gives you access to a licensed therapist who shares science-backed tools that will actually change your life. Hi, I'm Amy Morin, psychotherapist, mental strength trainer, and international best-selling author. In each episode, we cover research-back strategies, like how to stop relying on willpower and start creating habits for lasting change. And the five mental strength-building exercises you can do from your couch. I also speak to world-class experts like Dr. Nicole Kane, who shares how to permanently heal anxiety by addressing the root cause.
Starting point is 00:00:57 With over 200 episodes in our catalog, this podcast is for you if you're ready to crush self-doubt, conquer challenges, and become stronger than ever with therapist-approved strategies that can change your life. Listen to Mentally Stronger with therapist Amy Morin, wherever you get your podcasts. Welcome back or welcome to the I Can't Sleep Podcast, where I read random articles from across the web to bore you to sleep with my soothing voice. I'm your host, Benjamin Boster. Today's episode is from a Wikipedia article titled, Algorithm. In mathematics and computer science, an algorithm is a finite sequence of mathematically rigorous instructions,
Starting point is 00:01:42 typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing calculations and data processing. More advanced algorithms can use conditionals to divert the code execution, through various routes, referred to as automated decision-making, and deduce valid inferences, referred to as automated reasoning, achieving automation eventually. Using human characteristics as descriptors of machines in metaphorical ways was already practiced by Alan Turing with terms such as memory, search, and stimulus. In contrast, a hero, is an approach to problem solving that may not be fully specified or may not guarantee correct or
Starting point is 00:02:43 optimal results, especially in problem domains where there is no well-defined correct or optimal result. For example, social media recommender systems rely on heuristics in such a way that, although widely characterized as algorithms in 21st century popular media, cannot deliver correct results due to the nature of the problem. As an effective method, an algorithm can be expressed within a finite amount of space and time and in a well-defined formal language for calculating a function. Starting from an initial state and initial input, perhaps empty, the instructions describe a computation that when executed proceeds through a finite number of well-defined success.
Starting point is 00:03:34 of states, eventually producing output and terminating at a final ending state. The transition from one state to the next is not necessarily deterministic. Some algorithms known as randomized algorithms incorporate random input. Around 825 AD, Persian scientist and polymath, Mohamed Ibn Musa Al-Qarizam wrote Kitab al-Hisab al-Hinthin, Book of Indian Computation, and Khatab al-Jam waltafrik al-Hisab al-Hindi, addition and subtraction in Indian arithmetic. In the early 12th century, Latin translations of the text involving the Hindu-Arabic numerical system and arithmetic appeared. For example, Liber Al-Go Arismi de Pratica Arismitrice, attributed to John of Seville,
Starting point is 00:04:37 and Liber Algorithmi denumero Indorum attributed to Alderod of Bath. Hereby, Algarismi, or Algarismi, is the Latinization of Alquharismi's name. The text starts with the phrase Dexied Algarismi, or Thus Spoke Alquharismi. In 1230, the English word algorithm is attested, and then by Chaucer in 1391. English adopted the French term. In the 15th century, under the influence of the Greek word arithmos, number, arithmetic, the Latin word was altered to algorithmus. One informal definition is a set of rules that precisely defines a sequence of operations,
Starting point is 00:05:34 which would include all computer programs, including programs that do not perform numeric calculations, and, for example, any prescribed bureaucratic procedure or cookbook recipe. In general, a program is an algorithm only if it stops eventually, even though infinite loops may sometimes prove desirable. Bulos, Jeffrey, and 1974, 1999 define an algorithm to be a set of instructions for determining an output given experience in a form that can be followed by either a computing machine or a human who could only carry out specific elementary operations on symbols. The concept of algorithm is also used to define the notion of decidability,
Starting point is 00:06:29 a notion that is central for explaining how formal systems come into being, starting from a small set of axioms and rules. In logic, the time that an algorithm requires to complete cannot be made. measured, as it is not apparently related to the customary physical dimension. From such uncertainties that characterize ongoing work stems the unavailability of a definition of algorithm that suits both concrete, in some sense, and abstract usage of the term. Most algorithms are intended to be implemented as computer programs. However, algorithms are also implemented by other means, such as in a biological and
Starting point is 00:07:15 neural network, for example, the human brain implementing arithmetic or an insect looking for food, in an electrical circuit, or in a mechanical device. Since antiquity, step-by-step procedures for solving mathematical problems have been attested. This includes in Babylonian mathematics around 2,500 BC, Egyptian mathematics around 1550 BC, Indian mathematics around 1850 BC, Indian mathematics around 800 BC and later. The Ilfa Oracle, around 500 BC, Greek mathematics around 240 BC, and Arabic mathematics around 880. The earliest evidence of algorithms is found in the Babylonian mathematics of ancient Mesopotamia, modern Iraq. A Sumerian clay tablet found in Surapak near Baghdad and dated to circa 2500 BC, described the earliest division algorithm. During the Hamarubi dynasty, circa 1800 to
Starting point is 00:08:27 circa 1600 BC, Babylonian clay tablets described algorithms for computing formulas. Algorithms were also used in Babylonian astronomy. Babylonian clay tablets describe and employ algorithmic procedures to compute the time and place of significant astronomical events. Algorithms for Arrismatic are also found in ancient Egyptian mathematics, dating back to the Rhinod mathematical papyrus circa 1550 BC. Algorithms were later used in ancient Hellenistic mathematics. Two examples are the sieve of Eratosthenes, which was described in the introduction to arithmetic by Nicomachus, and the Euclidean algorithm, which was first described in Euclid's elements, circa 300 BC. Examples of ancient Indian mathematics included the Shulba Sutras and the Kerala School.
Starting point is 00:09:35 The first cryptographic algorithm for deciphering encrypted code was developed by Al-Kindi, a 9th-century Arab mathematician, in a manuscript on deciphering cryptographic messages. He gave the first description of cryptanalysis by frequency analysis, the earliest code-breaking algorithm. Bolter credits the invention of the weight-driven clock as the key invention of Europe in the Middle Ages. In particular, he credits the verge-escapement mechanism that provides us with the tick and talk of a mechanical clock. The accurate automatic machine led immediately to mechanics. mechanical automata beginning in the 13th century, and finally to computational machines, the difference engine and analytical engines of Charles Babbage, and count as Ada Lovelace,
Starting point is 00:10:37 mid-19th century. Lovellase is credited with the first creation of an algorithm intended for processing on a computer. Babbage's analytical engine, the first device considered a real touring, complete computer instead of just a calculator, and is sometimes called history's first programmer as a result, though a full implementation of Babbage's second device would not be realized until decades after her lifetime. Bell and Newell, 1971, indicate that the Jacquard Loom, 1801, a precursor to Hollerous cards, punch cards 1887, and telephone switching technologies were the roots of a tree leading to the development of the first computers. By the mid-19th century, the telegraph, the precursor of the telephone,
Starting point is 00:11:38 was in use throughout the world, its discrete and distinguishable encoding of letters as dots and dashes common sound. By the late 19th century, the ticker tape, circa tape, circa 70s, was in use, as was the use of hollerith cards in the 1890 U.S. census. Then came the teleprinter circa 1910 with its punched paper use of boto code on tape. Telephone switching networks of electromechanical relays, invented 1835, was behind the work of George Stibbutz, 1937, the inventor of the digital adding device. As he worked in Bell Laboratories, he observed the burdened,
Starting point is 00:12:25 use of mechanical calculators with gears. He went home one evening in 1937, intending to test his idea. When the tinkering was over, Stibbids had constructed a binary adding machine. Mathematician Martin Davis supported the particular importance of the electromechanical relay. In 1928, a partial formalization of the modern concept of algorithms began with attempts to solve the decision problem posed by David Hilbert. Later formalizations were framed as attempts to define effective calculability or effective method. Those formalizations included the girdle-hairbrand clean recursive functions of 1930, 1934, and 1935, Alonzo Church's MDICALUS of 1936,
Starting point is 00:13:22 Emil Post Formulation 1 of 1936, and Alonzo Churches' Imda Calculus, and Alonzo Churches' Imda Calculus, and Alonzo Alan Turing's Turing Machine of 1936-37 and 1939. Algorithms can be expressed in many kinds of notation, including natural languages, pseudocode, flowchards, track and charts, programming languages, or control tables, processed by interpreters. Natural language expressions of algorithms tend to be verbose and ambiguous, and are rarely used for complex or technical algorithms. Pseudo-code, flow charts, track and control tables
Starting point is 00:14:10 are structured ways to express algorithms that avoid many of the ambiguities common and statements based on natural language. Programming languages are primarily intended for expressing algorithms in a form that can be executed by a computer, but they are also often used as a way to define or document algorithms. There is a wide variety of representations possible and one can express a given touring machine program as a sequence of machine tables, as flow charts and dracon charts, or as a form of rudimentary machine code or assembly code called sets of quadruples. Representations of algorithms can also be classified into three accepted levels of touring
Starting point is 00:15:02 machine description, high-level description, implementation description, and formal description. A high-level description describes qualities of the algorithm itself, ignoring how it is implemented on the tory machine. An implementation description describes the general manner in which the machine moves its head and stores data in order to carry out the algorithm, but doesn't give exact states. In the most detail, a formal description gives the exact state table and list of transitions of the Turing machine. The graphical aid called a flowchart offers a way to describe and document an algorithm and a computer program corresponding to it. Like the program flow of a Minsky machine, a flowchart always starts at the top of a page and proceeds down. Its primary symbols are only four.
Starting point is 00:16:07 The directed arrow showing program flow, the rectangle sequence go to, the diamond, if then else, and the dot, or tie. The berm-yacopini canonical structures are made of these primitive shapes. Sub-structures can nest in rectangles, but only if a single exit occurs from the
Starting point is 00:16:34 superstructure. It is frequently important to know how much of a particular resource, such as time or storage, is theoretically required for a given algorithm. Methods have been developed for the analysis of algorithms to obtain such quantitative answers, estimates. For example, an algorithm that adds up the elements of a list of n numbers would have a time requirement of O-N, using big O-notes, using big O-notes, At all times, the algorithm only needs to remember two values, the sum of all the elements so far, and its current position in the input list. Therefore, it is said to have a space requirement of 01, if the space required to store the input numbers is not counted, or ON, if it is counted. Different algorithms may complete the same task with a different set of instructions unless, or more time, space, or effort than others.
Starting point is 00:17:44 For example, a binary search algorithm with cost O-LogN outperforms the sequential search, cost O-N, when used for table lookups on sorted lists or arrays. The analysis and study of algorithms is a discipline of computer science and is often practiced abstractly without the use of specific programming language or implementation. In this sense, algorithm analysis resembles other mathematical disciplines in that it focuses on the underlying properties of the algorithm, and not on the specifics of any particular implementation. Usually, pseudocode is used for analysis, as it is the simplest and most general representation. However, ultimately, most algorithms are usually implemented on particular hardware software platforms,
Starting point is 00:18:45 and their algorithmic efficiency is eventually put to the test using real code. For the solution of a one-off problem, the efficiency of a particular algorithm may not have significant consequences, unless N is extremely large, but for algorithms designed for fast, interactive, commercial or long live scientific usage, it may be critical. Scaling from small end to large end frequently exposes inefficient algorithms that are otherwise benign. Empirical testing is useful because it may uncover unexpected interactions that affect performance. Benchmarks may be used to compare before and after potential improvements to an algorithm after program optimization. Empirical tests cannot replace formal analysis, though, and are not trivial to perform in a fair manner.
Starting point is 00:19:52 To illustrate the potential improvements possible even in well-established algorithms, a recent significant innovation relating to FFT algorithms used heavily in the field of image processing, and decrease processing time up to 1,000 times for applications like medical imaging. In general, speed improvements depend on special properties of the problem, which are very common and practical applications. Speed ups of this magnitude enable computing devices that make extensive use of image processing, like digital cameras and medical equipment to consume less power. Algorithm design refers to a method or a mathematical process for problem solving and engineering algorithms.
Starting point is 00:20:45 The design of algorithms is part of many solution theories, such as divide and conquer or dynamic programming within operation research. Techniques for designing and implementing algorithm designs are also called algorithm design patterns, with examples including the template method pattern and the decorator pattern. One of the most common aspects of algorithm design is resource, runtime, memory, usage efficiency. The big O notation is used to describe, for example, an algorithm's runtime growth as the size of its input increases. Per the Church Turing thesis, any algorithm can be computed by a model known by the Turing Complete. In fact, it has been demonstrated that Turing completeness requires only four instruction types. Conditional go-to, unconditional go-to, assignment, all
Starting point is 00:21:49 However, Chemene and Kurtz observe that, while undisciplined use of unconditional go-toes, and conditional if-then go-tos can result in spaghetti code, a programmer can write structured programs using only these instructions. On the other hand, it is also possible and not too hard to write badly structured programs in a structured language. Towsworth augments the three Burm Yakopini canonical. structures. Sequence, if then else, and while do with two more. Do while and case. An additional benefit of a structured program is that it lends itself to proofs of correctness
Starting point is 00:22:41 using mathematical induction. There are various ways to classify algorithms, each with his own merits. By implementation. One way to classify algorithms is by implementation. One way to classify algorithms is by implementation means. Recursion. A recursion algorithm is one that invokes, makes reference to itself, repeatedly, until a certain condition, also known as termination condition, matches, which is a method common to functional programming. Iterative algorithms use repetitive constructs like loops, and sometimes additional data structures like stacks, to solve the given problems. Some problems are naturally suited for one implementation or the other. For example, Towers of Hanoi is well understood using recursive implementation. Every recursive version has an
Starting point is 00:23:45 equivalent, but possibly more or less complex, iterative version, and vice versa. Serial, parallel, or distributed. Algorithms are usually discussed with the assumption that computers execute one instruction of an algorithm at a time. Those computers are sometimes called serial computers. An algorithm designed for such an environment is called a serial algorithm, as opposed to parallel algorithms or distributed algorithms. Parallel algorithms are algorithms that take advantage of computer architectures where multiple processors can work on a problem at the same time. Distributed algorithms or algorithms that use multiple machines connected to a computer network. Parallel and distributed algorithms divide the problem into more symmetrical or asymmetrical sub-problems
Starting point is 00:24:45 and collect the results back together. For example, a CPU would be an example of a parallel algorithm. The resource consumption and such algorithms is not only processor cycles on each processor, but also the communication overhead between the processors. Some sorting algorithms can be parallelized efficiently, but their communication overhead is expensive. Iterative algorithms are generally parallelizable, but some problems have no parallel algorithms, and are called inherently serial problems. Deterministic or non-deterministic.
Starting point is 00:25:31 Deterministic algorithms solve the problem with exact decision at every step of the algorithm, whereas non-deterministic algorithms solve problems via guessing, although typical guesses are made more accurate through the use of heuristics. Exact or approximate. While many algorithms reach an exact solution, approximation algorithms seek an approximation that is closer to the true solution. The approximation can be reached by either using a deterministic or a random strategy. Such algorithms have practical value for many hard problems.
Starting point is 00:26:12 One of the examples of an approximate algorithm is the knapsack problem, where there is a set of given items. Its goal is to pack the knapsack to get the maximum total value. value. Each item has some weight and some value. The total weight that can be carried is no more than some fixed number X, so the solution must consider weights of its items as well as their value. Quantum algorithm. Quantum algorithms run on a realistic model of quantum computation. The term is usually used for those algorithms which seem inherently quantum, or use some essential, feature of quantum computing, such as quantum superposition or quantum entanglement.
Starting point is 00:27:05 By design paradigm. Another way of classifying algorithms is by their design methodology or paradigm. There is a certain number of paradigms, each different from the other. Furthermore, each of these categories includes many different types of algorithms. Some common paradigms are, Brutforce or exhaustive search. Fruitforce is a method of problem solving that involves systematically trying every possible option until the optimal solution is found.
Starting point is 00:27:41 This approach can be very time-consuming, as it requires going through every possible combination of variables. However, it is often used when other methods are not available or too complex. Brut force can be used to solve. a variety of problems, including finding the shortest path between two points and cracking passwords. Divide and Conquer A divide and conquer algorithm repeatedly reduces an instance of a problem to one or more smaller instances of the same problem, usually recursively, until the instances are small enough to solve easily.
Starting point is 00:28:26 One such example of divide and conquer is merge sorting. Sorting can be done on each segment of data after dividing data into segments, and sorting of entire data can be obtained in the Conquer phase by merging the segments. A simpler variant of Divide and Conquer is called a decrease in Conquer algorithm, which solves an identical sub-problem and uses the solution of this sub-problem to solve the bigger problem. Divide and Conquer divides the problem into multiple sub-problem, and so the conquer stage is more complex than decrease in conquer algorithms. An example of a decrease in conquer algorithm is the binary search algorithm.
Starting point is 00:29:16 Search and enumeration Many problems, such as plain chess, can be modeled as problems on graphs. A graph exploration algorithm specifies rules for moving around a graph and is useful for such problems. This category also includes search algorithms, branch and bound enumeration, and backtracking, randomized algorithm. Such algorithms make some choices randomly or pseudo-randomely. They can be very useful in finding approximate solutions for problems where finding exact solutions can be impractical.
Starting point is 00:29:59 For some of these problems, it is known that the fastest-abroximate solutions, must involve some randomness. Whether randomized algorithms with polynomial time complexity can be the fastest algorithm for some problems is an open question known as the P versus N.P. problem. There are two large classes of such algorithms. One, Montecarlo algorithms return a correct answer with high probability, e.g., RP is a subclass of these. that run in polynomial time.
Starting point is 00:30:37 2. Las Vegas algorithms always return the correct answer, but their running time is only probabilistically bound. Reduction of complexity. This technique involves solving a difficult problem by transforming it into a better known problem, for which we have, hopefully, asymptotically optimal algorithms. The goal is to find a reducing algorithm whose complexity is not dominated by the resulting reduced algorithms.
Starting point is 00:31:11 For example, one selection algorithm for finding the median in an unsorted list involves first sorting the list, the expensive portion, and then pulling out the middle element in the sorted list, the cheap portion. This technique is also known as transform and conquer. Backtracking In this approach, multiple solutions are built and create and abandoned when it is determined that they cannot lead to a valid full solution. Optimization Problems For optimization problems, there is a more specific classification of algorithms.
Starting point is 00:31:53 An algorithm for such problems may fall into one or more of the general categories described above, as well as into one of the following. Linear Programming When searching for optimal solutions to a linear function bound to linear equality and inequality constraints, the constraints of the problem can be used directly in producing the optimal solutions. There are algorithms that can solve any problem in this category, such as the popular Simplex algorithm. Problems that can be solved with linear programming, including the maximum flow problem for directed graphs. If a problem additionally requires
Starting point is 00:32:38 that one or more of the unknowns must be an integer, than it is classified in integer programming. A linear programming algorithm can solve such a problem if it can be proved that all restrictions for integer values are superficial, i.e. the solutions satisfy these restrictions anyway. In the general case, a specialized algorithm or an algorithm that finds approximate solutions is used, depending on the difficulty of the problem. Dynamic programming When a problem shows optimal substructures, meaning the optimal solution to a problem,
Starting point is 00:33:20 can be constructed from optimal solutions to sub-problems, and overlapping sub-problems, meaning the same sub-problems are used to solve many different problem instances. A quicker approach called dynamic programming avoids re-computing solutions that have already been computed. For example, Floyd Warshall algorithm, the shortest path to a goal from a vertex in a weighted graph, can be found by using the shortest path to the goal from all adjacent vertices. Dynamic programming and memoization go together.
Starting point is 00:33:58 The main difference between dynamic programming and divide and conquer is that sub-problems are more or less independent in divide-and-conquer, whereas sub-problems overlap in dynamic programming. The difference between dynamic programming and straightforward recursion is in caching or memoization of recursive calls. When sub-problems are independent and there is no repetition, memoization does not help. Hence, dynamic programming is not a solution for all complex problems.
Starting point is 00:34:35 By using memoization or maintain, a table of sub-problems already solved, dynamic programming reduces the exponential nature of many problems to polynomial complexity, the greedy method. A greedy algorithm is similar to a dynamic programming algorithm and that it works by examining substructures, in this case, not of the problem, but of a given solution. Such algorithms start with some solution, which may be given,
Starting point is 00:35:09 which may be given or have been constructed in some way, and improve it by making small modifications. For some problems, they can find the optimal solution, while for others they stop at local optima, that is, at solutions that cannot be improved by the algorithm, but are not optimum. The most popular use of greedy algorithms is for finding the minimal spanning tree,
Starting point is 00:35:34 or finding the optimal solution is possible with this method.

There aren't comments yet for this episode. Click on any sentence in the transcript to leave a comment.