Friday, October 12, 2012

How would you implement trending topics for twitter. Think at large scale as well.


Design a system where you can reutrn top 20 queries made in last 24 hours to users. Think on the scale of Google and Yahoo. How would you store data. What will be your data structures, algorithm to get that data.Describe your assumptions etc. For simplicity, you can assume that every web server create a log file with query and timestamp.


A legend among a group of n people is a person who is top rated in all respects.The task is to identify a legend by asking a single question of the form "who deserves it?" Design an efficient algorithm to identify a legend or determine if the group has no such person.How many questions does your algorithm need in the worst case??


Monday, September 24, 2012

You have N computers and [Ca, Cb] means a is connected to b and this connectivity is symmetric and transitive. then write a program which checks that all computers are interconnected and talk two each other

I Believe there are multiple way to solve this problem 1. Here is my approach since graph is connected there will be path from each source to destination vertex , isn't it ? so we can simply run a dfs or bfs for all computers to check if all such path exist , finally we can return & of all operation that means all computer are inter connected and can talk to each other . PS.Since graph is undirected if there exist path from u to v then vice-verse also true so we wont calculate it again.

Write a function to convert Hexadecimal number (String) to Decimal Number (Int)