Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts
Sunday, March 4, 2012
A tutorial on trees
I came across this site eternally confuzzled which seems really good on data structures, specially trees and thought of sharing it..Hope it's useful :)
Labels:
graphs,
programming,
tutorial
Monday, December 12, 2011
divisibility by 7
Hi, recently i came across a problem where it was required to check if a number is divisible by 7 . Though quiet an elementary task, i think its not very commonly known. This is what i found.
Test 1:
Reverse the number . Mulitply each digit of this reversed number by the digits 1(=1%7),3(=10%7),2(=100%7),6(=1000%7),4(=10000%7),5(=100000%7) consequtively till all digits are covered. Sum the products. If this value is divisible by 7 then the original number is too.
Actually these numbers are the cyclic remainders of division by 7.
Test 2:
Take the last digit of the number and subtract it from the number formed by the remaining digits.If this value is divisible by 7 then the original number is too. We can do it recursively to reduce the number .
Hope that helps.
Test 1:
Reverse the number . Mulitply each digit of this reversed number by the digits 1(=1%7),3(=10%7),2(=100%7),6(=1000%7),4(=10000%7),5(=100000%7) consequtively till all digits are covered. Sum the products. If this value is divisible by 7 then the original number is too.
Actually these numbers are the cyclic remainders of division by 7.
Test 2:
Take the last digit of the number and subtract it from the number formed by the remaining digits.If this value is divisible by 7 then the original number is too. We can do it recursively to reduce the number .
Hope that helps.
Labels:
mathematics,
programming
Thursday, October 20, 2011
Pointers
Hi, recently came across an article which through some questions, has great explanation of pointers . They show that arrays are not pointers which is common pitfall.
Here's the link:
Pointers
Njoy reading. :)
Here's the link:
Pointers
Njoy reading. :)
Labels:
pointers,
programming
Monday, September 5, 2011
Some pearls of wisdom
Recently i came across few articles which were very inspiring especially for programmers.
They generally are concerned about how one must learn a language, start programming and ask relevant questions
Here are the links:
They generally are concerned about how one must learn a language, start programming and ask relevant questions
Here are the links:
How to ask the smart way
Short simple examples
Why everyone's in a rush?
Labels:
pearls,
programming,
wisdom
Saturday, August 13, 2011
Finding whether a point lies inside a polygon
Hi, it's been a really loong break. Well after getting into the corporate world, you hardly get time!
I recently came across a problem TETRAHED in SPOJ which asks us to find whether a point lies inside a tetrahedron or not.
It seems quiet an interesting problem as the solution can be extended to any polygon.
In this we need to find the barycenters of the required point and then check the signs of the barycenters. If they are same then we can say that the point lies inside the region.
The problem has its application in geometric modelling and in graphics.
Enjoy!!
IMPORTANT LINKS:
1.My DISCUSSION
2.triangle centers
3 tutorial
I recently came across a problem TETRAHED in SPOJ which asks us to find whether a point lies inside a tetrahedron or not.
It seems quiet an interesting problem as the solution can be extended to any polygon.
In this we need to find the barycenters of the required point and then check the signs of the barycenters. If they are same then we can say that the point lies inside the region.
The problem has its application in geometric modelling and in graphics.
Enjoy!!
IMPORTANT LINKS:
1.My DISCUSSION
2.triangle centers
3 tutorial
Labels:
mathematics,
programming,
spoj
Subscribe to:
Posts (Atom)