We discussed problem of Tower of Hanoi earlier and written a recursive function to solve the problem, Recursive functions take lot of extra memory (New activation record for each call on the stack) (A detailed analysis of recursion is done in this post of mine). Todays question is to write a Non-recursive function to solve […]
Tower of Hanoi is a Mathematical Game. There are 3 pegs (Rods) and number of discs, each of different size, which can be inserted into the rods. All discs are initially inserted into one rod in increasing order (smallest at the top and largest disc at the bottom). You have to move all the discs […]
Those who use languages like C and C++ that support user defined pointer variables, put utmost emphasis on implementing the pointers correctly. And rightfully so, A pointer wrongly handled can be catastrophic. And that’s an understatement 🙂 .
One Definition Rule (ODR) In C++, declaration does not allocate any memory. Its only when an object (or function) is defined that an instance of it is created. The One definition Rule says that there cannot be more that one definition in a single translation unit of C++.