Designing an efficient algorithm to solve a problem in computer science is a skill which makes you a real geek. Once u are comfortable with a programming language, the next step is to write efficient code to solve problems of different levels of difficulty. That said, thinking of an efficient algorithm is independent of programming language. Algorithms are simply a set of instructions followed in a logical order to solve a problem. It existed even before first programming language originated.

Let’s get back to the point. One needs to have a decent knowledge of a programming language to implement the generic solution to a problem. Efficiency in terms of time and memory is the most vital part of any algorithm. It is measured and represented with the term ‘complexity’.

On a brief note, if we are given an input data set of size n, and we need to iterate over each element of the set once to solve a problem with the given set, the complexity is O(n) or Order(n) [‘O’ is known as “big oh” notation]. For e.g, there are 6 elements { 5,2,7,8,1,3 } i.e n = 6. To find the largest no., we have to visit each element once. So it’s complexity is O(n). There are other notations to express complexity which we will cover in some other sections. But the point is we should try to think of best possible way to solve a given problem. Suppose you are getting interviewed by any of the firms mentioned above, if you give a naive approach for a problem, the follow up question will definitely demand an efficient approach.

So, with all these points in mind, let’s get motivated to see some efficient approaches for some algorithmic problems. The set of problems solved here is not an exhausted list but it will give an idea to think efficient algorithms and implement it. All solutions are implemented with C++.

Ok then, let’s not get overwhelmed with more theory, and get practical and orient ourselves towards problem solving . Thus, understand the problems, try to think of best possible approach to solve it before seeing the solution.

About    Contact    Sitemap    Terms    Privacy