Check out a free preview of the full Data Structures and Algorithms in JavaScript course:
The "Exercise: Deleting Single-Child Nodes" Lesson is part of the full, Data Structures and Algorithms in JavaScript course featured in this preview video. Here's what you'd learn in this lesson:

In this exercise, you will begin implementing the deleteNode() method. The deleteNode() method will search the tree for the passed value.

Get Unlimited Access Now

Transcript from the "Exercise: Deleting Single-Child Nodes" Lesson

>> Bianca Gandolfo: We're gonna scaffold our general remove node methods. That's gonna be in our exercise repo. So if we go to Exercises here,
>> Bianca Gandolfo: We're gonna start with the delete node method. And we're only gonna count for the first two cases.
>> Bianca Gandolfo: For general nodes.
>> Bianca Gandolfo: So the difference here, instead of the min and the max, is that you're gonna pass a value.

[00:00:32] You're going to have to search for that value.
>> Bianca Gandolfo: And then, you need to figure out if it has one children, or two children, or no children.
>> Bianca Gandolfo: For the case where it has two children, we'll just return. And we'll stop, and we're gonna, after our exercise, we're gonna come back, and we're gonna explore that next step.

>> Bianca Gandolfo: That make sense? You ready to go? Nice little warm-up? Cool. And the question that what should this return. Dimitri brought up a good point. If you wanna be able to chain, you could just return the entire tree at the end. Or if you want it to have more like a pop implementation, you might wanna delete the node, right?

[00:01:21] And you're gonna have to save that and delete it at the end.