Pages

Monday, July 14, 2025

Inorder Traversal(Binary Tree) in C++

void inorder(Node* root) {

    if (root == NULL) return;       // ✅ base case handled

    inorder(root->left);            // 🡐 left

    cout << root->data << endl;     // 🡐 root

    inorder(root->right);           // 🡐 right

}


No comments:

Post a Comment

3917. Count Indices With Opposite Parity (Brute Force) O(n2) + Optimized Solution O(n) + tips LEETCODE WEEKLY 500

  class Solution {     public int [] countOppositeParity ( int [] nums ) {          // approach 1 - checks every pair         int n = n...