Friday, March 6, 2009

4. Position of a number in a sorted array

4. How many comparisons are required to find the position of a number in a sorted array.

Answer: Using binary search it would require O(log n) comparisons.

Saturday, February 21, 2009

find the k largest or smallest numbers from a set of n numbers

3. How do you find the k largest or smallest numbers from a set of n numbers

Solution:

Build a min/max heap of size K from the available set.

Time complexity: n Log K

Tuesday, February 17, 2009

Reverse a string

This is one of my favourite and has several correct solutions.

2. Reverse a string.

The best way would be to loop through half of the sting and swap the characters at either end (without using an extra variable!)

Monday, February 16, 2009

A data-structure brain teaser for the day.

Hey guys,

Well I intend to put up a data structure related puzzle, problem, brain-teaser; whatever you wish to call it everyday from today. This is to keep my dedicated at keeping my skills sharp as I recently discovered that I'm faltering big time. So I shall shart off with a few basic old timer problems and then move on to more tricky problems. I shall provide a solution along with the problem and you can better it and enlighten me. So here goes.

1. How do you find loops in a single link list.

Tortise and Hair solution:
Use two pointers and move the first pointer at double the speed of the seconnd, ie, jump the first pointer by two two nodes while the second pointer moves one node at a time. If at any time the two point at the same node, there's a loop in the link list. If you reach the end of the list, there are no loops in the list.

I'm happy that I started this and hope to stick to my plan for a very long time.

Sunday, January 25, 2009

Images from shotgun & proto.in

Well for those who dont follow me on twitter (www.twitter.com/gsunil), I along with a couple of friends from work took part in a competition called shotgun startups. The challenge was to come up with a winning idea and build a working prototype all under 48 hours. We came 2nd and I really do think the team that came 1st deserved it. Here are the pics and links from both shotgun startup and the talks at proto.in.

Just a few points I wanted to mention rather than write a big post
1. Great experience participating, even greater experience winning, but I do believe everyone deserved to win for their work. Marketing/Presentation is where we won I guess.
2. Organization could have been quite a lot better for the shotgun item.
3. Met amazing pple and worth all the effort.


Working our asses off, I'm not kidding, our asses were all tired n asleep quite soon.



The bean bags that could have saved our asses.



Me presenting, with Rohan & Pradeep hiding (hidden) behind the podium.



Rohan and Pradeep doing their part, the actual demo which got us the 2nd place.



Tool to compute the cloud computing cost based on your requirements.



The winning team explaining their design of this really innovative lamp. Deserved to be on top.



Blackberry like service for a normal mobile. Alerts you when you get a mail.



Audience vote.



View from stage.



Leaving our foot print behind.

Saturday, January 24, 2009

Fog blankets bangalore

Early to bed, very early to rise and caught a wonderful sight




Above: View from my balcony
Below: Caught while walking my dog











The view really makes me miss ooty & kodai, places I used to visit very often as a kid. A visit is overdue I guess.

This is a treat after 2 hard days spent working on shotgun.proto.in where team phoenix (my team) were 2nd. Slept quite early (before 11, don remember when I last did that.......high school may be) as we havent been sleeping much during the event.

These pics were taken around 6:30 AM on 25th, January 09

Sunday, December 21, 2008

Marketing, the smart way

Marketing & Brand buildiing is always a challenge for new firms for two reasons
1. They are inexperienced in it
2. Its quite expensive

But there many cheap innovative marketing strategies I have come across so far. One of them is how the plastic company Cello built its brand in Chennai years ago. They ran advertisements in the morning paper that random calls will be made to residence in the city and if the call was answered by saying "Cello" instead of "Hello", they would win something. The entire city got grip of it and by eod, every household knew the word Cello and the company made its brand well known overnight.

Today I heard of another smart way a shoe company is marketing its products. Its taking advantage of a very public event. If you didnt get it still, its the Bush shoe throwing incident you can watch here. Apparently, Ramazan Baydan claims the shoe's were a model manafuctured by him, the Ducati Model 271, after which sales have sky rocketed.

I've heard a lot about how startups find marketing quite expensive but if an innovative idea or public event is used the end result can be far more rewarding.

Cheers to Ramazan Baydan.