Aditya Chatterjee's Blog, page 211
May 8, 2020
Ways to ZIP a file in Python

In this post, we will go through how to ZIP a file in Python, how to extract files from a ZIP file or how to print contents of a ZIP file using Python. Before that let's talk about a ZIP file.
What is a ZIP file?ZIP file is an archive file which supports lossless data compression. It can contain several files and folders or other compressed ZIP files in it. This format permits a number of compression algorithms, though DEFLATE is the most common. So, basically ZIP file is used to compress...
May 7, 2020
Number of ways to reach a number using increments of 1 and 2 (consecutive 2s are not allowed)
The problem states that given a number or a score, we need to find the number of ways to reach it using increments of 1 and 2 with a constraint that consecutive 2s aren't allowed. We will solve this using Dynamic Programming in linear time O(N).
Consider the example
4 1+1+1+1 1+2+1 1+1+2 2+1+1Note: Consecutive 2s does not imply that we can't use more than two 2s in forming the number, the number of 2s aren't restricted, only the order is. As long as they don't swing together that is fine.
...Understand Support Vector Machine (SVM) by improving a simple classifier model
Support vector machines are a popular class of Machine Learning models that were developed in the 1990s. They are capable of both linear and non-linear classification and can also be used for regression and anomaly/outlier detection. They work well for wide class of problems but are generally used for problems with small or medium sized data sets. In this tutorial, we will start off with a simple classifier model and extend and improve it to ultimately arrive at what is referred to a support...
Applications of Support Vector Machines (SVM)

Support vector machines are one of the finest and most efficient Machine Learning classification algorithms out there. However, support vector machines are more popular when the dataset to work with is smaller in size. This is understandable as we know that when the size will increase the SVM will take longer to train.
One of the things about support vector machines is that they are more flexible for new data. This makes them easier to use in the applications where we need more flexibility...
May 6, 2020
Topological Sort using Breadth First Search (BFS)
In this article, we have explored how to perform topological sort using Breadth First Search (BFS) along with an implementation. We have compared it with Topological sort using Depth First Search (DFS).
Let us consider a scenario where a university offers a bunch of courses . There are some dependent courses too.
Example : Machine Learning is dependent on Python and Calculus , CSS dependent on HTML etc.
All these dependencies can be documented into a directed graph. Now the university wants...
DFS vs BFS (in detail)
DFS and BFS are elementary graph traversal algorithms. These algorithms form the heart of many other complex graph algorithms. Therefore, it is necessary to know how and where to use them.
We will go through the main differences between DFS and BFS along with the different applications. Following this, we will go through the basics of both the algorithms along with implementations.
Comparison of DFS and BFSFollowing table highlights the difference between DFS and BFS:
Basis DFS BFS ...