Is our brain really that intelligent?
Can puzzles like (2 eggs,100 floor) , Calculation of prime numbers using "sieve of Eratosthenes",Calculating middle of linked list with Floyd cycle algorithm strike any one's mind instantly.Let's consider Floyd algorithm for determining middle of linked list.At the max,my brain can think of this solution-:
a)Count the total number of elements
b)Take the floor value of the count calculated in point a) above
c)Traverse the linked list till number calculated in point b) above
d)After traversing till the mid point print the value of linked list's data.
Time complexity is O(n),Space complexity is O(1)
No matter how hard I think,can Floyd algorithm really strike my mind.Well I don't think so.For all those who don't know about Floyd cycle algo let me brief you about it.
**Use two pointers.Move one pointer at twice the speed of second,When the first pointer reaches the end of list,the second pointer should be in the middle.
Do let me know if such thinking, requires some special efforts or simply practicing and mugging as much as you can!!
Technical head at Carvemylife
8 年I think,a lot of practicing can develop a human brain to think in an advanced way.