[00:00] extract a polygonal mesh of an ISO surface from a three-dimensional discrete scalar field yeah I didn't think so but back in ' 87 two programmers at General Electric did they created and patented the marching cubes [00:14] doctors to visualize data from CT and MRI scans whenever you instruct a for rearranging ones and zeros that can make animals talk and vacuums walk most [00:30] algorithms belong in the dumpster but some are fast some are beautiful and look at 10 of the most interesting algorithms ever engineered and how they're used to solve very interesting problems in the real world first on the [00:44] is the double slit experiment where particles behave like a wave when you're seems counterintuitive but it makes total sense when you realize we're [00:57] living in a simulation and the universe wrote this algorithm to cut down on its general idea behind wave function collapse can also be implemented programmatically imagine we have a map for a video game but what if this is a [01:11] sidescrolling game that can go on for eternity we can't just make a bigger map we need an algorithm to procedurally generate it on the Fly what's so weird super position of all possibilities it's the wave function then upon observation [01:26] it collapses into a particle or in other words it selects a Rand a map tile but follows a consistent set of rules like in this case making sure that the roads are always connected providing a random yet cohesive result and doesn't rely on [01:38] any sort of modern generative AI speaking of which AI is weird as hell Ai and is the magic behind image generators like Dolly and stable diffusion but the concept of diffusion actually comes from thermodynamics where [01:53] particles spread from areas of higher concentration to lower concentration in artificial intelligence the process is r reversed the algorithm starts by generating random noise which would be like high entropy in thermodynamics and [02:05] gradually refines it to a structured image which would be lower entropy but Works in two phases in the forward phase it gradually adds noise to an image step [02:17] by step until it becomes completely random in the second phase the algorithm reverses this process reconstructing it back into a coherent image when the that can be used to generate new images out of thin air allowing us to build an [02:32] infinite Army of only fans models it's highly compute intensive but also works well on audio and the next Frontier is diffusion for video generation but now let's talk about simulated analing one frustrating thing about programming is [02:44] that for many problems there's not just one solution but many solutions like an Amazon warehouse has many different ways to organize its inventory but some ways metals are heated up and cooled down over and over again to to remove defects [03:00] the same idea is used in optimization algorithms to find the best answer in a CA of good answers imagine trying to find the highest point in a mountain range full of Peaks and valleys a simple Hill Climb algorithm won't work because [03:12] algorithm to explore freely as time goes on though the temperature is lowered here is exploration versus exploitation but the reason I included this algorithm [03:28] you start out exploring all kinds of different Technologies and Frameworks then eventually you find one specific area to exploit and specialize in but we ingenious sorting algorithm of all time is without a doubt sleep sort the [03:46] conquer to break up an array into subarrays where it can be sorted more efficiently however some random genius on forchan found a better way but it's a simple it Loops over the array and then for each element it opens up a new [04:04] element then finally after waking up it prints that element it's genius because it delegates the Sorting to the CPU scheduler it's also incredibly dumb and useless because it delegates sorting to the CPU scheduler speaking of which you [04:19] might be familiar with another useless sorting algorithm BOGO sort which tries the lottery but what if we apply the same algorithm with Quant mechanics to possible outcomes exist in separate parallel universes that means as a [04:37] developer if you find yourself with an unsorted array there's some other parallel universe where it is sorted the technology isn't quite there yet but if could then use a portal gun to travel to that Universe which would make our lives [04:52] that universe but if it's a really large array Quantum BOGO sort might be worth it that's purely hypothetical but one of the most practical and goed algorithms of all time is RSA a public key crypto system it's essential for digital [05:07] letters with a unique signature but it's based on one simple mathematical reality extremely difficult and timec consuming like it take your laptop 300 trillion [05:22] start leveraging Shores algorithm which can solve the integer factorization problem exponentially faster than any classical algorithm Prime factoring is relies on Concepts like cubits superposition and entanglement to [05:40] perform massive amounts of calculations in parallel the algorithm is legit but so far the biggest number ever factored is [Music] 21 even IBM state-of-the-art Q system [05:52] one fails when trying to factor the number 35 however just recently the different algorithm that doesn't scale very well for large numbers unlike make quantum computers work expect all hell to break loose in the cyber [06:09] algorithm but it deserves a closer look so first we start with a 3D scalar field which might represent data from an MRI machine each point in the 3D space is [06:21] represented by a single number or scaler the algorithm starts with a single point treats the values as a bit in an 8bit integer this results in 256 different [06:34] algorithm marches through each point to create a 3D mesh that can be used in 3D of data that can now be rendered in 3D in modern times though we're often [06:49] dealing with distributed systems in the cloud and that brings us to the you're camped around a city with a few other generals with plans to attack up to hung over to attack the entire system could collapse computers have the [07:06] same problem sometimes they might fail or be infiltrated by hackers and you never know when or where that's going to happen luckily algorithms like pbft are designed to solve this they can keep a distributed Network working properly [07:18] even if up to onethird of its nodes go Haywire it works by having a node broadcast a pre-prepare message to other nodes indicating its Readiness to an agreement then after a certain threshold a consensus is formed once [07:33] other nodes which can then all execute the changes making the entire state of technology and things like distributed Cloud databases what's really cool about [07:47] algorithms though is that they can also reflect nature like Boyd's artificial Life program it was created back in ' 86 and simulates the flocking behavior of birds what's so cool about it is that it demonstrates the emerging complexity or [07:59] beauty that we get out of just a few simple rules in this case the birds have of the flock and they steer towards the center of mass of their local flock [08:11] directly but just emerge naturally but finally that brings us to an old algorithm that blew my mind just the other day and inspired this video boy or string it's searching becomes bigger that seems impossible but it makes sense [08:29] when you understand the algorithm it scans text from right to left then has pattern it jumps past it based on an estimation made in a pre-processed table likewise if it finds a partial match then a mismatch occurs it has a separate [08:44] pre-calculated table that maximizes the number of characters it can safely skip guaranteed to be perfect but are far more practical than looping over every because it's able to to skip a higher proportion of characters and if you've [09:01] ever wondered why grep is so fast you have this algorithm to thank