Posts

Showing posts from January, 2019

Divide and Conquer an Algorithm design technique

Image
Hey, this is  Shubham Mishra . In our previous post of  Algorithm and its analysis , we have discussed all the algorithm, its designing and many another part. In the same post, In the algorithm designing section, I have mentioned a step that is 'Algorithm Strategy' for selecting a technique to design an algorithm. Out of all the, one very most popular among all is Divide and Conquer. Now, let's start with divide and conquer technique for algorithm designing. In this technique, a problem is, Broken down into smaller sub-problems. The sub-problems are solved independently. Merge all the solutions of all sub-problems to get the solution to the original problem. Basically, If a problem seems too big but if the problem needs repetitive steps then it's better to divide the big problem and solve sub-problems. The sub-problems once solved then combine the solutions of sub-problems to get the result for the original problem. Now let's understand it with the algo

Study of Algorithm and its analysis

Image
In the world of computer science, every on heard of the term Algorithm. Now it's the time to know in-depth about it and also study to how to start writing an algorithm before actual coding. Writing an algorithm for a solution is 80% of the coding done. An algorithm is named for the ninth century Persian mathematician al-Khowarizmi, that is it is a set of rules used to compute some calculations. For any computer problems after understanding the problem, writing an algorithm is the second step. Once you have the algorithm ready now you can write code in any programming language you want. The famous algorithm, Euclid's algorithm for getting the greatest common divisor of two numbers is been written in ancient Greek.  Algorithm:  "An algorithm is defined as a set of unambiguous rules written in a specific sequence to produce expected output for predefined inputs." Let's come out of this bookies definition, and understand the steps for solving a problem in the wo

Naive String Matching Algorithm

Image
Hi, this is Shubham Mishra. I write blogs on algorithms and new technologies. In today's blog, we will be going to see a traditional way for string matching. For this blog, I have taken the reference of Analysis of Algorithm by A.A.Putambekar's book. String matching generally used in text processing. Normally text processing is done in the compilation of a program. The string matching is a vital part in software designing and system designing. String matching means finding one or more generally all the occurrences of a string in a text. These occurrences are called Pattern . Let, Text T is denoted by T0.....T(n-1) and pattern P is denoted by P0....P(m-1). String Matching Algorithm For String matching scenario we will be discussing many algorithms in upcoming blogs such as, The naive method (This blog) Rabin-Karp algorithm Finite automaton for string matching Knuth - Morris - Pratt method Naive String Matching Algorithm Naive string matching alg

Radix Sort the best sorting algorithm

Image
Hi, this is Shubham Mishra, I write blogs on algorithms and on the technologies. Today we will be going to deals with one of the best algorithm for sorting of an array. Before doing this algorithm I recommend you to visit other algorithms such as  Merge Sort , so as to compare Radix sort algorithm with them. Radix sort is my favourite for its time complexity. Don't panic about time complexity for Radix, I will cover that later in this post. Radix sort is also known as bucket sort. The radix sort is to sort decimal numbers, where the radix or base is 10, which need 10 buckets. This all buckets are numbered from 0 to 9. The most important part of the algorithm is that the number of iterations required is equal to the number of digits in the largest number in the list. For example, refer to the table below, Radix Sort Algorithm Before moving on to the algorithm and code I would like to explain you in general terms that how radix sort works.  The number of iteratio

Introduction to Recursion (A way to write an function in Computer Science world)

Image
Hi, I am Shubham Mishra a computer science engineer, passionate about writing technical posts. While writing posts for algorithms such as  Merge Sort  and others, I thought that I should write a post on Recursion, which is a way to write a function where a step is repeated for multiple times. But before reading this I would like you to read my previous post  Data Structure and Types . Now start with the term Recursion. When a function is defined in terms of itself that is it is called even inside its own body then it is called a Recursive function. Don't be confused just scroll down and see below picture for a better understanding. Suppose you want to calculate the factorial of '4'. The factorial is calculated by multiplying the terms itself with all the numbers below to it till one. It is as '4 * 3 * 2 * 1 * 1'. The '1' extra is the Factorial(0) = 1. The factorial function will work as it will return '1' if the factorial is called for zero (