Computer science problem solving using real world examples
I’m a seasoned software engineer and throughout my careeer I have successfully used computer science fundementals to solve various problems in different levels complexity.
These computer science fundementals include data structures and algorithms.
I studied most of them during my studies at the Israeli Institute of Technology (The Technion) and some after my graduation, either to successfuly complete engineering tasks or as a part of interview preparations.
Different individuals have different ways to access data, ideas and thoughts in their memory.
One can try to memorize various algorithms that are being used in interviews, but it might be better to find the rationale, or what I personally like to call “a story” behind the algorithm.
Some of my Linked-in followers can ocassionally find postes I’m publishing with a hashtag of #Software_architecture_for_kids.
In these posts I’m sharing the achievemnts I’m reaching with explaining my 8 year old daughter, Lily, the ways complex software systems were built.
I’m using real life examples from her world to abstract concepts. For example, she does not know what hash table is, but she can understand the idea of a closet with labeled drawers.
I have participated in several GO carting events with team mates from various companies. In these events the participants drive using “mini cars” , and need to perform several laps.
Imagine a scenario where there is a highly experienced GO cart driver, let’s call him Fred. Syd is a friend of Fred, and he is not well experienced, and drives with less confidence.
Most likely not only Fred drives faster, but he is also experienced in taking turns with minimal loss of control of the vehicle and responds quickly to situations where several carts collided block a part of the track.
Fred and Syd are starting a race. It takes less than one minute for Fred to pass Syd, and he does not see him for several minutes. Fred continues to drive, bypassing other experienced drivers, but suddenly he sees Syd in front of him. How is it even possible?
Obviously the race course is circular or contains a circular part. Fred has completed more laps than Syd in the circular part of race course.
If we look at this example, we can now think about an algorithm that will find if there is a circle in a linked list.
We will use two pointers:
A fast pointer (Fred) and a slow pointer (Syd).
We will use a loop. Each iteration of the loop is equvalent to a fixed unit of time in the above race course example.
During each iteration the slow pointer advances one node in the list, while the fast pointer advanced by two nodes.
Obviously, the two pointers may reach the end of the list (The end of the list is denoted using “null” or a dummy node at the end of the list) — if this happens, there is no circle in the list, and the loop will end.
The loop will also end if the fast pointer is about to advance to a node being pointed by the slow pointer. This means that the list contains a circular part, as explaiend with the example above using go carting.
To conclude this post I would like to remind all of us that software engineers and computer scientists are human beings that want to solve problems or find tools and frameworks that can solve a set of problems, and by thinking about real life problems or scenarios, they make come up with ideas for algorithms (these include flow algorithms , breadth first search, depth first search and many more).
While writing this post I was also thinking about the time I took driving lessons in Melbourne, Victoria, Australia. Some of the challanges I was facing were driving on the left side of the road, with the stirring wheel at right side of the car.
I would to thank Omer Kimchi, my former driving instructor, for his patience and all the useful tips and instructions.