Skip to main content

Posts

Showing posts from 2015

HTTP 2 and How does it matters

Since a decade or so we have been using HTTP 1.1 for all kind server requests in application layer.There are a lot of latency issues when we used that for our traditional request response approach and the only thing we have found is hacks around this old HTTP 1.1 to suffice or solve a particular problem. Hence that created a need for new version of HTTP which addresses all these issues at foundational protocol level. I have been reading and exploring this a lot lately and have some useful things listed out as I explored it and can help even a beginner figure out HTTP 2. HTTP 2 SPDY  is a networking protocol introduced by Google in 2009. Its aim was to decrease web latency(time interval between request and response) and increase security. HTTP/2 is a clone of SPDY. Google has now stopped developing SPDY and started working on HTTP/2 with the same ideas of SPDY. HTTP2 is a binary protocol where as HTTP1.1 is an text based protocol  Here is a simple explanation to it : 

Write a program such that given a BST,return the size of largest subtree that lies within a given range[a,b].

Write a program such that given a BST,return the size of largest subtree that lies within a given range[a,b]. N.B: This  exact question was asked in a Google interview.  This problem when looked at first looks simple and may be for some it it but for me when it wasn't because when I started coding it I got all confused between recursions and the flow the algorithm will take.So i started simple on pen and paper tried for a couple of hours and could make it work . Point to be noted here is that the following approach here I took is not the most  efficient way but yes it does works perfectly. Steps or rather my thoughts : I had to touch each node so that I can calculate the size of the subtree in case the tree below and the node itself lied in the range.And after i calculate it I have maintained a global variable that stores the current max and when new value comes it compares it with existing one and updates it with the max value between them. To do so ,we

Graphs - DFS

Its been a while I posted because I had been busy with other stuff.From now on i would be posting basically what I learn and how I implement it in my journey of preparing for the best interviews. Now I am going to implement GRAPH DFS algorithm. Graphs as we all know many people tend to fear as we implement but once you start  realising  the underlying beauty and power of the data-structure, you can not hold yourself implementing it. Graphs can be represented as 2 ways: Adjacency lists or Adjacency matrices. Here I use adjacency list because as i am using java it pretty easy to implement it using Collections framework. DFS is pretty simple : Start with a node timestamp it and go deep and deep until u cannot go anywhere and then timestamp it. Finally you would end up creating a forest of multiple trees(Starting nodes). Code below is self explanatory and if any one has any queries please let me know. And the algorithm is direct implementation of book by Cormen (Intro