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
  • Interview Problems on Tree
  • Practice Tree
  • MCQs on Tree
  • Tutorial on Tree
  • Types of Trees
  • Basic operations
  • Tree Traversal
  • Binary Tree
  • Complete Binary Tree
  • Ternary Tree
  • Binary Search Tree
  • Red-Black Tree
  • AVL Tree
  • Full Binary Tree
  • B-Tree
  • Advantages & Disadvantages
Open In App
Next Article:
How to Print Data in Binary Tree Level by Level in C++?
Next article icon

Print nodes in top view of Binary Tree | Set 2

Last Updated : 23 Dec, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

Top view of a binary tree is the set of nodes visible when the tree is viewed from the top. Given a binary tree, print the top view of it. The output nodes should be printed from left to right. 

Note: A node x is there in output if x is the topmost node at its horizontal distance. Horizontal distance of the left child of a node x is equal to the horizontal distance of x minus 1, and that of right child is the horizontal distance of x plus 1. 

Input:
1
/ \
2 3
/ \ / \
4 5 6 7
Output: Top view: 4 2 1 3 7
Input:
1
/ \
2 3
\
4
\
5
\
6
Output: Top view: 2 1 3 6

Recommended: Please solve it on “PRACTICE” first, before moving on to the solution.

The idea is to do something similar to Vertical Order Traversal. Like Vertical Order Traversal, we need to group nodes of same horizontal distance together. We do a level order traversal so that the topmost node at a horizontal node is visited before any other node of same horizontal distance below it. A Map is used to map the horizontal distance of the node with the node’s Data and vertical distance of the node.

Below is the implementation of the above approach:

C++




// C++ Program to print Top View of Binary Tree
// using hashmap and recursion
#include <bits/stdc++.h>
using namespace std;
 
// Node structure
struct Node {
    // Data of the node
    int data;
 
    // Horizontal Distance of the node
    int hd;
 
    // Reference to left node
    struct Node* left;
 
    // Reference to right node
    struct Node* right;
};
 
// Initialising node
struct Node* newNode(int data)
{
    struct Node* node = new Node;
    node->data = data;
    node->hd = INT_MAX;
    node->left = NULL;
    node->right = NULL;
    return node;
}
 
void printTopViewUtil(Node* root, int height,
    int hd, map<int, pair<int, int> >& m)
{
    // Base Case
    if (root == NULL)
        return;
 
    // If the node for particular horizontal distance
    // is not present in the map, add it.
    // For top view, we consider the first element
    // at horizontal distance in level order traversal
    if (m.find(hd) == m.end()) {
        m[hd] = make_pair(root->data, height);
    }
    else{
        pair<int, int> p = (m.find(hd))->second;
                 
        if (p.second > height) {
            m.erase(hd);
            m[hd] = make_pair(root->data, height);
        }
    }
 
    // Recur for left and right subtree
    printTopViewUtil(root->left, height + 1, hd - 1, m);
    printTopViewUtil(root->right, height + 1, hd + 1, m);
}
 
void printTopView(Node* root)
{
    // Map to store horizontal distance,
    // height and node's data
    map<int, pair<int, int> > m;
    printTopViewUtil(root, 0, 0, m);
 
    // Print the node's value stored by printTopViewUtil()
    for (map<int, pair<int, int> >::iterator it = m.begin();
                                        it != m.end(); it++) {
        pair<int, int> p = it->second;
        cout << p.first << " ";
    }
}
 
int main()
{
    Node* root = newNode(1);
    root->left = newNode(2);
    root->right = newNode(3);
    root->left->right = newNode(4);
    root->left->right->right = newNode(5);
    root->left->right->right->right = newNode(6);
 
    cout << "Top View : ";
    printTopView(root);
 
    return 0;
}
 
 

Java




// Java Program to print Top View of Binary Tree
// using hashmap and recursion
import java.util.*;
 
class GFG {
 
    // Node structure
    static class Node {
        // Data of the node
        int data;
 
        // Reference to left node
        Node left;
 
        // Reference to right node
        Node right;
    };
    static class pair {
        int data, height;
        public pair(int data, int height)
        {
            this.data = data;
            this.height = height;
        }
    }
 
    // Initialising node
    static Node newNode(int data)
    {
        Node node = new Node();
        node.data = data;
        node.left = null;
        node.right = null;
        return node;
    }
 
    static void printTopViewUtil(Node root, int height,
                                 int hd,
                                 Map<Integer, pair> m)
    {
        // Base Case
        if (root == null)
            return;
 
        // If the node for particular horizontal distance
        // is not present in the map, add it.
        // For top view, we consider the first element
        // at horizontal distance in level order traversal
        if (!m.containsKey(hd)) {
            m.put(hd, new pair(root.data, height));
        }
        else {
            pair p = m.get(hd);
 
            if (p.height >= height) {
                m.put(hd, new pair(root.data, height));
            }
        }
 
        // Recur for left and right subtree
        printTopViewUtil(root.left, height + 1, hd - 1, m);
        printTopViewUtil(root.right, height + 1, hd + 1, m);
    }
 
    static void printTopView(Node root)
    {
        // Map to store horizontal distance,
        // height and node's data
        Map<Integer, pair> m = new TreeMap<>();
        printTopViewUtil(root, 0, 0, m);
 
        // Print the node's value stored by
        // printTopViewUtil()
        for (Map.Entry<Integer, pair> it : m.entrySet()) {
            pair p = it.getValue();
            System.out.print(p.data + " ");
        }
    }
 
    // Driver code
    public static void main(String[] args)
    {
        Node root = newNode(1);
        root.left = newNode(2);
        root.right = newNode(3);
        root.left.right = newNode(4);
        root.left.right.right = newNode(5);
        root.left.right.right.right = newNode(6);
 
        System.out.print("Top View : ");
        printTopView(root);
    }
}
 
 

Python3




# Python3 Program to prTop View of
# Binary Tree using hash and recursion
from collections import OrderedDict
 
# A binary tree node
class newNode:
     
    # A constructor to create a
    # new Binary tree Node
    def __init__(self, data):
        self.data = data
        self.left = None
        self.right = None
        self.hd = 2**32
 
def printTopViewUtil(root, height, hd, m):
     
    # Base Case
    if (root == None):
        return
     
    # If the node for particular horizontal
    # distance is not present in the map, add it.
    # For top view, we consider the first element
    # at horizontal distance in level order traversal
    if hd not in m :
        m[hd] = [root.data, height]
    else:
        p = m[hd]
        if p[1] > height:
            m[hd] = [root.data, height]
     
    # Recur for left and right subtree
    printTopViewUtil(root.left,
                     height + 1, hd - 1, m)
    printTopViewUtil(root.right,
                     height + 1, hd + 1, m)
     
def printTopView(root):
     
    # to store horizontal distance,
    # height and node's data
    m = OrderedDict()
    printTopViewUtil(root, 0, 0, m)
     
    # Print the node's value stored
    # by printTopViewUtil()
    for i in sorted(list(m)):
        p = m[i]
        print(p[0], end = " ")
 
# Driver Code
root = newNode(1)
root.left = newNode(2)
root.right = newNode(3)
root.left.right = newNode(4)
root.left.right.right = newNode(5)
root.left.right.right.right = newNode(6)
 
print("Top View : ", end = "")
printTopView(root)
 
# This code is contributed by SHUBHAMSINGH10
 
 

C#




// C# program to print Top View of Binary
// Tree using hashmap and recursion
using System;
using System.Collections.Generic;
 
class GFG{
  
// Node structure
class Node
{
     
    // Data of the node
    public int data;
 
    // Reference to left node
    public Node left;
 
    // Reference to right node
    public Node right;
};
 
class pair
{
    public int data, height;
     
    public pair(int data, int height)
    {
        this.data = data;
        this.height = height;
    }
}
 
// Initialising node
static Node newNode(int data)
{
    Node node = new Node();
    node.data = data;
    node.left = null;
    node.right = null;
    return node;
}
 
static void printTopViewUtil(Node root, int height,
                             int hd,
                             SortedDictionary<int, pair> m)
{
     
    // Base Case
    if (root == null)
        return;
 
    // If the node for particular horizontal distance
    // is not present in the map, add it.
    // For top view, we consider the first element
    // at horizontal distance in level order traversal
    if (!m.ContainsKey(hd))
    {
        m[hd] = new pair(root.data, height);
    }
    else
    {
        pair p = m[hd];
 
        if (p.height >= height)
        {
            m[hd] = new pair(root.data, height);
        }
    }
 
    // Recur for left and right subtree
    printTopViewUtil(root.left, height + 1,
                     hd - 1, m);
    printTopViewUtil(root.right, height + 1,
                     hd + 1, m);
}
 
static void printTopView(Node root)
{
     
    // Map to store horizontal distance,
    // height and node's data
    SortedDictionary<int,
                     pair> m = new SortedDictionary<int,
                                                    pair>();
                                                     
    printTopViewUtil(root, 0, 0, m);
 
    // Print the node's value stored by
    // printTopViewUtil()
    foreach(var it in m.Values)
    {
        Console.Write(it.data + " ");
    }
}
 
// Driver code
public static void Main(string[] args)
{
    Node root = newNode(1);
    root.left = newNode(2);
    root.right = newNode(3);
    root.left.right = newNode(4);
    root.left.right.right = newNode(5);
    root.left.right.right.right = newNode(6);
 
    Console.Write("Top View : ");
     
    printTopView(root);
}
}
 
// This code is contributed by rutvik_56
 
 

Javascript




<script>
 
// JavaScript program to print Top View of Binary
// Tree using hashmap and recursion
 
// Node structure
class Node
{
    constructor()
    {
      // Data of the node
      this.data = 0;
      // Reference to left node
      this.left = null;
      // Reference to right node
      this.right = null;
    }
};
 
class pair
{
  constructor(data, height)
  {
    this.data = data;
    this.height = height;
  }
}
 
// Initialising node
function newNode(data)
{
    var node = new Node();
    node.data = data;
    node.left = null;
    node.right = null;
    return node;
}
 
function printTopViewUtil(root, height, hd, m)
{
     
    // Base Case
    if (root == null)
        return;
 
    // If the node for particular horizontal distance
    // is not present in the map, add it.
    // For top view, we consider the first element
    // at horizontal distance in level order traversal
    if (!m.has(hd))
    {
        m.set(hd, new pair(root.data, height));
    }
    else
    {
        var p = m.get(hd);
 
        if (p.height >= height)
        {
            m.set(hd, new pair(root.data, height));
        }
    }
 
    // Recur for left and right subtree
    printTopViewUtil(root.left, height + 1,
                     hd - 1, m);
    printTopViewUtil(root.right, height + 1,
                     hd + 1, m);
}
 
function printTopView(root)
{
     
    // Map to store horizontal distance,
    // height and node's data
    var m = new Map();
                                                     
    printTopViewUtil(root, 0, 0, m);
 
    // Print the node's value stored by
    // printTopViewUtil()
    for(var it of [...m].sort())
    {
        document.write(it[1].data + " ");
    }
}
 
// Driver code
var root = newNode(1);
root.left = newNode(2);
root.right = newNode(3);
root.left.right = newNode(4);
root.left.right.right = newNode(5);
root.left.right.right.right = newNode(6);
document.write("Top View : ");
printTopView(root);
 
 
</script>
 
 
Output
Top View : 2 1 3 6      

Complexity Analysis:

  • Time complexity: O(n) where n is number of nodes of binary tree
  • Auxiliary space: O(n) for call stack

Approach#2: Using deque

We use a level order traversal technique to traverse the tree and maintain a dictionary to store the horizontal distance of each node from the root node. We keep adding nodes to the queue along with their horizontal distance from the root node. Then, we traverse the dictionary and print the values of the nodes with the minimum horizontal distance from the root node.

Algorithm

1. Create an empty dictionary to store the horizontal distance of each node from the root node.
2. Create a queue and enqueue the root node along with its horizontal distance, which is zero.
3. Traverse the tree using a level order traversal technique:
a. Dequeue a node and its horizontal distance from the queue.
b. If the horizontal distance is not present in the dictionary, add the node’s value to the dictionary with its horizontal distance.
c. Enqueue the left child of the dequeued node with its horizontal distance decreased by 1.
d. Enqueue the right child of the dequeued node with its horizontal distance increased by 1.
4. Traverse the dictionary and print the values of the nodes with the minimum horizontal distance from the root node.

C++




#include <iostream>
#include <map>
#include <deque>
 
// Definition of a binary tree node
class Node {
public:
    int val;
    Node* left;
    Node* right;
 
    Node(int value) : val(value), left(nullptr), right(nullptr) {}
};
 
// Function to print the top view of a binary tree
void topView(Node* root) {
    // Map to store horizontal distance and corresponding node's value
    std::map<int, int> hdMap;
    // Queue for level order traversal with horizontal distance
    std::deque<std::pair<Node*, int>> q;
 
    // Enqueue the root with horizontal distance 0
    q.push_back(std::make_pair(root, 0));
 
    // Level order traversal to find the top view
    while (!q.empty()) {
        Node* node = q.front().first;
        int hd = q.front().second;
        q.pop_front();
 
        // If the horizontal distance is not in the map, add it with the node's value
        if (hdMap.find(hd) == hdMap.end()) {
            hdMap[hd] = node->val;
        }
 
        // Enqueue the left child with a decreased horizontal distance
        if (node->left) {
            q.push_back(std::make_pair(node->left, hd - 1));
        }
        // Enqueue the right child with an increased horizontal distance
        if (node->right) {
            q.push_back(std::make_pair(node->right, hd + 1));
        }
    }
 
    // Print the top view nodes in order of horizontal distance
    for (auto it = hdMap.begin(); it != hdMap.end(); ++it) {
        std::cout << it->second << " ";
    }
}
 
int main() {
    // Create a sample binary tree
    Node* root = new Node(1);
    root->left = new Node(2);
    root->right = new Node(3);
    root->left->left = new Node(4);
    root->left->right = new Node(5);
    root->right->left = new Node(6);
    root->right->right = new Node(7);
 
    // Print the top view of the binary tree
    std::cout << "Top view: ";
    topView(root);
 
    return 0;
}
 
 

Java




import java.util.*;
 
class Node {
    int val;
    Node left;
    Node right;
     
    public Node(int val) {
        this.val = val;
        this.left = null;
        this.right = null;
    }
}
 
public class Main {
    public static void topView(Node root) {
        if (root == null) {
            return;
        }
         
        Map<Integer, Integer> hdMap = new TreeMap<>();
        Queue<Node> queue = new LinkedList<>();
        Queue<Integer> hdQueue = new LinkedList<>();
         
        queue.offer(root);
        hdQueue.offer(0);
         
        while (!queue.isEmpty()) {
            Node currNode = queue.poll();
            int currHd = hdQueue.poll();
             
            if (!hdMap.containsKey(currHd)) {
                hdMap.put(currHd, currNode.val);
            }
             
            if (currNode.left != null) {
                queue.offer(currNode.left);
                hdQueue.offer(currHd - 1);
            }
             
            if (currNode.right != null) {
                queue.offer(currNode.right);
                hdQueue.offer(currHd + 1);
            }
        }
         
        for (int hd : hdMap.keySet()) {
            System.out.print(hdMap.get(hd) + " ");
        }
    }
     
    public static void main(String[] args) {
        Node root = new Node(1);
        root.left = new Node(2);
        root.right = new Node(3);
        root.left.left = new Node(4);
        root.left.right = new Node(5);
        root.right.left = new Node(6);
        root.right.right = new Node(7);
 
        System.out.print("Top view: ");
        topView(root);
    }
}
 
 

Python3




from collections import deque
 
class Node:
    def __init__(self, val):
        self.val = val
        self.left = None
        self.right = None
 
def top_view(root):
    hd_dict = {}
    q = deque([(root, 0)])
    while q:
        node, hd = q.popleft()
        if hd not in hd_dict:
            hd_dict[hd] = node.val
        if node.left:
            q.append((node.left, hd-1))
        if node.right:
            q.append((node.right, hd+1))
    for hd in sorted(hd_dict.keys()):
        print(hd_dict[hd], end=' ')
 
# Example usage
root = Node(1)
root.left = Node(2)
root.right = Node(3)
root.left.left = Node(4)
root.left.right = Node(5)
root.right.left = Node(6)
root.right.right = Node(7)
 
print("Top view: ", end='')
top_view(root)
 
 

C#




using System;
using System.Collections.Generic;
using System.Linq; // Adding System.Linq for LINQ methods
 
public class Node
{
    public int val;
    public Node left;
    public Node right;
 
    public Node(int val)
    {
        this.val = val;
        left = null;
        right = null;
    }
}
 
public class BinaryTree
{
    public static void TopView(Node root)
    {
        Dictionary<int, int> hdDict = new Dictionary<int, int>();
        Queue<(Node, int)> queue = new Queue<(Node, int)>();
        queue.Enqueue((root, 0));
 
        while (queue.Count > 0)
        {
            (Node node, int hd) = queue.Dequeue();
            if (!hdDict.ContainsKey(hd))
            {
                hdDict[hd] = node.val;
            }
            if (node.left != null)
            {
                queue.Enqueue((node.left, hd - 1));
            }
            if (node.right != null)
            {
                queue.Enqueue((node.right, hd + 1));
            }
        }
 
        foreach (int hd in hdDict.Keys.OrderBy(key => key)) // Using OrderBy from System.Linq
        {
            Console.Write(hdDict[hd] + " ");
        }
    }
}
 
class Program
{
    static void Main(string[] args)
    {
        Node root = new Node(1);
        root.left = new Node(2);
        root.right = new Node(3);
        root.left.left = new Node(4);
        root.left.right = new Node(5);
        root.right.left = new Node(6);
        root.right.right = new Node(7);
 
        Console.Write("Top view: ");
        BinaryTree.TopView(root);
    }
}
 
 

Javascript




// Node class definition
class Node {
    constructor(val) {
        this.val = val;
        this.left = null;
        this.right = null;
    }
}
 
// Function to find and print the top view of a binary tree
function topView(root) {
    const hdMap = {}; // Dictionary to store nodes at each horizontal distance
    const queue = [{ node: root, hd: 0 }]; // Queue for level order traversal
 
    while (queue.length !== 0) {
        const { node, hd } = queue.shift();
 
        if (!(hd in hdMap)) {
            hdMap[hd] = node.val;
        }
 
        if (node.left !== null) {
            queue.push({ node: node.left, hd: hd - 1 });
        }
 
        if (node.right !== null) {
            queue.push({ node: node.right, hd: hd + 1 });
        }
    }
 
    // Print the top view nodes
    Object.keys(hdMap)
        .sort((a, b) => a - b) // Sorting keys to print nodes in left-to-right order
        .forEach(hd => process.stdout.write(hdMap[hd] + ' '));
}
 
// Example usage
const root = new Node(1);
root.left = new Node(2);
root.right = new Node(3);
root.left.left = new Node(4);
root.left.right = new Node(5);
root.right.left = new Node(6);
root.right.right = new Node(7);
 
process.stdout.write("Top view: ");
topView(root);
 
 
Output
Top view: 4 2 1 3 7       

Time Complexity: O(N), where N is the number of nodes in the binary tree, as we need to visit each node once.

Space Complexity: O(N), where N is the maximum number of nodes at any level in the binary tree, as we need to store the horizontal distance of each node from the root node. Additionally, we need to store the nodes in the queue, which can have at most N nodes in the worst case when the tree is a complete binary tree.



Next Article
How to Print Data in Binary Tree Level by Level in C++?

A

AmishGupta
Improve
Article Tags :
  • Algorithms
  • C++ Programs
  • Competitive Programming
  • DSA
  • Tree
  • Binary Tree
  • cpp-map
  • Hash
  • Tree Traversals
  • tree-level-order
  • tree-view
Practice Tags :
  • Algorithms
  • Hash
  • Tree

Similar Reads

  • Print leaf nodes in binary tree from left to right using one stack
    Given a binary tree, the task is to print all leaf nodes of the given binary tree from left to right. That is, the nodes should be printed in the order they appear from left to right in the given tree.Examples: Input : 1 / \ 2 3 / \ / \ 4 5 6 7 Output : 4 5 6 7 Input : 4 / \ 5 9 / \ / \ 8 3 7 2 / /
    8 min read
  • Inorder Tree Traversal of Binary Tree in C++
    A binary tree is a non-linear hierarchical data structure in which each node has at most two children known as the left child and the right child. As the binary tree has non-linear structure it can be traversed in multiple ways one such way is in-order traversal which is a depth first (DFS) traversa
    4 min read
  • Sum of nodes at maximum depth of a Binary Tree | Set 2
    Given a root node to a tree, find the sum of all the leaf nodes which are at maximum depth from root node. Example: 1 / \ 2 3 / \ / \ 4 5 6 7 Input : root(of above tree) Output : 22 Explanation: Nodes at maximum depth are: 4, 5, 6, 7. So, sum of these nodes = 22 In the previous article we discussed
    7 min read
  • Clockwise Spiral Traversal of Binary Tree | Set - 2
    Given a Binary Tree. The task is to print the circular clockwise spiral order traversal of the given binary tree.Examples: Input : 1 / \ 2 3 / \ \ 4 5 6 / / \ 7 8 9 Output :1 9 8 7 2 3 6 5 4 Input : 20 / \ 8 22 / \ / \ 5 3 4 25 / \ 10 14 Output :20 14 10 8 22 25 4 3 5 We have already discussed Clock
    11 min read
  • How to Print Data in Binary Tree Level by Level in C++?
    A binary tree is a non-linear hierarchical data structure where each node can have at most two children which are termed as left and right child. In this article, we will learn how to print data in a binary tree level by level in C++. Example Input: 10 / \ 20 30 / \ / \40 50 60 70Output:10 20 30 40
    4 min read
  • Floor in Binary Search Tree (BST)
    Given a Binary Search Tree and a number x, the task is to find the floor of x in the given BST, where floor means the greatest value node of the BST which is smaller than or equal to x. if x is smaller than the smallest node of BST then return -1. Examples: Input: Output: 55Explanantion: Table of Co
    14 min read
  • Binary Search Tree in C++
    A Binary Search Tree (BST) is a type of binary tree in which the data is organized and stored in a sorted order. Unlike, a binary tree that doesn't follow a specific order for node placement, in a binary search tree all the elements on the left side of a node are smaller than the node itself, and el
    10 min read
  • Sum of the mirror image nodes of a complete binary tree in an inorder way
    Given a complete binary tree, the task is to find the sum of mirror image nodes in an inorder way i.e. find the inorder traversal of the left sub-tree and for every node traversed, add the value of its mirror node to the current node's value. Examples: Input: Output: 20 51 19 10 Inorder traversal of
    6 min read
  • Print N-ary tree graphically
    Given an N-ary tree, the task is to print the N-ary tree graphically.Graphical Representation of Tree: A representation of tree in which the root is printed in a line and the children nodes are printed in subsequent lines with some amount of indentation. Examples: Input: 0 / | \ / | \ 1 2 3 / \ / |
    11 min read
  • Iterative Boundary Traversal of Complete Binary tree
    Given a complete binary tree, the task is to traverse it such that all the boundary nodes are visited in Anti-Clockwise order starting from the root. Example: Input: Output: 1 2 4 5 6 7 3 Input: Output: 18 15 40 50 100 20 30 Approach: Traverse left-most nodes of the tree from top to down. (Left boun
    9 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