Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • DSA
  • Practice on BST
  • MCQs on BST
  • BST Tutorial
  • BST Insertion
  • BST Traversals
  • BST Searching
  • BST Deletion
  • Check BST
  • Balance a BST
  • Self-Balancing BST
  • AVL Tree
  • Red-Black Tree
  • Splay Tree
  • BST Application
  • BST Advantage
Open In App
Next Article:
Leaf nodes from Preorder of a Binary Search Tree
Next article icon

Inversion count in Array Using Self-Balancing BST

Last Updated : 16 Dec, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Given an integer array arr[] of size n, find the inversion count in the array. Two array elements arr[i] and arr[j] form an inversion if arr[i] > arr[j] and i < j.

Note: The Inversion Count for an array indicates how far (or close) the array is from being sorted. If the array is already sorted, then the inversion count is 0, but if the array is sorted in reverse order, the inversion count is maximum. 

Examples: 

Input: arr[] = [4, 3, 2, 1]
Output: 6
Explanation:

inversion-count


Input: arr[] = [1, 2, 3, 4, 5]
Output: 0
Explanation: There is no pair of indexes (i, j) exists in the given array such that arr[i] > arr[j] and i < j

Input: arr[] = [10, 10, 10]
Output: 0

We have already discussed Naive approach and Merge Sort based approaches for counting inversions. 

Complexity Analysis of solution in above mentioned post: 

  • Time Complexity of the Naive approach is O(n2) 
  • Time Complexity of merge sort based approach is O(n Log n). 

Prerequisute: Please go through AVL tree before reading this article.

Approach:

The idea is to use Self-Balancing Binary Search Tree like Red-Black Tree, AVL Tree, etc and augment it so that every node also keeps track of number of nodes in the right subtree. So every node will contain the count of nodes in its right subtree i.e. the number of nodes greater than that number. So it can be seen that the count increases when there is a pair (a,b), where a appears before b in the array and a > b, So as the array is traversed from start to the end, add the elements to the AVL tree and the count of the nodes in its right subtree of the newly inserted node will be the count increased or the number of pairs (a,b) where b is the present element.

Algorithm: 

  1. Create an AVL tree, with a property that every node will contain the size of its subtree.
  2. Traverse the array from start to the end.
  3. For every element insert the element in the AVL tree.
  4. The count of the nodes which are greater than the current element can be found out by checking the size of the subtree of its right children, So it can be guaranteed that elements in the right subtree of current node have index less than the current element and their values are greater than the current element. So those elements satisfy the criteria.
  5. So increase the count by size of subtree of right child of the current inserted node.
  6. return the count.
C++
// C++ Program to count inversions using  // an AVL Tree #include <bits/stdc++.h> using namespace std;  class Node {   public:     int key, height, size;     Node *left;     Node *right;      Node(int val) {         key = val;         height = 1;         size = 1;         left = right = nullptr;     } };  // Function to get the height of the tree // rooted with n int getHeight(Node *n) {     if (n == nullptr) {         return 0;     }     return n->height; }  // Function to get the size of the tree // rooted with n int getSize(Node *n) {     if (n == nullptr) {         return 0;     }     return n->size; }  // Function to right rotate subtree rooted with y Node *rightRotate(Node *y) {     Node *x = y->left;     Node *curr = x->right;      // Perform rotation     x->right = y;     y->left = curr;      // Update heights     y->height = max(getHeight(y->left), getHeight(y->right)) + 1;      x->height = max(getHeight(x->left), getHeight(x->right)) + 1;      // Update sizes     y->size = getSize(y->left) + getSize(y->right) + 1;     x->size = getSize(x->left) + getSize(x->right) + 1;      return x; }  // Function to left rotate subtree rooted with x Node *leftRotate(Node *x) {     Node *y = x->right;     Node *curr = y->left;      // Perform rotation     y->left = x;     x->right = curr;      // Update heights     x->height = max(getHeight(x->left), getHeight(x->right)) + 1;      y->height = max(getHeight(y->left), getHeight(y->right)) + 1;      // Update sizes     x->size = getSize(x->left) + getSize(x->right) + 1;     y->size = getSize(y->left) + getSize(y->right) + 1;      return y; }  // Get balance factor of Node n int getBalance(Node *n) {     if (n == nullptr) {         return 0;     }     return getHeight(n->left) - getHeight(n->right); }  // Function to insert a new key to the tree // and update inversion count Node *insert(Node *root, int key, int &inversionCount) {      // Perform the normal BST insertion     if (root == nullptr) {         return new Node(key);     }      if (key < root->key) {         root->left = insert(root->left, key, inversionCount);          inversionCount += getSize(root->right) + 1;     }     else {         root->right = insert(root->right, key, inversionCount);     }      // Update height and size of the current node     root->height = max(getHeight(root->left), getHeight(root->right)) + 1;     root->size = getSize(root->left) + getSize(root->right) + 1;      // Get the balance factor to check whether     // this node became unbalanced     int balance = getBalance(root);      // Left Left Case     if (balance > 1 && key < root->left->key) {         return rightRotate(root);     }      // Right Right Case     if (balance < -1 && key > root->right->key) {         return leftRotate(root);     }      // Left Right Case     if (balance > 1 && key > root->left->key) {         root->left = leftRotate(root->left);         return rightRotate(root);     }      // Right Left Case     if (balance < -1 && key < root->right->key) {         root->right = rightRotate(root->right);         return leftRotate(root);     }      return root; }  // Function to count inversions in a vector using AVL Tree int countInversions(vector<int> &arr) {     Node *root = nullptr;     int inversionCount = 0;      for (int num : arr) {         root = insert(root, num, inversionCount);     }     return inversionCount; }  int main() {      vector<int> arr = {8, 4, 2, 1};      cout << countInversions(arr) << endl;      return 0; } 
Java
// Java Program to count inversions using // an AVL Tree import java.util.*;  class Node {     int key, height, size;     Node left, right;      Node(int val) {         key = val;         height = 1;         size = 1;         left = right = null;     } }  class GfG {      // Function to get the height of the      // tree rooted with n     static int getHeight(Node n) {         if (n == null) {             return 0;         }         return n.height;     }      // Function to get the size of the tree      // rooted with n     static int getSize(Node n) {         if (n == null) {             return 0;         }         return n.size;     }      // Function to right rotate subtree rooted with y     static Node rightRotate(Node y) {         Node x = y.left;         Node curr = x.right;          // Perform rotation         x.right = y;         y.left = curr;          // Update heights         y.height = Math.max(getHeight(y.left),                             getHeight(y.right)) + 1;                x.height = Math.max(getHeight(x.left),                             getHeight(x.right)) + 1;          // Update sizes         y.size = getSize(y.left) + getSize(y.right) + 1;         x.size = getSize(x.left) + getSize(x.right) + 1;          return x;     }      // Function to left rotate subtree rooted with x     static Node leftRotate(Node x) {         Node y = x.right;         Node curr = y.left;          // Perform rotation         y.left = x;         x.right = curr;          // Update heights         x.height = Math.max(getHeight(x.left),                                getHeight(x.right)) + 1;                y.height = Math.max(getHeight(y.left),                                 getHeight(y.right)) + 1;          // Update sizes         x.size = getSize(x.left) + getSize(x.right) + 1;         y.size = getSize(y.left) + getSize(y.right) + 1;          return y;     }      // Get balance factor of Node n     static int getBalance(Node n) {         if (n == null) {             return 0;         }         return getHeight(n.left) - getHeight(n.right);     }      // Function to insert a new key to the tree     // and update inversion count     static Node insert(Node root, int key,                                  int[] inversionCount) {                // Perform the normal BST insertion         if (root == null) {             return new Node(key);         }          if (key < root.key) {             root.left = insert(root.left,                                 key, inversionCount);                        inversionCount[0] += getSize(root.right) + 1;         }          else {             root.right = insert(root.right, key, inversionCount);         }          // Update height and size of the current node         root.height = Math.max(getHeight(root.left),                                getHeight(root.right)) + 1;                root.size = getSize(root.left)                                 + getSize(root.right) + 1;          // Get the balance factor to check whether this         // node became unbalanced         int balance = getBalance(root);          // Left Left Case         if (balance > 1 && key < root.left.key) {             return rightRotate(root);         }          // Right Right Case         if (balance < -1 && key > root.right.key) {             return leftRotate(root);         }          // Left Right Case         if (balance > 1 && key > root.left.key) {             root.left = leftRotate(root.left);             return rightRotate(root);         }          // Right Left Case         if (balance < -1 && key < root.right.key) {             root.right = rightRotate(root.right);             return leftRotate(root);         }          return root;     }      // Function to count inversions in a list using AVL Tree     static int countInversions(List<Integer> arr) {         Node root = null;         int[] inversionCount = {0};          for (int num : arr) {             root = insert(root, num, inversionCount);         }          return inversionCount[0];     }      public static void main(String[] args) {         List<Integer> arr = Arrays.asList(8, 4, 2, 1);          System.out.println(countInversions(arr));     } } 
Python
# Python Program to count inversions # using an AVL Tree  class Node:     def __init__(self, val):         self.key = val         self.height = 1         self.size = 1         self.left = None         self.right = None   def GetHeight(n):     if n is None:         return 0     return n.height   def GetSize(n):     if n is None:         return 0     return n.size   def RightRotate(y):     x = y.left     curr = x.right      # Perform rotation     x.right = y     y.left = curr      # Update heights     y.height = max(GetHeight(y.left), GetHeight(y.right)) + 1     x.height = max(GetHeight(x.left), GetHeight(x.right)) + 1      # Update sizes     y.size = GetSize(y.left) + GetSize(y.right) + 1     x.size = GetSize(x.left) + GetSize(x.right) + 1      return x   def LeftRotate(x):     y = x.right     curr = y.left      # Perform rotation     y.left = x     x.right = curr      # Update heights     x.height = max(GetHeight(x.left), GetHeight(x.right)) + 1     y.height = max(GetHeight(y.left), GetHeight(y.right)) + 1      # Update sizes     x.size = GetSize(x.left) + GetSize(x.right) + 1     y.size = GetSize(y.left) + GetSize(y.right) + 1      return y   def GetBalance(n):     if n is None:         return 0     return GetHeight(n.left) - GetHeight(n.right)   def Insert(root, key, inversionCount):      # Perform the normal BST insertion     if root is None:         return Node(key)      if key < root.key:         root.left = Insert(root.left, key, inversionCount)         inversionCount[0] += GetSize(root.right) + 1     else:         root.right = Insert(root.right, key, inversionCount)      # Update height and size of the current node     root.height = max(GetHeight(root.left), GetHeight(root.right)) + 1     root.size = GetSize(root.left) + GetSize(root.right) + 1      # Get the balance factor to check whether this     # node became unbalanced     balance = GetBalance(root)      # Left Left Case     if balance > 1 and key < root.left.key:         return RightRotate(root)      # Right Right Case     if balance < -1 and key > root.right.key:         return LeftRotate(root)      # Left Right Case     if balance > 1 and key > root.left.key:         root.left = LeftRotate(root.left)         return RightRotate(root)      # Right Left Case     if balance < -1 and key < root.right.key:         root.right = RightRotate(root.right)         return LeftRotate(root)      return root   def CountInversions(arr):     root = None     inversionCount = [0]      for num in arr:         root = Insert(root, num, inversionCount)      return inversionCount[0]   if __name__ == "__main__":      arr = [8, 4, 2, 1]     print(CountInversions(arr)) 
C#
// C# Program to count inversions using  // an AVL Tree using System; using System.Collections.Generic;  class Node {     public int key, height, size;     public Node left, right;      public Node(int val) {         key = val;         height = 1;         size = 1;         left = right = null;     } }  class GfG {      // Function to get the height of the   	// tree rooted with n     static int GetHeight(Node n) {         if (n == null) {             return 0;         }         return n.height;     }      // Function to get the size of the tree rooted with n     static int GetSize(Node n) {         if (n == null) {             return 0;         }         return n.size;     }      // Function to right rotate subtree rooted with y     static Node RightRotate(Node y) {         Node x = y.left;         Node curr = x.right;          // Perform rotation         x.right = y;         y.left = curr;          // Update heights         y.height = Math.Max(GetHeight(y.left),                             GetHeight(y.right))                    + 1;          x.height = Math.Max(GetHeight(x.left),                             GetHeight(x.right))                    + 1;          // Update sizes         y.size = GetSize(y.left) + GetSize(y.right) + 1;         x.size = GetSize(x.left) + GetSize(x.right) + 1;          return x;     }      // Function to left rotate subtree rooted with x     static Node LeftRotate(Node x) {         Node y = x.right;         Node curr = y.left;          // Perform rotation         y.left = x;         x.right = curr;          // Update heights         x.height = Math.Max(GetHeight(x.left),                             GetHeight(x.right))                    + 1;          y.height = Math.Max(GetHeight(y.left),                             GetHeight(y.right))                    + 1;          // Update sizes         x.size = GetSize(x.left) + GetSize(x.right) + 1;         y.size = GetSize(y.left) + GetSize(y.right) + 1;          return y;     }      // Get balance factor of Node n     static int GetBalance(Node n) {         if (n == null) {             return 0;         }         return GetHeight(n.left) - GetHeight(n.right);     }      // Function to insert a new key to the tree and update     // inversion count     static Node Insert(Node root, int key,                        int[] inversionCount) {          // Perform the normal BST insertion         if (root == null) {             return new Node(key);         }          if (key < root.key) {             root.left                 = Insert(root.left, key, inversionCount);              inversionCount[0] += GetSize(root.right) + 1;         }         else {             root.right                 = Insert(root.right, key, inversionCount);         }          // Update height and size of the current node         root.height = Math.Max(GetHeight(root.left),                                GetHeight(root.right))                       + 1;          root.size             = GetSize(root.left) + GetSize(root.right) + 1;          // Get the balance factor to check whether this         // node became unbalanced         int balance = GetBalance(root);          // Left Left Case         if (balance > 1 && key < root.left.key) {             return RightRotate(root);         }          // Right Right Case         if (balance < -1 && key > root.right.key) {             return LeftRotate(root);         }          // Left Right Case         if (balance > 1 && key > root.left.key) {             root.left = LeftRotate(root.left);             return RightRotate(root);         }          // Right Left Case         if (balance < -1 && key < root.right.key) {             root.right = RightRotate(root.right);             return LeftRotate(root);         }          return root;     }      // Function to count inversions in a list using AVL Tree     static int CountInversions(List<int> arr) {         Node root = null;         int[] inversionCount = { 0 };          foreach(int num in arr) {             root = Insert(root, num, inversionCount);         }          return inversionCount[0];     }        static void Main(string[] args) {         List<int> arr = new List<int>{ 8, 4, 2, 1 };          Console.WriteLine(CountInversions(arr));     } } 
JavaScript
// JavaScript Program to count inversions using // an AVL Tree class Node {     constructor(key) {         this.key = key;         this.height = 1;         this.size = 1;         this.left = null;         this.right = null;     } }  // Function to get the height of the tree  // rooted with node function getHeight(node) {     return node === null ? 0 : node.height; }  // Function to get the size of the tree  // rooted with node function getSize(node) {     return node === null ? 0 : node.size; }  // Function to right rotate subtree rooted with y function rightRotate(y) {     let x = y.left;     let curr = x.right;      // Perform rotation     x.right = y;     y.left = curr;      // Update heights     y.height = Math.max(getHeight(y.left),                                getHeight(y.right)) + 1;                                     x.height = Math.max(getHeight(x.left),                                 getHeight(x.right)) + 1;      // Update sizes     y.size = getSize(y.left) + getSize(y.right) + 1;     x.size = getSize(x.left) + getSize(x.right) + 1;      return x; }  // Function to left rotate subtree rooted with x function leftRotate(x) {     let y = x.right;     let curr = y.left;      // Perform rotation     y.left = x;     x.right = curr;      // Update heights     x.height = Math.max(getHeight(x.left),                                     getHeight(x.right)) + 1;                                         y.height = Math.max(getHeight(y.left),                                     getHeight(y.right)) + 1;      // Update sizes     x.size = getSize(x.left) + getSize(x.right) + 1;     y.size = getSize(y.left) + getSize(y.right) + 1;      return y; }  // Get balance factor of node function getBalance(node) {     return node === null ? 0 : getHeight(node.left)                                  - getHeight(node.right); }  // Function to insert a new key to the tree  // and update inversion count function insert(root, key, inversionCount) {      // Perform the normal BST insertion     if (root === null) {         return new Node(key);     }      if (key < root.key) {         root.left = insert(root.left, key, inversionCount);         inversionCount.count += getSize(root.right) + 1;     }      else {         root.right = insert(root.right, key, inversionCount);     }      // Update height and size of the current node     root.height = Math.max(getHeight(root.left),                                    getHeight(root.right)) + 1;                                        root.size = getSize(root.left) + getSize(root.right) + 1;      // Get the balance factor to check whether      // this node became unbalanced     let balance = getBalance(root);      // Left Left Case     if (balance > 1 && key < root.left.key) {         return rightRotate(root);     }      // Right Right Case     if (balance < -1 && key > root.right.key) {         return leftRotate(root);     }      // Left Right Case     if (balance > 1 && key > root.left.key) {         root.left = leftRotate(root.left);         return rightRotate(root);     }      // Right Left Case     if (balance < -1 && key < root.right.key) {         root.right = rightRotate(root.right);         return leftRotate(root);     }      return root; }  // Function to count inversions in an array  // using AVL Tree function countInversions(arr) {     let root = null;     let inversionCount = { count: 0 };      for (let num of arr) {         root = insert(root, num, inversionCount);     }      return inversionCount.count; }  const arr = [8, 4, 2, 1]; console.log(countInversions(arr)); 

Output
6 

Time Complexity: O(n Log n), Insertion in an AVL insert takes O(log n) time and n elements are inserted in the tree
Auxiliary Space: O(n), To create a AVL tree with max n nodes O(n) extra space is required.

Related articles:

  • Counting Inversions using Set in C++ STL
  • Binary Indexed Tree or Fenwick Tree


Next Article
Leaf nodes from Preorder of a Binary Search Tree
author
kartik
Improve
Article Tags :
  • Binary Search Tree
  • DSA
  • inversion
Practice Tags :
  • Binary Search Tree

Similar Reads

  • Binary Search Tree
    A Binary Search Tree (or BST) is a data structure used in computer science for organizing and storing data in a sorted manner. Each node in a Binary Search Tree has at most two children, a left child and a right child, with the left child containing values less than the parent node and the right chi
    3 min read
  • Introduction to Binary Search Tree
    Binary Search Tree is a data structure used in computer science for organizing and storing data in a sorted manner. Binary search tree follows all properties of binary tree and for every nodes, its left subtree contains values less than the node and the right subtree contains values greater than the
    3 min read
  • Applications of BST
    Binary Search Tree (BST) is a data structure that is commonly used to implement efficient searching, insertion, and deletion operations along with maintaining sorted sequence of data. Please remember the following properties of BSTs before moving forward. The left subtree of a node contains only nod
    2 min read
  • Applications, Advantages and Disadvantages of Binary Search Tree
    A Binary Search Tree (BST) is a data structure used to storing data in a sorted manner. Each node in a Binary Search Tree has at most two children, a left child and a right child, with the left child containing values less than the parent node and the right child containing values greater than the p
    2 min read
  • Insertion in Binary Search Tree (BST)
    Given a BST, the task is to insert a new node in this BST. Example: How to Insert a value in a Binary Search Tree:A new key is always inserted at the leaf by maintaining the property of the binary search tree. We start searching for a key from the root until we hit a leaf node. Once a leaf node is f
    15+ min read
  • Searching in Binary Search Tree (BST)
    Given a BST, the task is to search a node in this BST. For searching a value in BST, consider it as a sorted array. Now we can easily perform search operation in BST using Binary Search Algorithm. Input: Root of the below BST Output: TrueExplanation: 8 is present in the BST as right child of rootInp
    7 min read
  • Deletion in Binary Search Tree (BST)
    Given a BST, the task is to delete a node in this BST, which can be broken down into 3 scenarios: Case 1. Delete a Leaf Node in BST Case 2. Delete a Node with Single Child in BST Deleting a single child node is also simple in BST. Copy the child to the node and delete the node. Case 3. Delete a Node
    10 min read
  • Binary Search Tree (BST) Traversals – Inorder, Preorder, Post Order
    Given a Binary Search Tree, The task is to print the elements in inorder, preorder, and postorder traversal of the Binary Search Tree.  Input:  Output: Inorder Traversal: 10 20 30 100 150 200 300Preorder Traversal: 100 20 10 30 200 150 300Postorder Traversal: 10 30 20 150 300 200 100 Input:  Output:
    11 min read
  • Balance a Binary Search Tree
    Given a BST (Binary Search Tree) that may be unbalanced, the task is to convert it into a balanced BST that has the minimum possible height. Examples: Input: Output: Explanation: The above unbalanced BST is converted to balanced with the minimum possible height. Input: Output: Explanation: The above
    10 min read
  • Self-Balancing Binary Search Trees
    Self-Balancing Binary Search Trees are height-balanced binary search trees that automatically keep the height as small as possible when insertion and deletion operations are performed on the tree. The height is typically maintained in order of logN so that all operations take O(logN) time on average
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences