Skip to main content

Posts

Yahoo News Digest - Now on Android - Adds International and Canadian Editions

Link: Yahoo News Digest - Now on Android - Adds International and Canadian Editions yahoo : By Nick D’Aloisio, Product Manager, Yahoo News Digest When we launched the Yahoo News Digest in January for iPhone users in the United States and United Kingdom, our goal was to ensure that our audience is “in the know” of the top news and information in the shortest amount of time, all while…

Suffix Trees , a bit complicated but really powerful data structure

Continuing with my obsession with the string matching algorithms , after  KMP algorithm which does string matching in O(n +k) time , where n is length of the string and k is the length of the pattern. I tried exploring another data structure called as “Suffix Trees” , Suffix trees are nothing but compressed tries , where you model all the suffix present in a string in an optimized tree/trie structure. this is how a suffix tree for word “BANANA” will look like some of the other common use cases , where suffix trees can be used is  Find the longest common substring of the strings S and T. This can be done in time O(|S| + |T|) Find the longest substring of S that appears at least m > 1 times. This query can be answered in O(|S|) time. Traverse the suffix tree labeling the branch nodes with the sum of the label lengths from the root and also with the number of information nodes in the subtrie. Traverse the suffix tree visiting branch nodes with information node co...

Ruby implementation of the famous Knuth–Morris–Pratt Algorithm

today just decided to write the   Knuth–Morris–Pratt string searching algorithm  , implementation in ruby.  As you can see that the algorithm is divided into two parts , one is the preprocess , which is the crux of the Algo and the actual string searching using the preprocessed metadata. The preprocess function is run only on the patterns, and it calculates π[i] = the longest proper prefix of pattern[0..i] , which is also a suffix of pattern[0..i]. e.g. if the pattern you are searching for is  P = [ ‘A’,'B’,'A’,'B’,'A’,'C’,'A’] the π array will look like π = [ 0,0,1,2,3,0,1] which shows that longest running prefix of the pattern is ABA . Buy doing the above calculations the algo saves itself some of the comparisons which it had to do in the naive , brute force approach. if you get the preprocessing function then the rest of the things are straight forward , the algorithm is intelligent enough to understand that if next char in the seq does...

HATEOAS - Hypermedia as the Engine of Application State

Just came across this term HATEOAS , which some of my team members were using in describing what we did in our previous project wrt to REST. My Last project was about building an e-commerce platform for one of the largest book publisher and distributor in Latin America.As part of that project we had thought to use the LEVEL-3 for rest communication which is using REST as a hypermedia controls.  You can read about different levels of REST at this Martin Fowler’s Blog  . When we said we wanted to use REST as hypermedia controls , the main idea behind this was to be able to navigate the result of a REST call. For Example if there is a product catalogue call which looks like GET /products/123456 So It would return  As you can see that apart from the the properties of the product 123456 it also has a links array. This links array contains the the link description in rel and the location of that document. so essentially what i could do is parse the JSON response , and then look for wha...

The dam which has slowed down Earth's rotation!

Link: The dam which has slowed down Earth's rotation! China'™s Three Gorges Dam is world'€™s largest hydroelectric station. First envisioned in 1919 and finally completed in 2012, the dam spans the Yangtze River and measures 2.3 kilometers (1.4 miles) long and 185 meters (607 feet) tall. Almost 30 million cubic meters (just over 35 million cubic yard…