The Wayback Machine - https://web.archive.org/web/20250114151859/https://www.geeksforgeeks.org/difference-between-binary-search-tree-and-avl-tree/
Open In App

Difference between Binary Search Tree and AVL Tree

Last Updated : 06 Jun, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Binary Search Tree:

A binary Search Tree is a node-based binary tree data structure that has the following properties:

  • The left subtree of a node contains only nodes with keys lesser than the node’s key.
  • The right subtree of a node contains only nodes with keys greater than the node’s key.
  • The left and right subtree each must also be a binary search tree.

Binary Search Tree

AVL Tree: 

AVL tree is a self-balancing Binary Search Tree (BST) where the difference between heights of left and right subtrees for any node cannot be more than one.

AVL Tree

Difference between Binary Search Tree and AVL Tree

Binary Search Tree AVL Tree
In Binary Search Tree, every node does not follow the balance factor. In AVL Tree, every node follows the balance factor i.e. 0, 1, -1.
Every Binary Search tree is not an AVL tree. Every AVL tree is a Binary Search tree.
Simple to implement. Complex to implement.
The height or depth of the tree is O(n). The height or depth of the tree is O(logn)
Searching is not efficient when there are a large number of nodes in the Binary Search tree.  Searching is efficient because searching for the desired node is faster due to the balancing of height. 
The Binary Search tree structure consists of 3 fields left subtree, data, and right subtree.  AVL tree structure consists of 4 fields left subtree, data, right subtree, and balancing factor.
It is not a balanced tree. It is a balanced tree.
In Binary Search tree. Insertion and deletion are easy because no rotations are required.  In an AVL tree, Insertion and deletion are complex as it requires multiple rotations to balance the tree.

Unlock your potential with our DSA Self-Paced course, designed to help you master Data Structures and Algorithms at your own pace. In 90 days, you’ll learn the core concepts of DSA, tackle real-world problems, and boost your problem-solving skills, all at a speed that fits your schedule. With comprehensive lessons and practical exercises, this course will set you up for success in technical interviews and beyond.

And here's the challenge – join the Three 90 Challenge! Complete 90% of the course in 90 days, and you’ll earn a 90% refund. It's a great way to stay motivated, track your progress, and reward yourself for your dedication. Start the challenge today, and push your limits to achieve mastery in DSA!


Next Article
Article Tags :

Similar Reads

three90RightbarBannerImg