Describe an interesting problem and how you solved it.



Describe an interesting problem and how you solved it...

Answer / Archana Kumari

An interesting problem I encountered was the Tower of Hanoi. The goal is to move a stack of n disks from one peg to another using a third peg as auxiliary, with the following conditions: only one disk can be moved at a time, no disk may be placed on top of a smaller disk, and all disks are initially on one peg in decreasing order by size. To solve this problem recursively, I implemented a helper function that moves n-1 disks from the source peg to the auxiliary peg, moves the largest disk from the source peg to the destination peg, and then moves the n-1 disks from the auxiliary peg to the destination peg. The base case is when there is only one disk (n = 1), which can be moved directly from the source to the destination.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More HR Questions Interview Questions

tell me about your college life

4 Answers   DELL,


what support training would you require to be able to do this job?

1 Answers   Starbucks,


Responsibilities at a bank are pressing. Can you shoulder them?

1 Answers   Bank of Maharashtra,


Why did you apply for this particular job?

1 Answers   IOCL,


Tell me the courses you liked and why did you like them.

2 Answers   Microsoft,


What are your career plans at PNC Bank?

1 Answers   PNC Bank Financial Services,


is it possible to implement only sap hr without fico?

1 Answers  


what do you prefer- hard work or smart work?

1 Answers   IOCL,


Who inspired you in your life and tell me your family background?

1 Answers   Ittiam Systems,


How would you find the second largest element in an array using minimum no of comparisons?

1 Answers   Amazon,


What do you know about our bank?

1 Answers   IBPS,


You have switched 3 jobs in 2 years - why?

1 Answers   Allfon,


Categories