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

remove duplicates from sorted array - two pointer approach (leetcode)

  class Solution {     public int removeDuplicates ( int [] nums ) {         // base case: return if array have no el.         if ( nums...