So every morning you do a series of tasks in a sequence: first you wake up, then you go to the washroom, eat breakfast, get prepared for the office, leave home, then you may take a taxi or bus or start walking towards the office and, after a certain time, you reach your office. Algorithms affect us in our everyday life. In fact, I think it’s not only important for software development or programming, but for everyone. Photo by bruce mars on Unsplash What is an algorithm?Īn algorithm is one of the most important concepts for a software developer. What is that? Any idea? No problem, let’s see. Wait, we have a new word here: “ Algorithm”. Now, let’s try to build the algorithm to solve the problem. You can see the animated image above for a better understanding. Let’s go through each of the steps:īoom! We have solved our problem. We can use B as a helper to finish this job. How do we do this?īefore we can get there, let’s imagine there is an intermediate point B. Our job is to move this stack from source A to destination C. No larger disk may be placed on top of a smaller disk.In other words, a disk can only be moved if it is the uppermost disk on a stack. Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack.Well, this is a fun puzzle game where the objective is to move an entire stack of disks from the source position to another position. Before getting started, let’s talk about what the Tower of Hanoi problem is.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |