KickSolve • Free • Private

Degenerate Tree Visualizer

A tree in which each parent has only one child, resembling a linked list. Insert, delete, edit and search with step-by-step animation.

One child per parentAll four traversalsLive shape checks

How to use the Degenerate Tree Visualizer on KickSolve

Three quick steps, no account needed.

Type a value and a sideEnter a value, choose Left or Right in Insert on side, then press Insert. The first value becomes the root. Every later value is added below the last node of the chain.
Press Insert, Delete, Edit or SearchInsert walks down the whole chain to its end. Delete removes a node and its child takes its place. Orange is a new node, red is being deleted and green is found.
Run a traversalUse the traversal buttons to see preorder, inorder, postorder and level order output, and check the Degenerate, Left skewed and Right skewed badges on the right.

Why choose KickSolve

Built for learning, speed and privacy.

Private by designEverything runs in your browser. Nothing you type is ever sent anywhere.
Animated, step by stepWatch every visit and placement as it happens, at a speed you choose.
Linked list shapeWatch a tree with one child per parent turn into a linked list as it grows.
Undo and experimentStep back through your last 40 changes, or generate a random tree to explore.

What you can do with the Degenerate Tree Visualizer

Everything this tool offers.

InsertAdd a node below the last node of the chain, on the left or right side you choose.
DeleteRemove a node. Its child takes its place so the chain stays unbroken.
EditChange a node's value in place without moving it.
SearchScan the tree and highlight the first node that matches.
PreorderRoot, then left, then right.
InorderLeft, root, right. The order depends on which sides the chain uses.
PostorderLeft, right, then root.
Level orderBreadth first. In a chain this is simply top to bottom.
Shape checksBadges show whether the tree is degenerate, left skewed, right skewed, balanced and ordered.
Copy and downloadCopy the tree as an image or save it as a PNG for notes and slides.
Click to selectClick any node to fill in the target box for delete or edit.
Random and UndoGenerate a random degenerate tree, or step back through your changes.

About the Degenerate Tree Visualizer on KickSolve

What it does and how to get the best results.

What is a degenerate tree?

A degenerate tree, also called a pathological tree, is a tree in which every parent has only one child. It has the shape of a linked list: each node has one child, which has one child, and so on.

Key properties

  • Every parent node has exactly one child
  • Only one leaf, at the bottom of the chain
  • A tree with n nodes has height n
  • The child can be on the left or the right at each step

Operations and time complexity

Search, insert at the end, delete and traversal all take O(n), because every operation has to walk the chain. A balanced tree does the same work in O(log n).

Why it matters

  • The worst case for binary search trees
  • Shows why self-balancing trees exist
  • Behaves like a linked list
  • Can cause deep recursion and stack overflow

Comparing tree shapes? Try the Skewed Tree, Binary Search Tree or Balanced Binary Tree visualizer.

Worked example: building a small degenerate tree

The same steps the visualizer animates for any input.

Insert 1: it becomes the root.
Insert 2 on the Right: right child of 1.
Insert 3 on the Left: left child of 2.
Insert 4 on the Right: right child of 3.
Every parent has exactly one child, but the sides are mixed.

Preorder:    1 2 3 4
Inorder:     1 3 4 2
Postorder:   4 3 2 1
Level order: 1 2 3 4

The tree has 4 nodes and height 4, with one leaf. Because the sides are mixed it is degenerate but not skewed.

Degenerate Tree traversals compared

When each node is visited relative to its children.

TraversalOrderTypical use
PreorderRoot, left, rightCopying a tree, prefix expressions
InorderLeft, root, rightSorted output from a binary search tree
PostorderLeft, right, rootDeleting a tree, postfix expressions
Level orderLevel by level, left to rightShortest path, printing by depth

Degenerate tree shapes

How the chain can lean.

ShapeRuleChild sides along the chain
DegenerateEvery parent has exactly one childAny mix of left and right
Left skewedDegenerate, and every child is a left childLeft, left, left
Right skewedDegenerate, and every child is a right childRight, right, right
Zig-zagDegenerate, and the side alternatesLeft, right, left

Degenerate vs balanced height

Height grows with n instead of with log n.

NodesDegenerate heightBalanced height
111
332
773
15154
31315
63636
1271277
2552558
5115119
1023102310

Degenerate Tree FAQ

Quick answers.

What is a degenerate tree?

A tree in which every parent has only one child, so it looks like a linked list. It is also called a pathological tree.

What is the height of a degenerate tree with n nodes?

The height is n levels, because every node sits one level below the previous one. A balanced tree with the same nodes needs only about log2(n + 1) levels.

What is the difference between a degenerate and a skewed tree?

A skewed tree is a degenerate tree whose nodes all lean the same way, all left or all right. Every skewed tree is degenerate, but a degenerate tree that switches sides is not skewed.

Why is a degenerate tree bad for performance?

Search, insert and delete have to walk the whole chain, so they take O(n) time like a linked list instead of O(log n) in a balanced tree.

How does a tree become degenerate?

A common cause is inserting already sorted values into a binary search tree. Each new value is larger than the last, so it always goes to the same side.

How can a degenerate tree be fixed?

Use a self-balancing tree such as an AVL or red-black tree, which rotates nodes to keep the height small.

How do I build a degenerate tree in the visualizer?

The first value becomes the root. After that, choose Left or Right in Insert on side and press Insert. The new node is added below the last node of the chain, so every parent keeps a single child.

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 chain stays unbroken.

How many leaves does a degenerate tree have?

Exactly one leaf, at the bottom of the chain. The other n - 1 nodes are internal nodes with one child each.

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.