Posts

Showing posts from 2017

Case Study - Part1

Real world Case studies How your email works? We receive hundreds of emails per day in our inbox for example in our Gmail. Essentially it requires servers to take all the  incoming mails that comes to your emailid , process them properly and show them in your beautiful ui. So some stages that can come in between can be like Take the incoming mail Check for Virus Parse the email Do Spam Checks. Deliver to mailbox Index the emails for search. If you look at real metrics, there could be billions of mails that can come per day for multiple users. So what are the real ways in which these real world  applications can scale ? For example, what could be possible ways in which Gmail can scale to process billions of emails per day. ? Solution: Bring in queues for each and every process. User facing servers should be offloaded to increase the speed. All heavy processes needs to be done offline via queue.. Basically, all heavy processe...

Animation for String search - KMP Algorithm

This is a beautiful and interactive animation to understand how KMP Algorithm works. Mix and match with different inputs and give a try. Failure Function: Represents function to lookup if there is a mismatch in pattern and txt strings. Search Button: Represents how search works . Animation for KMP Algorithm Credits & Copyright to : This is an embedded link from http://www.cs.usfca.edu/ . Credits to original contributor as given in below copyright. Copyright 2011 David Galles. Copyright 2015 Yves Lucet. Available under the FreeBSD license.

Interactive Data Structure visualizations/animations for algorithms

These are the beautiful and interactive animations to understand various data structure algorithms. Mix and match with different inputs and give a try. If you have any doubts about how these algorithms work, drop a comment. Will get back to you. Visualizations for Data-structure algorithms Credits & Copyright to : This is an embedded link from http://www.cs.usfca.edu/ . Credits to original contributor as given in below copyright. Copyright 2011 David Galles. Copyright 2015 Yves Lucet. Available under the FreeBSD license.

Solution - Rearrange characters in a string such that no two adjacent are same

Rearrange characters in a string such that no two adjacent are same: To view question , click here http://www.interviewrack.com/2017/03/rearrange-characters-in-string-such.html Prerequisite :  priority_queue . The idea is to put highest frequency character first (a greedy approach). We use a priority queue (Or Binary Max Heap) and put all characters and ordered by their frequencies (highest frequency character at root). We one by one take highest frequency character from the heap and add it to result. After we add, we decrease frequency of the character and we temporarily move this character out of priority queue so that it is not picked next time. We have to follow the step to solve this problem, they are: 1. Build a Priority_queue or max_heap,  pq  that stores characters and their frequencies. …… Priority_queue or max_heap is built on the bases of frequency of character. 2. Create a temporary Key that will used as the previous visited element ( prev...