Algorithm to delete node from binary search tree, Data Structure & Algorithms

Assignment Help:

Algorithm to Delete Node from Binary Search Tree

To delete a node following possibilities might be arise

Node id a terminal node

Node have only one child

Node having 2 children.

DEL (INFO, LEFT, RIGT, ROOT, AVAIL, ITEM)

A binary search tree T is in memory and an ITEM of information is given. This algorithm deletes ITEM from the tree.

1.  [Find the locations of ITEM and its parent]

Call FINDS (INFO, RIGHT, ROOT, ITEM, LOC, and PAR).

2.  [ITEM in tree?]

if LOC=NULL, then write : ITEM not in tree, and Exit.

3.  [Delete node containing ITEM.]

if RIGHT[LOC] != NULL and LEFT[LOC] !=NULL then:

 Call CASEB(INFO,LEFT,RIGHT,ROOT,LOC,PAR).

Else:

 Call CASEA (INFO,LEFT,RIGHT,ROOT,LOC,PAR).

[End of if structure.]

4.  [Return deleted node to AVAIL list.]

Set LEFT[LOC]:=AVAIL and AVAIL:=LOC.

5.  Exit.

CASEB(INFO,LEFT,RIGHT,ROOT,LOC,PAR)


Related Discussions:- Algorithm to delete node from binary search tree

Trees, Have you ever thought about the handling of our files in operating s...

Have you ever thought about the handling of our files in operating system? Why do we contain a hierarchical file system? How do files saved & deleted under hierarchical directories

Pseudo code, I need help writing a pseudocode for my assignment can anyone ...

I need help writing a pseudocode for my assignment can anyone help?

Algo for quicksort, Easy algorithm for beginner for quicksort with explanat...

Easy algorithm for beginner for quicksort with explanation

Array implementation of lists, In the array implementation of the lists, we...

In the array implementation of the lists, we will use the array to hold the entries and a separate counter to keep track of the number of positions are occupied. A structure will b

Different ways for representing s graph, W h at are the different ways by...

W h at are the different ways by which we can represent graph?  Represent the graph drawn below using those ways.     T he d iff e r e nt w a y s by

Procedure to delete all terminal nodes of the tree, Q. Let a binary tree 'T...

Q. Let a binary tree 'T' be in memory. Write a procedure to delete all terminal nodes of the tree.       A n s . fun ction to Delete Terminal Nodes from Binary Tree

Brute force, Determine the number of character comparisons made by the brut...

Determine the number of character comparisons made by the brute-force algorithm in searching for the pattern GANDHI in the text

Efficient algorithms.., implementation of fast fourier transforms for non p...

implementation of fast fourier transforms for non power of 2

Sorting algorithm for singly linked lists, Q. Which sorting algorithm can b...

Q. Which sorting algorithm can be easily adaptable for singly linked lists? Explain your answer as well.        Ans: The simple Insertion sort is sim

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd