Join Raghavendra Dixit for an in-depth discussion in this video Tower of Hanoi: Implementation, part of Introduction to Data Structures & Algorithms in Java.
- [Instructor] Before explaining the implementation,…let me run the program to show you…what exactly needs to be done,…just in case you're not aware of this problem.…So we are supposed to implement this move method,…such that it takes these parameters,…which was already discussed earlier.…And we call this move method from the main method.…Like here, we say,…move two discs from tower A to tower C, using tower B,…all right?…And when we run this program,…we get the exact sequence of the steps…that are supposed to be executed to complete this task.…
So, as you can see, we first move disc one from A to B,…then move disc 2 from A to C,…and finally move disc 1 from B to C.…Similarly, let's try to create the steps for three discs.…So, if you have understood the problem,…pause the video here, and implement it before moving on.…So let's just start implementing the move method.…
As you can see, we just have these three lines of code here,…which we have already seen earlier in the animation.…So, what we are essentially doing is that…
Note: This course was created by Packt Publishing. We are pleased to host this training in our library.
- Why study data structures and algorithms?
- How to calculate the time complexity
- Using Big O notation
- Using basic sorting and search algorithms
- Searching elements in unordered arrays and ordered arrays
- Implementing a linked list in Java
- Implementing stacks using arrays
- Queues using arrays
- Binary search trees
- Representing heaps using arrays
Skill Level Intermediate
1. Introduction to Algorithms
2. Analysis of Algorithms
3. Basic Sorting and Search Algorithms
4. Linked Lists
5. Stacks and Queues
7. Binary Search Trees
8. More Sorting Algorithms
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.