Skip to main content

Posts

Showing posts with the label Computer Science

Recursion And Dynamic Programming

An  Analysis using  Fibonacci series in C++ Recursion and Dynamic Programming are like two sides of the same coin. Both are widely used in many instances and here in this article, we are going to explore both approaches using a simple well-known example. First of all, what is recursion? Picture 1 - A small depiction of how recursion looks like Recursion is an approach where the solution of a problem depends on the solutions of the smaller instances of the same problem.  Shortly, in recursion, a method calls itself to solve a problem.  Example: Finding the factorial of an integer, say 4. We all know that 4! = 4x3x2x1 = 24. It can be done using a for loop like this. int fact = 1; for(int i = 4; i>0; i++) {     fact = fact * i; } But when it comes to being in recursion?  The process is simple. We can write 4! = 4x3! Similarly; 3! = 3x2! 2! = 2x1! 1! = 1 Here, each factorial calculation happens recursively. Picture 2 - How recursion works to calculate 4...

Sorting Algorithms  : A Comprehensive Guide

Sorting Algorithms  : Explained With Illustrations Sorting is the process of structuring data in a specific format. The sorting algorithm explicitly states how to arrange data in a specific order. The most popular orders are numerical or lexicographical. When humans understood the importance of searching speedily, they coined the term sorting. The significance of sorting stems from the fact that if data is stored in a sorted manner, data searching can be optimized to a very high level. Sorting is also used to make data more readable. The following are a few examples of sorting in real-world scenarios. 1. Telephone Directory: The telephone directory stores people’s phone numbers alphabetically so that the names can be easily searched. 2. Dictionary: Words are stored in alphabetical order in the dictionary, making it easy to find any word. Sorting algorithms can be classified into two types. Integer sorts Comparison sorts Integer sorts Counting sorts are another name for integer sort...

Dead Reckoning

When it is the beginning , the navigator is clearly aware of the position/location. When he starts to move (in the mid-sea or mid sky), he can get some known (measured) factors other than the position/location in terms of a fixed landmark . They are, The direction of movement (by using a compass) Speed of movement Time taken to reach each heading Using all this information, the navigator calculates the distance and route which he has covered and keeps track of his movement by plotting a nautical chart ( also called a sea chart). This technique is known as Dead reckoning . In brief, Dead recko ning is a process to determine the position of the navigator (sailing a ship or flying an aircraft) using the record of courses that have been sailed (or flown), the distance covered (by using the velocity in which he has traveled and time taken to reach the next course from the previous course), known point (the previous point is the known point) and the estimated or known or approximated ...