Join Raghavendra Dixit for an in-depth discussion in this video Deleting an item: Case 3, part of Introduction to Data Structures & Algorithms in Java.
- These are the first two cases that we have to consider…while deleting a node from a binary search tree.…Now, let's look at the third case.…In the third case, the node to be deleted has two children.…And this case is the most complicated of all.…Let's say we have to delete the node having data 33.…Now, this node 33 has two children, 25 and 39.…So, how do we delete this node?…Think about the options.…
Can we replace the node 33 with this node 39?…Well, if we do that, you can see that node 39…will have three children…and that is not a binary tree, right?…So, we cannot do that.…Well, we may try to connect these two nodes,…the parent and the right child of the node to be deleted.…But, if we do that, you can see that…this whole subtree will be lost.…So, we can't do that either.…Now, think about this. What we really want to do here is…find a replacement for node 33 from within the tree…such that none of the nodes are lost and the structure…of the binary search tree is also maintained.…
So, which node should come here?…
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.