Fun with Computer Science — ChatGPT

ChatGPT ( is in research release mode and has already attracted a lot of attention. Let’s examine its knowledge of computer science.

There are quite a few Algorithms almost all computer scientists have heard of, most know them by heart, and some use them. Here is a composition of ChatGPT’s funny explanations of each. Here, ChatGPT uses fun analogous stories about kings, knights, restaurants, pinguins, ants, dinner parties, stuffed animals, kingdom of mischievous numbers, and wizards to satisfy the “funny” context (constraint).

The explanations are fun indeed, but not quite funny!

Table of Contents

· Search Algoritms
Linear Search
Binary Search
Breadth First Search (BFS)
Depth First Search (DFS)
· Sort Algorithms
Merge Sort
Quick Sort
Insertion Sort
Selection Sort
Heap Sort
Counting Sort
· Graph Algorithms
Floyd Warshall
Floyd’s Cycle Detection
· Lee
· Flood Fill
· Kadane’s
· Huffman Coding Compression
· Quickselect
· Euclid’s

Search Algoritms

Explain Linear Search Algorithm in a funny way.

Linear search is like a group of friends trying to find a specific person in a crowded party. They start at one end of the room and scan each person one by one, asking them if they are the person they are looking for. If they don’t find the person, they move on to the next person and continue the process until they finally find their friend. It may not be the most efficient way to find someone, but it gets the job done!

Explain Binary Search Algorithm in a funny way.

Imagine you’re looking for your lost car keys in a cluttered room. You could search the entire room methodically, going through every single clutter and checking if your keys are there. But that would be slow and tedious.

Instead, you could use the binary search algorithm to find your keys faster. First, you would divide the room in half and look in one half. If your keys aren’t there, you would know they must be in the other half. Then you would repeat the process, dividing the half that contains your keys in half again, and looking in one of the two quarters. You would continue this process until you find your keys.

Just like the binary search algorithm, this process allows you to quickly narrow down the search area and find what you’re looking for faster. And just like the algorithm, it’s much more efficient than searching the entire room one clutter at a time!

Explain Breadth First Search (BFS) Algorithm in a funny way.

BFS is like a game of “Marco Polo” — you start at a specific point and shout out “Marco” (i.e. visit the starting node), then listen for a response of “Polo” (i.e. visit the neighboring nodes), then move in that direction and repeat the process until you find what you’re looking for (i.e. the goal node). It’s a bit like following a trail of breadcrumbs, hence the name “breadth first” search.

But instead of just shouting “Marco Polo” over and over again, you keep a list of all the places you’ve already visited, so you don’t end up going in circles (or getting lost in the pool, if you’re playing the actual game of Marco Polo). And instead of just going in one direction, you explore all the neighboring nodes before moving on, so you can be sure you’ve searched the whole area before giving up.

In short, BFS is a way of systematically searching through a maze (or graph, in computer science terms) until you find what you’re looking for, without getting stuck in any dead ends (or pools, if you’re still thinking about Marco Polo). It may not be the fastest way to search, but it’s guaranteed to find the answer if it exists, and that’s what makes it such a useful algorithm.

Explain Depth First Search (DFS) Algorithm in a funny way.

Imagine you’re lost in a maze and you need to find a way out. You see two paths in front of you, so you choose one and start walking down it. You continue walking down this path, deeper and deeper into the maze, until you reach a dead end and can’t go any further. At this point, you backtrack and take the other path you didn’t choose earlier. You repeat this process of going down one path until you reach a dead end and then backtracking and taking the other path until you finally find your way out of the maze. This is essentially how Depth First Search works: it explores one path all the way to the end before backtracking and exploring the other paths.

Sort Algorithms

Explain Merge Sort Algorithm in a funny way.

Once upon a time, there was a group of numbers that were all jumbled up and couldn’t decide on their own how to organize themselves. So, they decided to call in the “Merge Sort” algorithm to help them out.

The Merge Sort algorithm split the group of numbers into smaller groups, and then sorted each of those groups individually. Once all of the smaller groups were sorted, the algorithm started “merging” them back together in a way that made them all happy and organized.

It was like a big family reunion, but instead of awkward small talk and awkward photos, there was just a lot of sorting and merging. And in the end, all of the numbers were in perfect order and living happily ever after.

The moral of the story? Sometimes, it takes a little help to get things sorted out. (And also, algorithms can be pretty funny.)

Explain Quick Sort Algorithm in a funny way.

Quicksort is like a group of friends trying to decide what restaurant to go to for dinner. One friend, the pivot, suggests a restaurant and everyone else quickly splits into two groups — those who think it’s a good idea and those who don’t. The group then repeats this process for each subgroup until everyone has made a decision and the group can happily go to their chosen restaurant. Just remember — always choose a good pivot or you’ll end up at a sketchy buffet.

Explain Insertion Sort Algorithm in a funny way.

Okay, imagine you’re throwing a dinner party and you’ve invited all your friends. But instead of just letting them come in any order, you want them to arrive in alphabetical order so you can seat them properly.

So you start with the first person on the list, let’s say it’s Adam. You let Adam in and he takes his seat.

Next up is Bella. You check the list again and see that Adam is already seated, so you let Bella in and she takes the seat next to Adam.

Now it’s time for Charlie to arrive. You check the list again and see that Adam and Bella are seated, so you let Charlie in and he takes the seat next to Bella.

This continues until all your friends have arrived and are seated in alphabetical order. That, my friend, is the magical power of insertion sort!

Explain Selection Sort Algorithm in a funny way.

Once upon a time, in a land far, far away, there was a king named King Sorting who had a very important task at hand — sorting his subjects in ascending order of height.

The king gathered his subjects and stood them in a line, and then he began the process of sorting.

He looked at the first person in line and thought to himself, “Hmm, this person isn’t the shortest one here. I need to find the shortest person and put them first.”

So, he started looking at each person in the line, one by one, and whenever he found a person who was shorter than the current person, he swapped them with the first person in line.

This process continued until he reached the end of the line, and finally, he had a line of subjects sorted in ascending order of height.

And that, my friends, is how Selection Sort works — by finding the smallest element and moving it to the front of the list, one element at a time.

King Sorting was very pleased with his work and lived happily ever after, knowing that his subjects were now sorted in the most efficient way possible.

Explain Heap Sort Algorithm in a funny way.

Okay, so imagine you have a giant pile of stuffed animals. You want to sort them by size, but you’re too lazy to pick them up one by one and arrange them. So instead, you grab the biggest stuffed animal at the top of the pile and toss it aside. Then you grab the next biggest stuffed animal and toss it aside. You keep doing this until the pile is empty and you have a nice, neat line of stuffed animals sorted by size. That’s basically how heap sort works — it grabs the biggest element from the heap and puts it in its proper place, until the whole heap is sorted. And just like with your stuffed animals, it’s a quick and efficient way to get the job done.

Explain Counting Sort Algorithm in a funny way.

Once upon a time, in a land far, far away, there lived a group of mischievous numbers. These numbers were always causing chaos and disorder, and their kingdom was in need of a solution.

One day, a wise old king decided to implement a new sorting algorithm to tame the numbers. He called it “Counting Sort,” and it worked like this:

First, the king counted all the numbers in the kingdom and made a list of how many of each number there were. Then, he went through the list and placed each number in its proper order, starting with the smallest number and going all the way up to the largest.

The mischievous numbers were shocked at first, but they quickly realized that they could no longer cause chaos and disorder. They were now in a neat and organized order, and the kingdom was finally at peace.

And they all lived happily ever after. The end.

Graph Algorithms

Explain Kruskal’s Algorithm in a funny way.

Imagine that you’re a king in medieval times, and you have a kingdom with a bunch of villages. You want to build roads between these villages so that all the villagers can easily travel between them. But you’re a frugal king, so you want to build the roads in the cheapest possible way.

Enter Kruskal’s Algorithm! This clever algorithm tells you the best order to build the roads in, so that you can save as much money as possible. It works by starting with the cheapest road and adding roads one by one, making sure that each new road connects two villages that aren’t already connected. This way, you can build a network of roads without any expensive duplicates.

So, in the end, you end up with a beautiful network of roads connecting all your villages, and you didn’t have to spend a fortune on it. Thanks, Kruskal’s Algorithm!

Explain Floyd Warshall Algorithm in a funny way.

Once upon a time, in a land far, far away, there lived a group of penguins. These penguins loved to go on adventures and explore their snowy kingdom.

One day, they decided to travel to the furthest corner of their kingdom to find a hidden treasure. However, they quickly realized that they didn’t know the best route to take.

That’s when Floyd Warshall, the smartest penguin in the group, stepped up to the plate. He decided to use his special algorithm to find the shortest path to the treasure.

First, Floyd made a map of the kingdom, marking all the different paths and distances between them. Then, he used his algorithm to calculate the shortest path by repeatedly checking and updating the distances between each pair of penguins.

Finally, after much calculating and updating, Floyd found the perfect route for the penguins to take. They all cheered and set off on their adventure, grateful for Floyd’s help.

And that, my friends, is the tale of Floyd Warshall and his amazing algorithm.

Explain Dijkstra’s Algorithm in a funny way.

Okay, imagine you’re a little ant trying to find the shortest path to the delicious picnic feast. You start at your anthill and start wandering around, taking note of all the different paths and how long they take to get to the feast.

As you’re wandering, you come across a fork in the path and have to choose which way to go. You wisely choose the path that’s shorter and faster, because who wants to waste time when there’s a yummy picnic waiting?

You keep following the shortest path and eventually make it to the feast. But wait, there’s another ant there who’s also trying to find the shortest path! You both compare notes and realize that you took different routes, but somehow you both ended up at the same place.

That’s the basics of Dijkstra’s Algorithm — it helps you find the shortest path from point A to point B, even if there are multiple paths to choose from. And just like the little ant, it’s all about making smart choices and being efficient. Bon appetit!

Explain Floyd’s Cycle Detection Algorithm in a funny way.

Imagine you are at a party and you are trying to find the person who keeps stealing your snacks. You decide to put a tiny tracking device on your next snack and see where it goes.

First, you introduce two “pointers” to the party — one named “Tortoise” and the other named “Hare”. You give the snack to Tortoise and tell him to move one step at a time. Hare, on the other hand, is a bit faster and can move two steps at a time.

As Tortoise and Hare move around the party, they are constantly checking if they are at the same spot. If they ever meet, you know that there is a “cycle” or loop in the movement of the snack thief.

To find out who the culprit is, you continue to let Tortoise and Hare move around the party until they meet again at the same spot. At this point, Tortoise goes back to the starting point and starts moving one step at a time again. Hare continues moving at the same pace.

Eventually, Tortoise and Hare will meet again and this time, the spot where they meet will be the person who keeps stealing your snacks!

So, in short, Floyd’s Cycle Detection Algorithm is a clever way to track down the snack thief at a party.


Explain Lee Algorithm in a funny way.

Once upon a time in a far-off land, there lived a king named Lee. King Lee was known for his wisdom and his ability to solve complex problems with ease.

One day, a group of knights came to the kingdom and presented King Lee with a challenge. They said, “Your majesty, we have a maze with many paths and we need your help to find the shortest route to the treasure at the end.”

King Lee thought for a moment and then said, “I have a solution. I will send out my knights to explore each path in the maze, and they will mark the ones that lead to the treasure. Then, I will use my knowledge of mathematics and logic to determine the shortest route to the treasure.”

The knights were impressed and set off to explore the maze. After a few hours, they returned with their findings and King Lee carefully studied the marked paths. Using his algorithm, he quickly determined the shortest route and led the knights to the treasure.

And thus, the Lee Algorithm was born and it became known as a powerful tool for solving maze-like problems. The end.

Flood Fill

Explain Flood Fill Algorithm in a funny way.

Flood fill is like when you’re painting a room and you accidentally spill some paint on the floor. You quickly grab a brush and start spreading the paint around, filling in all the empty spaces until the whole floor is covered. That’s basically how flood fill works — it starts at a specific point and spreads out, filling in all the empty spaces with a certain color until it reaches the edge of the area. So next time you’re doing some DIY home improvements, just think of flood fill and you’ll be a pro at painting in no time!


Explain Kadane’s Algorithm in a funny way.

Kadane’s Algorithm is like a carnival strongman who can lift heavy weights. It starts by picking up the first number it sees and then, one by one, picks up all the other numbers in the sequence and adds them to its weightlifting bar. If the number being picked up is heavier than the current weight on the bar, the strongman discards the current weight and picks up the heavier number instead. In the end, the strongman is left with the maximum sum of all the numbers it picked up. So basically, Kadane’s Algorithm is like a beefy, number-lifting superhero!

Huffman Coding Compression

Explain Huffman Coding Compression Algorithm in a funny way.

Once upon a time, in a land of data compression, there was a wise old wizard named Huffman. Huffman was a master of compressing information and making it smaller, but still understandable.

One day, Huffman came across a giant pile of data that needed to be compressed. He looked at the data and saw that some of the information was used more often than others. So, Huffman used his magical powers to create a special code for each piece of information.

The code was made up of ones and zeros, and the more often a piece of information was used, the shorter its code was. This way, Huffman could compress the data without losing any important information.

Huffman worked tirelessly, creating code after code until the pile of data was much smaller. And the people of the land of data compression lived happily ever after, thanks to Huffman and his clever coding tricks.


Explain Quickselect Algorithm in a funny way.

Quickselect is like a hot girl at a party. Everyone wants to talk to her, but she only has time for the most important guys (or in this case, the kth smallest element in the array). She quickly sifts through all the guys (or elements) and effortlessly picks out the one she wants. And just like that, the algorithm is done and the chosen guy (or element) is the center of attention.

ChatGPT had originally given the following answer which wasn’t accurate, hence the retry. But, funny enough, both completions of Quickselect use “hot folks at parties” as an analogy! What was in the training data?

“Quickselect is like when you’re at a party and you’re trying to find the hottest person in the room. You first randomly pick someone and then compare them to everyone else. If they’re not the hottest, you eliminate them and pick someone else. This process continues until you find the hottest person in the room. It’s a fast and efficient way to find the one you’re looking for, just like Quickselect is a fast and efficient way to find the value you want in a list of numbers.”

Both completions of Quickselect use “hot folks at parties” for analogy! What on eart was in the training data?


Explain Euclid’s Algorithm in a funny way.

Okay, so imagine you have two really big numbers, like really really big. Like, so big that you can’t even fit them in your head. But you want to know what the biggest number is that can divide both of them evenly.

Enter Euclid’s Algorithm. It’s like a super smart robot that can figure out the biggest number that can divide both of those big numbers evenly.

First, the robot takes the two big numbers and divides them by each other. If there’s a remainder, the robot takes that remainder and divides it by the original big number that it started with. And it keeps doing this until there’s no remainder left.

And voila! The robot has figured out the biggest number that can divide both of those big numbers evenly. It’s like magic, but with math.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store