Skewed Tree Visualizer
A tree in which all nodes are on either the left side or the right side. Insert, delete, edit and search with step-by-step animation.
How to use the Skewed Tree Visualizer on KickSolve
Three quick steps, no account needed.
Why choose KickSolve
Built for learning, speed and privacy.
What you can do with the Skewed Tree Visualizer
Everything this tool offers.
About the Skewed Tree Visualizer on KickSolve
What it does and how to get the best results.
What is a skewed tree?
A skewed tree is a binary tree in which all nodes lie on one side. In a left skewed tree every node has only a left child, and in a right skewed tree every node has only a right child. It is a degenerate tree that never changes direction.
Key properties
- Every node has at most one child
- All children are on the same side
- A tree with n nodes has height n
- Only one leaf, at the bottom of the chain
Operations and time complexity
Search, delete and traversal take O(n). Finding the end of the chain to insert is also O(n), so a skewed tree is no faster than a linked list.
Why it matters
- The worst case for binary search trees
- Shows why balancing matters
- Appears when sorted data goes into a BST
- Behaves like a linked list
Comparing tree shapes? Try the Degenerate Tree, Binary Search Tree or Balanced Binary Tree visualizer.
Worked example: building a small skewed tree
The same steps the visualizer animates for any input.
Set Skew direction to Right, then insert 1, 2, 3, 4. 1 is the root, 2 is its right child, 3 is the right child of 2, and 4 is the right child of 3. Preorder: 1 2 3 4 Inorder: 1 2 3 4 Postorder: 4 3 2 1 Level order: 1 2 3 4 Now set Skew direction to Left and insert 5. The whole tree mirrors to the left, then 5 becomes the left child of 4. Preorder: 1 2 3 4 5 Inorder: 5 4 3 2 1
The tree always has 1 leaf, and its height equals the number of nodes.
Traversals on a skewed tree
The same four nodes, 1 down to 4, in each direction.
| Traversal | Right skewed | Left skewed |
|---|---|---|
| Preorder | 1 2 3 4 | 1 2 3 4 |
| Inorder | 1 2 3 4 | 4 3 2 1 |
| Postorder | 4 3 2 1 | 4 3 2 1 |
| Level order | 1 2 3 4 | 1 2 3 4 |
Skewed vs degenerate trees
Every skewed tree is degenerate, but not the other way round.
| Type | Rule | Child sides |
|---|---|---|
| Left skewed | Every node has only a left child | Left only |
| Right skewed | Every node has only a right child | Right only |
| Degenerate | One child per parent, sides may mix | Left and right |
| Balanced | Left and right heights differ by at most 1 | Both sides |
Skewed vs balanced search cost
The most steps needed to find a value.
| Nodes | Steps in a skewed tree | Steps in a balanced tree |
|---|---|---|
| 1 | 1 | 1 |
| 3 | 3 | 2 |
| 7 | 7 | 3 |
| 15 | 15 | 4 |
| 31 | 31 | 5 |
| 63 | 63 | 6 |
| 127 | 127 | 7 |
| 255 | 255 | 8 |
| 511 | 511 | 9 |
| 1023 | 1023 | 10 |
Skewed Tree FAQ
Quick answers.
What is a skewed tree?
A tree in which all nodes are on either the left side or the right side. Every node has only one child, and all of those children lean the same way.
What are left skewed and right skewed trees?
In a left skewed tree every node has only a left child. In a right skewed tree every node has only a right child.
Is a skewed tree the same as a degenerate tree?
A skewed tree is a special case of a degenerate tree. Both have one child per parent, but a skewed tree keeps every child on the same side.
What is the height of a skewed tree with n nodes?
The height is n levels. The tree is as tall as it can possibly be for n nodes.
What is the time complexity of a skewed tree?
Search and delete take O(n) because they may walk the entire chain. Insert at the end also takes O(n) here, since the end has to be found first.
How do traversal orders differ on a skewed tree?
In a right skewed tree preorder, inorder and level order are the same and postorder is the reverse. In a left skewed tree preorder and level order are the same, while inorder and postorder are the reverse.
Can a binary search tree be skewed?
Yes. Inserting values in ascending order gives a right skewed BST, and descending order gives a left skewed BST. Searching then costs O(n).
How do I build a skewed tree in the visualizer?
Choose Left or Right in Skew direction, type a value and press Insert. The first value becomes the root, and every new node is added at the end of the chain on that side.
What happens if I change the skew direction?
The whole tree mirrors to the new side first, so every node stays on one side, and then the new node is added.
How do I delete a node in the visualizer?
Type the node or click it, then press Delete. Its child takes its place, so the tree stays skewed.
Can I undo a change?
Yes. Press Undo to step back through your last 40 changes. Clear and Random can also be undone.
Is the visualizer free and private?
Yes. It is free with no signup, and everything runs in your browser. Nothing you type is sent to a server.
More free tools from KickSolve
Other tree visualizers.