Prashnikaप्रश्निका

Binary tree and BST tool

Draw a binary tree and get what ISC Computer Science asks about it: the preorder, inorder and postorder traversals, the height and levels, leaves, internal nodes, and each node's parent, children and sibling. Build it by inserting values into a binary search tree, give it level by level, or rebuild it from two traversals.

Build the tree

Write - for a missing child. After a -, leave out its children.

Separate the values with commas or spaces.

Try: BST: 50, 30, 70, 20, 40, 60, 80BST: MANGO, BANANA, PEAR, APPLE, ORANGEA, B, C, D, -, E, Finorder + preorderinorder + postorder

The tree

DBEFCA

Traversals

Preorder (root, left, right)
A B D C E F
Inorder (left, root, right)
D B A E C F
Postorder (left, right, root)
D B E F C A
Level order
A B C D E F

About the tree

Root
A
Number of nodes (size)
6
Height = depth (edges from the root to the deepest leaf)
2
Levels (the root is at level 0)
3
Leaves (external nodes)
D, E, F
Internal nodes (not the root)
B, C
Full binary tree (every node has 0 or 2 children)
No
Complete binary tree
No
Binary search tree (inorder is in order)
No

Every node

NodeLevelParentLeft childRight childSiblingDegreeKind
A0-BC-2root
B1AD-C1internal
C1AEFB2internal
D2B---0leaf
E2C--F0leaf
F2C--E0leaf

Practise on real ISC questions

More Computer Science tools

All study tools ›