#codestorydaily

What is codestorydaily?

This is an hashtag series I  have created on Instagram to engage with people on the topics pertaining to Data structures and Algorithms.

The Idea

Main idea behind this series is to provide a simple but effective way to approach problem solving in the domain of data structures and algorithms. The focus is not on how you would write code for something or how complex a question is. But, rather on how we could develop the right thinking and arrive at a correct data structure or algorithm to solve an everyday use-case, when certain boundary conditions are specfied.

My hope is that it instigates enough interest in people to discuss and explore further about data structures and algorithms.

 

How does it work?

Well, I try and post a question on the Instagram stories feature during weekdays ( a post that stays on Instagram for 24 hours). This post includes a list of specifications posted as requirements to solve a given problem at hand. And, also provides a poll option for users to vote for their choice.

One simple example of a #codestorydaily is as below :

Requirements/Scenario : 

  • You got done with your office work.
  • You want to find the fastest way home.

Poll :

  • Which algorithm would be an efficient way to do this ?
  • Choices : BFS / DFS

How could you participate?

You can participate in this if you are active on Instagram. You can essentially vote for your choice of data structure or algorithm choices, provided for a given problem.

So, without further ado join the #codestorydaily army on Instagram: here !


FIN.


 

1. Installer for a package

Requirements :

  • Need to design a package installer (example: apt-get)
  • Ensure that all packages required are installed in the right order

Algorithm that would be useful here is :

A. Merge sort 
B. Topological sort

Correct Answer : TOPOLOGICAL SORT

  • To ensure the right order of installation of all packages that this task requires – what we really need is this:
    • Understand and build a dependency graph of the given package and packages that this is dependent on.
  • And, an algorithm that is known to help with resolving dependencies is the “Topological sort” – an application of DFS. As the name suggests it is useful in getting the topology right – the relationship topology.

No clue about what this algorithm is? Don’t worry! Here is a list of good references to help you explore further :

  1. Simple example based explanation of topological sort
  2. Solve coding problems related to this
  3. Course on graphs – that covers this? (Stanford course)