Join Raghavendra Dixit for an in-depth discussion in this video Deleting an item: Case 2, part of Introduction to Data Structures & Algorithms in Java.
- [Instructor] Now in the second case,…the node to be deleted has one child.…For example, let's say we have to delete the node 72.…The second case is also not very difficult to handle,…so as you mean that we have found node 72 as current,…and its parent, which is node 78,…but now, as you can see,…that this node 72 has a left child, 70.…So if we set the left child of the parent to null,…node 70 will also be lost,…because it will lose contact from the tree.…All we want to do is to delete the node with value 72.…
What we need to do is to point the left child of the parent,…point to the child of the current node to be deleted.…That is, now, the left child of node 78 will become node 70,…and thus, node 72 will be ready for garbage collection.…Now what if that single child of node to be deleted…itself has children?…Well, as you can see, it doesn't really matter,…because all we are doing…is connecting the child of the node to be deleted…to the parent of the node to be deleted.…
So even if there is a sub-tree underneath it,…
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?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
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.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.