Search This Blog

Simplicity is the ultimate sophistication.” — Leonardo da Vinci
Contact me: sreramk360@gmail.com

Wednesday, 16 December 2015

What exactly caused the Chennai rains this december (2015)?


What exactly caused the Chennai rains this December (2015)?
                                    Article author: K Sreram
Heavy rain that hadn’t occurred in Chennai for over hundred years is something important to consider to understand our world’s climatic change. We have all heard about global warming, in which the global surface temperature gradually increase as a consequence of greenhouse effect. The global average temperature raised by 1˚C from 1880 to 2010. Does this value sound quite small? Well it's probably not. Because, this data is “average global surface temperature”. So on an average, all places on the map experience a temperature hike by 1˚C; obviously we have the net hike being directly proportional to the Earth’s surface area; which means that it eventually sums up to a huge value. Can the Chennai rains be related to this temperature hike? Yes it can! Global warming does not just cause glaciers melting in the Polar Regions, and the raising of the sea water level.

Saturday, 21 November 2015

how chess works


How chess games work

People have always wondered, “How to play like a grandmaster?” But when the question is “How to get into IIT?” the simple answer known to everyone is study hard and solve all problems; also make sure you solve them on time during the exam. But when it comes to chess, I found it really hard to come up with “what do players actually do to win the game?” Or what causes a grandmaster to play better than anyone? If the question is about IIT-JEE, the simple answer would be, “Just know them all, and solve problems on time”. Nevertheless when it comes to chess, it is quite hard to determine how a good chess game should be played.

Chess is a battle, where you mustn’t make mistakes. You might already know that any standard chess engine running on an ordinary machine would easily defeat the world’s top grandmasters. If you have tried playing with one such chess engines, you would think “Fine, that’s obvious. The computer is unimaginably strong. Beating it is impossible”. Not so soon; if a super grandmaster plays ten games with the computer, he is bound to lose most of them. But not all of them! This clearly shows that not all chess games played by a computer is unbeatable. If you are someone (like me) who have tried to improve your chess by trying the beat the engine, but failed unbelievably but finally managed to bring the game to a draw, after several “reverse moves” and finally realised that you have mistakenly set a lesser “fixed search depth” value; and badly want to know how chess works. You have come to the right place.

So what is so different about chess grandmasters? Or perhaps, any strong player (especially if you have got the awesome opportunity of playing chess with a chess grandmaster, being an ordinary player). Let me tell you the secret. You need to always make sure that you do the following each time you play:

Thursday, 5 November 2015

Writing a good story


Writing a good story
While reading a story, we tend to feel as if the events in the story are real. We cannot say this is exactly true, because I the hero is in a dangerous situation, you don’t feel “shocked” or “scared” the same way you would feel when it were real. But, you will know “How it feels” to be in that situation and be shocked or scared. Now let’s go on to the part where we actually write our story.

Saturday, 3 October 2015

Bellman Ford Algorithm implementation in c++

BELLMAN FORD ALGORITHM IMPLEMENTATION IN C++


Shortest path algorithm: Elaborated


Shortest path algorithm
Email: sreramk@outlook.com
Shortest path algorithms are used in may real life applications, especially applications involving maps and artificial intelligence algorithms which are NP in nature. A graph is a collection of nodes connected by edges  and can be expressed as. Stands for vertices. These vertices and the connecting edges together can be imagined to form a three dimensional geometrical structure. In some cases, for each (here  are vertices which are connected) there is a weight value assigned to it. This can also be called as “distance” or “cost” of connecting the two nodes. The shortest path algorithm traces the minimum distance (or cost) between two nodes  which are either directly or indirectly connected. The weight values along each possible paths to the destination node from the source node are summed up, and the path with the minimum summation value is chosen as the shortest path.
We may represent a weighted graph as where the extra parameter represents the set of weight values across each edge. Weight of the edge. Usually, shortest path algorithms are of time complexity because every node needs to be visited at least once. In case of AI algorithms, the vertices are generated based on specific rules, and usually it’s a function of depth; because most nodes have more than one connections, we may also have non-polynomial relation between the depth and the number of nodes.
Algorithms like Dijkstra’s algorithm’s time complexity is (note, represents number of nodes and represents number of edges). Dijkstra’s algorithm holds only for the situations where. But from the definition of a weighted graph given above, weight values can also be negative. So a modified version of the algorithm which also solves problems with negative weight edge is required. But this modified algorithm would require a greater runtime-time complexity; Dijkstra’s algorithm is a greedy algorithm, which selects the best possible path to every node in the graph, originating from source. But Dijkstra’s algorithm fails to solve problems that have negative weight values. In scenarios where negative weight values are present, another algorithm called Bellman Ford algorithm is used. But its runtime complexity is. Which is far greater than Dijkstra’s algorithm. Generally,  unless there are disjoint nodes or graphs. Unless stated, the graphs discussed here are always assumed to not contain any disjoint sets or nodes.

Sunday, 2 August 2015

Fundamentals of calculus chapter 4: More on differential equations

Fundamentals of calculus chapter 4: More on differential equations

Differential equations do not have immediate means to solve them. The reason is, because differential equations are defined from differentiation and so is its integral, it’s easier to find the differential equation rather than it’s solution. If our motive is purely to find the solution of differential equations, then our best approach will be to try and find how the expressions “behave” while trying to differentiate them. Then we may back trace this sequence of steps to find the original expression.

Monday, 27 July 2015

An optimal algorithm for the shortest path in the graph


An optimal algorithm to find the shortest path in the graph
Introduction:

Many real-life solutions rely on shortest path algorithms, especially games rely on them! If a graphic game character traces your moves along a complicated path and finds you, then it is obvious that the game implemented a graph algorithm to find the shortest path to approach you. Is it really that easy to find an optimal path to reach a point in a graph? No not exactly, as the upper bound of the Dijkstra’s algorithm is $O(|V|^2)$. If we assume your game map to be a big grid, then the number of cells in the grid is equal to the number $|V|$. But this is still the worst case, and for most times we don’t need to consider the worst case. Let me describe the Dijkstra’s algorithm. 

Sunday, 19 July 2015

Fundamentals of calculus Chapter 3: differential equations of functions involving one independent variable.


Fundamentals of calculus
Chapter 3: differential equations of functions involving one independent variable.


“Everything big is built out of smaller units; and if the smaller units fail to cooperate the bigger ones ultimately fall”

“A good learner never accepts the educative information he comes across unless he knows for sure, that there is no practical and logical way to contradict it”


Calculus as a whole evolved to support something new, a differential equation. One marvellous fact about differential equations are they don’t have any constants to describe the graphical structure they represent. In the previous article ‘chapter 2’, we saw how differentiation eliminates a constant. This fact can be taken advantage of to frame differential equations that elaborate the actual rate of change of different quantities. For example if, $z = ax^2 + bx +c$ then $\frac{dz}{dx} = 2ax + b$ and $\frac{d^2z}{dx^2} = 2a$ and $\frac{d^3z}{dx^3} = 0$.

Friday, 17 July 2015

Fundamentals of calculus Chapter 2: Integration

Fundamentals of calculus
Chapter 2: Integration

Integration is the converse of differentiation. To understand this better, it must be known that during differentiation an important information is lost. Let $\frac{dz(x)}{dx} = z’(x)$. Then, we cannot get back $z(x)$ from $z’(x)$ because, while taking the difference $z(x+\Delta x) – z(x)$ only the information regarding the difference between a point in Z axis and a neighbourhood of that point is retained. But the actual orientation is lost. Throughout this article, unless stated $\Delta x$ is limited to zero. To see how this could cause the loss of a piece of information, let me elaborate this with a simple algebraic example. Consider $a-b = c$ to be true. Then we may write $a – (a-c) = c$, here $b=a-c$.

Wednesday, 15 July 2015

Fundamentals of calculus Chapter 1: Differentiation.

Fundamentals of calculus
Chapter 1: Differentiation.

Can we really call calculus an art? Moreover, can we call mathematics an art? Most mathematicians will agree to the answer: yes. We express ourselves, our creativity through mathematics. It’s not always about calculation. Read my article why do we need mathematics?’ to better understand what I believe mathematics is really. I will not agree that the explanation I had given there was enough. But anyway, I believe mathematics is an art because it is not based on mere calculations but based on creating new rules, using them to express what is around us in a more precise and defined manner. Most of the time, mathematicians would define these rules not for the sake of answering questions that follow up with our reality. But they just do it, in hope that their discovery might come in handy to some scientist in the near future. Some don’t even care about its necessity and for the sake of not expressing themselves to be someone ignorant of the reality most people scramble through physics equations or some other kind of scientific material to find the right place for their equations or mathematical rules to fit in and prove to be beneficial.

Monday, 13 July 2015

Calculus Vs algebra





Calculus Vs algebra:-


-By K Sreram

This article was first written on 2013


Introduction:-

This article was written to show the difference between arithmetic algebra and calculus. Differentiation and integration is far different from arithmetic algebra (though arithmetic algebra is used to represent the process of differentiation, differentiated equations, integrated equations or expressions) because, arithmetic algebra does not support the results provided by differentiation or integration process. Arithmetic algebra shows that the result provided by differentiation or integration process is approximated and the error will never be zero; but calculus says exact values.
I have proved all this in this article. This article also shows us what actually calculus is and how to apply them practically. Differential and integral calculus is a modification done to the mathematics at the time when arithmetic (and some geometric) algebra was prominent. It defines a wrong result (according to the ordinary algebra) to be correct (with proper proofs).



Monday, 22 June 2015

How to make a good chess move


How to calculate chess positions?

The grandmaster's secret” is what every average chess player will want to know. But unfortunately there is no "secret" for evaluating chess positions with high accuracy. We just need to change the view by which we look at the board while evaluating. But that's also not going to be easy. Only extensive practical experience on applying the methods described in this article will improve the player's playing strength. This article is not written by an experienced rated chess player of any sort, the author just play chess and analyses chess to some degree. And the author does not claim that the methods presented in this article are standardized theoretical methods. 

Analysis on shell sorting algorithm's worse case



Analysis on shell sorting algorithm's worse case

Dear reader,

Before we get to the main part of this post, I would like to share my experience learning this algorithm. I am a student doing my computer science engineering, and this concept of shell sorting is a part of my first year syllabus. I couldn't initially understand why shell sort runs faster than insertion sort, given that shell sort tends to insertion sort algorithm if the separation by which the system does the sorting procedure reaches one. On all cases, it does reach one and the same kind of iterations as of insertion sorting algorithm is found to take place. So this question had bothered me for a two days after since I had come across it. But now, I am completely clarified with that doubt. Because I found it difficult to understand why shell sorting algorithm proceeds faster than insertion sorting algorithm when I was learning this algorithm, I would be able to give a better view on shell sorting algorithm, in a way that you don't face the same problem I had faced.
Yours,
 K Sreram.

Wednesday, 29 April 2015

Time travel


If time travel to the past were possible (A good solution to the grandfather paradox)

Traveling back in time is one of the most important science fictional concept that most science fiction author wish to exploit. Any story that involves time travel, will always forget to answer certain questions that stand vital for the reader’s understanding of time travelling concept. The main reason to this is time travel concept gives raise to many unique paradoxes that are hard to solve. Solving such paradox might not always seem easy. One such paradox is the grandfather paradox.

Tuesday, 28 April 2015

Maximize your creativity


Steps to maximize your Creativity easily

Of course, keeping the title of this blog as "Creativity Maximized" and not talking about maximizing your creativity seems a bit offbeat. So in this article I have shared my views on how to maximize your creativity; what I say here are purely out of my experience and does not go beyond that. Usually when we talk about "creativity", we refer to doing something "different" or "out of the box". When do we say something is "out of the box?" Have you ever thought about it? When we feel something seems different, we call it creative.

Monday, 27 April 2015

Detective series's answer




Question1. The jewel thief  : Detective John Volt. (detective puzzle series)
Mrs Lucy had her front door fastened before going to the market to buy some food. When she came back after an hour, she found her front door open. She rushed to her room and found her valuable jewels missing, so she immediately contacted the best detective in the town John Volt.

Detective game series



Question 1. The jewel thief   : Detective John Volt (detective puzzle series).
Mrs Lucy had her front door fastened before going to the market to buy some food. When she came back after an hour, she found her front door open. She rushed to her room and found her valuable jewels missing, so she immediately contacted the best detective in the town John Volt.

Sunday, 19 April 2015

Determine the average run-time of insertion sort algorithm



Insertion sorting algorithm analysis
 This article shows the analysis of insertion sorting algorithm and a program to implement insertion sorting algorithm. Link list implementation is used for the implementation.

This algorithm does comparison based sorting which involves $N^2$ iterations for the worse case and $N$ iterations if the list is already in sorted order. For the reader's convenience, a quick description of the algorithm is provided here.  

Let there be an unsorted list $L$ which has its elements read linearly, starting from one of its edges. Another list $L'$ (which is assumed to be always sorted)  is generated upon reading the first element from the list $L$. For each element read from $L$ (let's consider the variable $x$ to store the read value) it's inserted into the sorted list $L'$ in such a position that $L'$ remains sorted  after the insertion (note that initially $L'$ was empty). The position in $L'$ to which the variable $x$ has to be inserted is determined by a linear search through $L'$ starting from one of its edges and comparing the arithmetic priority of $x$ with the succeeding element.

This algorithm explains what basically happens in an insertion sorting algorithm. But it states that the searching process could begin from either of the ends. On the whole, this wouldn't have any influence in the run time, but certain parameters change. For example, if the algorithm is made to arrange a set of numbers in ascending order, and the search iterations begins with the beginning of the list $L'$ during any point in time, then passing on a list that has its elements arranged in descending order takes $O(1)$ to be sorted in acceding order whereas passing on a list which is initially in acceding order would take $O(N^2)$ time to get sorted. Searching from the beginning of the list $L'$ and moving to its end is same as another algorithm which reverses the order of elements in $L$ and then sorts them in ascending order but have its search iteration start from the last element in list $L'$ and move towards the first. So minor changes such as these are not going to count, especially if we do pure theoretical analysis on this topic, rather than provide an optimal practical working modal.

A link to inserting sorting implementation C program.      

Friday, 17 April 2015

The legend of the unbreakable coin




The legend of the unbreakable coin

-K Sreram

Episode 1

"Time can be bent in the most mysterious possible ways"–An old man


Part 1 (part 2 is still pending to be written)

“I send you out to buy tomatoes for fifty two rupees and you come back to tell me that you were robbed? Which robber robs fifty two rupees?” asked Hema to her younger brother Roshan who had just returned home after losing a sum of fifty two rupees to a stranger. He said “I told you! He demanded for the money. He first asked me for some food, claiming to not have eaten for three days. I said I had none, but only had the fifty two rupees which I needed for buying tomatoes”
Hema said “why would you need to tell him how much you had? Of course! Now it makes sense. It’s like approaching a stranger voluntarily and telling him ‘Mr. Robber. I have some money with me. It’s not much, but you may rob me’”.

Friday, 3 April 2015

program to evaluate infix expressions



Program to evaluate infix expressions
 

/*
* Program to convert an infix arithmetic expression to
* postfix and to thereby evaluate the result.
*/

Thursday, 2 April 2015

Example program for queue



Example program for queue


Program:

/*
* This program is written to obtain the job application form and to later verify the forms
* using queue implementation.
*/

Wednesday, 1 April 2015

CS6212 lab manual programs


- By

Uploaded on:

CS6212 lab manual programs (complete solutions - C programs).

The following programs are written for the subject CS6212 (only the first ten out of twelve are given here). These programs or based on BE- CSE semester 2 lab syllabus. I am a student doing my second semester BE CSE currently while writing down these record programs. So please excuse me for any mistakes that might have crept in the programs (but I have made sure that the following programs are error free and warning free and also works as expected).  

Monday, 30 March 2015

Example program that imitiates function stack




An example program that imitates function stack

Program:

/*
 an example program that imitates the "function stack" concept.
 This program is already available as the second program in these record
 program series, but here recession is imitated with a fake function stack!

*/

Friday, 27 March 2015

employee record program



Program to manipulate and store employee records
 

/*
* problem 3
* employee record program
*/
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#define NILL 0
#define Set_NULL(employeeRec) (*((unsigned long long int*)&employeeRec) = NILL)
#define Check_If_Null(employeeRec) ( *((unsigned long long int*)&employeeRec) == NILL )
struct EMPLOYEE;
typedef struct EMPLOYEE Employee;

struct EMPLOYEE
{
    char name[50];
    float Salary;
    char designation[100];
    unsigned int empNo;
};

Employee getRecord()
{
    Employee emp;
    printf("\nenter the employee details: ");
    printf("\nenter name: "); fflush(stdin);
    gets(emp.name); fflush(stdin);
    printf("\nenter the salary of the employee: ");
    scanf("%f", &emp.Salary); fflush(stdin);
    printf("\nenter the designation of the employee: ");
    scanf("%s", emp.designation); fflush(stdin);
    printf("\nenter the employee number: ");
    scanf("%d", &emp.empNo);
    return emp;
}

An example program for control statements and conditional statements



An example program for control statements and conditional statements


/*
* An example program for control statements and conditional statements
* problem: write a program to solve the following problem:
*    statement: Let there be an integer array A with n elements. Lets say that
*    we choose m numbers from the n numbers (a number can be chosen twice) and add them
*    to obtain the value x. So algorithmically determine the number of combinations
*    possible to bring about the sum x. Note: the values can be repeated.
**** By K Sreram
*/

program to count the number of prime numbers from 1 to limit



Program to count the number of prime numbers from 1 to limit
 

/*
* program to count the number of prime numbers from 1 to limit
*/
#include <stdio.h>
#include <conio.h>

int checkPrime(int val)
{ // tests if the given number is prime or not
    int i;
    if(val == 1 || val == 0)
        return 0;
    for(i=2; i<=val/2; ++i)
        if((val%i) == 0)
                return 0;
    return 1;
}

int noOfPrimes(int lim)
{// this calls the function checkPrime to test if the number is prime
    // if it is prime, 'count' is incremented.
    int i, count = 0;
    printf("\nlist of prime numbers from 2 to %d", lim);
    for(i=2; i<=lim; ++i)
        if(checkPrime(i))
            {
                ++count;
                printf("\n%d", i);
            }
    return count;
}

int main() /// the runtime complexity of this program is O(N^2)
{
    int lim;
    printf("enter the limit:");
    scanf("%d", &lim);
    printf("number of prime numbers from 2 to %d is %d", lim, noOfPrimes(lim));
    return 0;
}




copyright (c) 2015 K Sreram.
About my blog
 
 

infix to post-fix conversion program




Infix to post-fix conversion program

/*
 infix to postfix conversion program
*/
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <process.h>
#include <ctype.h>
#include <strings.h>
enum BOOL {FALSE, TRUE };
typedef int BOOL;

struct NODE;
typedef struct NODE Node;
typedef Node* PtrNode;
typedef PtrNode Stack;
typedef char DataType;

struct NODE{
    DataType data;
    PtrNode next;
};

BOOL IsEmpty(Stack s)
{
    return ((s!=NULL)&&(s->next == NULL));
}
Stack NewStack()
{
    Stack s = malloc(sizeof(Node));
    s->next = NULL;
    return s;
}

polynomial multiplication and addition implementation



Implementation of polynomial multiplication and addition using linked list


/*
   polynomial multiplication and addition implementation
*/

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

enum BOOL {FALSE, TRUE};
typedef int BOOL; // the more obvious choice would be char, but int is more
                  // time efficient as it uses a basic memory unit optimal for the
                  // particular processor design, by default

struct NODE;
typedef struct NODE Node;
typedef Node* PtrNode;
typedef PtrNode List;
typedef PtrNode Position;
typedef List Polynomial;
struct polyTerm {
    int degree; // the power of the taken term
    int coeff; // the coefficient of the term
};
typedef struct polyTerm DataType; // this is a default data type

struct NODE{ // single link list node
    DataType data;
    PtrNode next;
};
// vital ones>>>>>>>>>>>>>>>>>>>>>>>>>
PtrNode NewPoly() // returns the List's header
{
    PtrNode tempNode =  malloc(sizeof(Node));
    tempNode->next = NULL;
    return tempNode;
}
Position NewNode()
{
    // to do: add code to create the other parts of
    // the memory to be allocated.
    return malloc(sizeof(Node)); // for old compilers,
    // explicit type conversion like (Node) is needed to be
    //used.
}

Featured post

Why complicating matters is not good

“ Simplicity is the ultimate sophistication.” — Leonardo da Vinci Why is complicating things wrong ? - K Sr...