geeksforgeeks
  • Courses
  • Tutorials
  • Practice
  • Jobs
  • DSA
  • Practice Problems
  • C
  • C++
  • Java
  • Python
  • JavaScript
  • Data Science
  • Machine Learning
  • Courses
  • Linux
  • DevOps
Videos
January 10, 2025 |3.3K Views

Get level of a node in binary tree Iterative approach

Data Structure and Algorithm, binary-tree
 Save  Share  1 Like
Description
Discussion

Given a Binary Tree and a key, write a function that returns level of the key. 
For example, consider the following tree. If the input key is 3, then your function should return 1. If the input key is 4, then your function should return 3. And for key which is not present in key, then your function should return 0.

Get level of a node in binary tree : https://www.geeksforgeeks.org/get-level-of-a-node-in-a-binary-tree/

Recommendations
Video Thumbnail
10:51
Video Thumbnail
670 Views | 23/04/2026...
Row with maximum number of 1s
Video Thumbnail
10:30
Video Thumbnail
26.2K Views | 10/01/2025...
Implement two stacks in an array
Video Thumbnail
07:59
Video Thumbnail
31.0K Views | 10/01/2025...
Longest Palindromic Subsequence
Video Thumbnail
12:14
Video Thumbnail
10.4K Views | 10/01/2025...
Maximum Sum Increasing Subsequence
Video Thumbnail
04:25
Video Thumbnail
17.8K Views | 10/01/2025...
Iterative Postorder Traversal
Video Thumbnail
06:17
Video Thumbnail
6.9K Views | 10/01/2025...
Sort a linked list of 0s, 1s and 2s
Video Thumbnail
11:24
Video Thumbnail
11.5K Views | 09/01/2025...
Segment Tree | Set 2 (Range Minimum Query)
Video Thumbnail
08:03
Video Thumbnail
16.7K Views | 09/01/2025...
Convert a given Binary Tree to Doubly Linked List | Set 3
Video Thumbnail
06:47
Video Thumbnail
8.1K Views | 08/01/2025...
SDE Sheet - Special Keyboard
Video Thumbnail
10:38
Video Thumbnail
11.6K Views | 08/01/2025...
Length of the longest valid substring
GeeksforGeeks
location
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
location
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play StoreGFG App on App Store
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • Careers
  • Contact Us
  • Corporate Solution
  • Campus Training Program
  • Explore
  • POTD
  • Practice Problems
  • Connect
  • Blogs
  • Upskill Courses
  • Tutorials
  • Programming Languages
  • DSA
  • Web Technology
  • AI, ML & Data Science
  • DevOps
  • CS Core Subjects
  • GATE
  • School Subjects
  • Software and Tools
  • Courses
  • ML and Data Science
  • DSA and Placements
  • Web Development
  • Data Science
  • Programming Languages
  • DevOps & Cloud
  • GATE
  • MongoDB Certifications
  • Offline Centers
  • Noida
  • Bengaluru
  • Hyderabad
  • Kolkata
  • Preparation Corner
  • Interview Corner
  • Aptitude
  • Puzzles
  • GfG 160
  • System Design
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved