Insertion in Binary Tree based on parent node | Custom comparator in Apex | Apex Data Structures

Опубликовано: 06 Декабрь 2024
на канале: SFDC Stop
955
16

Hello Trailblazers, In this tutorial we're going to see how we can insert a new node in binary tree recursively based on the parent node. We're going to refer the code we created in our previous tutorial and add a new insertData() method which is going to accept the new data, the parent data and a comparator class. Then it's going to compare if the parent data is equal to the data of any node in the binary tree or not, in case we find such a node, we're going to consider that node as our parent node and we'll link the new node as a child of the parent node. If not, we'll return NULL which means the node cannot be inserted in our binary tree.

Chapters:
0:00 Introduction
1:00 Insert Data Method Explanation
5:14 Insert Data Recursive Method Explanation
20:55 Revision
22:40 Use case: If the parent node is not found anywhere
24:00 Comparator class
24:50 IntegerCompare class
26:16 Code Execution
28:35 Possible use case
29:40 Wrapping Up
30:12 Time Complexity Analysis
31:42 Resources

Blog: https://www.sfdcstop.com/2021/07/inse...

Code: https://github.com/rahulmalhotra/apex...

Previous Tutorial Video:    • Binary Tree implementation in Apex | ...  

Subscribe to SFDC Stop:- https://www.youtube.com/c/sfdcstop?su...

LWC Todo App Project Tutorial Series -    • Simplifying the Callouts in Salesforc...  

Interested in learning about Scratch Orgs and SFDX ? Have a look at the playlist:-    • Getting started with Scratch Orgs and...  

Interested in learning about Integration ? Have a look at this playlist:-    • Salesforce Integration Tutorial Series