Search: | |||||

| ||||

Home » Forum » Java | RSS Feeds |

for one of my classes i have to implement a binary search tree

using Nodes, where each node has a key value, a reference to the left

child, and a reference to the right child.

The problem i am having is implementing "remove(int key)". this

method takes a key parameter and removes the node in the tree with

that key. It's really difficult because after you find the node and

remove it, you can't have empty nodes, so you have to rearrange the

tree to make it correct.

Tree-Delete (T, x)

if x has no children case 0

then remove x

if x has one child case 1

then make p[x] point to child

if x has two children case 2

then swap x with its successor

perform case 0 or case 1 to delete it

Sounds like you need to cross link the left and right children to each

other after deleting (or maybe before),

rather than to the node you are deleting (which is what they are linked

to before the delete).

Didn't find what you were looking for?
Find more on Implement a binary search tree using Nodes
Or get search suggestion and latest updates.

Related Topics:

- Binary Search Tree
- Binary Search Tree
- binary search tree
- Binary tree for algebraic expression
- help regarding change color of tree node
- trees and more trees
- Reading Binary Files with Leading Binary Zeros
- Program of binary search with process output
- dataminig using Decsion tree
- Tree structure using jsf
- Tree View using database
- Implement RPC in java without using RMI
- Depth first search and Breath first search ...
- Depth first search and Breath first search
- JSP Tree Tag Examples
- Dynamic tree with richfaces and ajax tech
- I need help on richfaces tree component , i want to use RIGHT to LEF
- convert binary digits to decimal
- storing binary files in blob fields from a servet
- tree control
- Ternary trees
- search string in text file using JAVA
- javaScript tree structure
- VBA Binary variable/constant type ?
- Can we write RAM data in a binary file in the hard disc