The 'YOU' way of solving


Given an Array of size 9, with numbers from 1 to 10 in random order, find the missing number ?

This is a simple problem which can be easily algorithmified by any entry level software programmer. The purpose of this article is not about detailing the complexity or solution of the problem, but about the mind traversal of different solution architects towards the problem. As far as the word 'Approaching' is concerned, there are no rules, guidance or not even 'The Right Way' of solving a problem.

1.  The Turing Machine Way  (Array-Walk)

This is the common way most of the programmers are trained to attempt on such kind of logical question. Conceptually Turing Machine is head moving on a tape, forward and backward,  reading and updating data.

The approach is, traverse through the array with set of rules and update/mark the values based on the logic targeting the solution. In this case, traverse through a new array having of size 10 with numbers from 1-10 and take each element and traverse through the given array of size 9 asking each element whether the number is missing or included.

2. The Math Way

Some people always find solution through maths. The amazing fact is any particular problem in this world has a Math Way of solving. The axiom of Mathematical Science says, there is only one operation in Math, that is 1+1 =2 , this can be used to solve any given problem in this universe. Out-of-syllabus, skipping!!

Here, the math way approach is, always find a mathematical analogy of the problem.  A number is missing from a sequential set of numbers. Here is my take, and this is one among many  of the math ways of solving this issue.

Take the sum of the given array of size 9, and subtract the sum from 55, where 55 is the sum of 1-10 numbers.

Sum(1 to10) - Sum (Given Array) = Missing Number

3. The Real Life Analogy Way  

This is an interesting way of thinking solution for a problem, which I personally find has the best way for me in many occasions. Find the best analogy of the problem in real life. Let’s find out some analogy based on the given problem. There may be better analogies, this is something I could find while writing this article.

10 students going for a school tour and one student is missing in some occasion, find who is missing.  The usual way is every one himself check among a small set of students who was nearby previously and make sure that small group is still there. For all such small group iteration they easily find a name, who is missing.

Assume the numbers randomly entering to Array of 9 is those students (objects) who has the capability (method/function)  to find who is nearby to them in the Array of 10. When this question of who is missing happens, each number themselves check their small group and raise  a number (event) missing in the array. Suitable Object Oriented Model can be adapted to fit in this case.

There could be many ways for approaching a solution. However,  I believe there will be your way of approaching a problem, the challenge is to identify that be ready to evolve into a master in your approach, no matter, how difficult in actual implementation. It is perception, not perfection is important.  

Cheers

Sajith Amma







要查看或添加评论,请登录

社区洞察

其他会员也浏览了