Posts

Showing posts with the label Recurssion

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 Naiv...

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 (...