QuickSort Algorithm in Javascript

So I was reading algorithms and was working on implementation of quick-sort in javascript, since this the language I’m totally love in. This is a great algorithm for sorting compared to insertion sort since it takes O(nlogn) processing time over O(n2) for insertion sort.

So if you are too concerned about performance of your sort function or if your web application needs to perform sorting on large data sets then this is the sorting that you should definitely use, Since directly using javascript’s array.sort() will implement merge-sort subroutine. Even though both merge-sort and quicksort consume the same time i.e their time is O(nlogn) but merge-sort creates new sub arrays and this will consume more memory. And since javascript runs in a single thread and if your dataset is really really huge, the tab/window may hang for some while or may end up dead.

Here is a Gist of the implementation. https://gist.github.com/vaibhavtolia/6747303

Advertisements

You have a startup idea, what should you do now?

Alright, you have an idea, you love it and you are ready to do whatever it takes to bring it to life, but you should not jump to idea of starting up so soon. ‘99% of startups fail‘, it is not because they lack skills or their idea wasn’t superb enough, the major reasons are they were not prepared for the challenges ahead. Before you actually decide to start a business –

Evaluate the idea – every idea has a potential of making money, but how much, in what ways (what all possible revenue models), how it will scale. Get an unbiased view of an expert on the idea – he/she will tell you about the major pitfalls. Once you are sure of the sustainability of operations and development (not from VCs or angels money), go ahead.

Build a great Team – the greatest of the ideas can fail miserably if not executed properly. You need to nurture a team which shares the same ideals and concerns as You. They should possess skills necessary to execute the idea. When looking for a co-founder do not go for a guy who fills the skill set required (you are hiring an employee then). Find a person who shares the same concern, the skill set and ability to scale the business. For eg, when looking for a Tech Cofounder, don’t just go for a great Engineer, find someone who has the skills but can also hire, nurture a team and ship great product in timely manner.

Make products with utility not beauty – your product should not solve the same issue that other tens of products are doing, just that you are doing in a ‘better’ or ‘user friendly’ way. No, it won’t work for most of you. Find utility the customers will get out of it, and it should not be marginal. Marginal improvements over existing solutions is not going to work. You need to take a leap, shift curves of imagination and utility.

Give it in hands of superusers – you love your brainchild, everyone does. Learning about its shortcoming is a not an easy task. Give it to some superusers – people who live in the real world, face the issue you are trying to address and are really good critics. Learn from their feedbacks, improve upon the shortcomings and release a beta version.

Market it great – ‘Good products don’t need marketing‘ – its true if you have all your life to wait for it to go viral. Greatest of all products need loads of marketing in the right manner to catch the attention of potential customers and make them hold on to it. The attention span of internet users is very low, if you don’t catch the eyeballs right away, your product stands very less chances of going viral.

Iterate and Improve – One thing most of startups fail to do is, they don’t iterate. Learn from user analytics, insights, feedbacks, keep on iterating, try new things that improves the experience of your user or customer. Here is a quote I personally admire a lot

Speed of iteration outbeats the quality of iteration.

Keep on improving your product before trying to diversifying it. Follow the Lean startup principle – Keep It Simple. Don’t try to do many things, find a very basic problem try to solve it, in a way which provides the most utility to customers. Try to increase the marginal utility of using your product everyday.