0% found this document useful (0 votes)
13 views1 page

Pseudo Code

The procedure 'Addnode' adds an input value to a binary tree structure stored in an array. It checks if there is space available and navigates through the tree to find the correct position for the new node. If the tree is full, it outputs a message indicating that the tree cannot accept more nodes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

Pseudo Code

The procedure 'Addnode' adds an input value to a binary tree structure stored in an array. It checks if there is space available and navigates through the tree to find the correct position for the new node. If the tree is full, it outputs a message indicating that the tree cannot accept more nodes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

PROCEDURE Addnode(input)

IF freePointer <= 19 THEN


Array_binary[freePointer, 1] <--- input
currentPointer <--- rootPointer
WHILE currentPointer <> -1
IF input < Array_binary[currentPointer, 1] THEN
addPointer = currentPointer
currentPointer <--- Array_binary[currentPointer, 0]
IF currentPointer = -1 THEN
Array_binary[addPointer, 0] <--- freePointer
freePointer <--- freePointer + 1
OUTPUT "Data entered!!"
END IF

ELSE IF input > Array_binary[currentPointer, 1] THEN


addPointer = currentPointer
currentPointer <--- Array_binary[currentPointer, 2]
IF currentPointer = -1 THEN
Array_binary[addPointer, 0] <--- freePointer
freePointer <--- freePointer + 1
OUTPUT "Data entered!!"
END IF

END IF

END WHILE

ELSE
OUTPUT "tree full"
END IF

END PROCEDURE

You might also like