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 tree for algebraic expression
- help regarding change color of tree node
- trees and more trees
- Reading Binary Files with Leading Binary Zeros
- Tree structure using jsf
- Tree View using database
- dataminig using Decsion tree
- Implement RPC in java without using RMI
- please help me ---- B Tree
- Why are there 2 different directory trees?
- Get a web site tree
- Depth first search and Breath first search ...
- Depth first search and Breath first search
- Splay tree apps
- Splay tree
- Splay tree
- Splay tree
- 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
- tree control
- Ternary trees
- javaScript tree structure