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

#title., Ask quapplication of data structure estion #Minimum 100 words acce...

Ask quapplication of data structure estion #Minimum 100 words accepted#

Flow chart, What is tha flow chart of algorithm

What is tha flow chart of algorithm

Explain th term input and output- pseudocode, Explain th term input and ou...

Explain th term input and output-  Pseudocode Input and output indicated by the use of terms input number, print total, output total, print "result is" x and so on.

State in detail about the integer, State in detail about the Integer ...

State in detail about the Integer Carrier set of the Integer ADT is the set {..., -2, -1, 0, 1, 2, ...}, and  operations on these values are addition, multiplication, subtrac

Binary search trees, In this unit, we discussed Binary Search Trees, AVL tr...

In this unit, we discussed Binary Search Trees, AVL trees and B-trees. The outstanding feature of Binary Search Trees is that all of the elements of the left subtree of the root

Data Warehousing, Assume you are in the insurance business. Find two exampl...

Assume you are in the insurance business. Find two examples of Type 2 slowly changing dimensions in that business. As an analyst on the project, write the specifications for applyi

Abstract data type-stack, Conceptually, the stack abstract data type mimics...

Conceptually, the stack abstract data type mimics the information kept into a pile on a desk. Informally, first we consider a material on a desk, where we might keep separate stack

Avl tree, Example: (Single rotation into AVL tree, while a new node is inse...

Example: (Single rotation into AVL tree, while a new node is inserted into the AVL tree (LL Rotation)) Figure: LL Rotation The rectangles marked A, B & C are trees

Which is the most suitable data type, Problem 1. You are asked to store...

Problem 1. You are asked to store Names of all 100 students of class A in your Learning Centre. Which data type will you use? What is its syntax? Explaining the data typ

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