GATE CS 2023 | Q37 : Consider the C function foo and the binary tree shown. typedef struct node

GATE CS 2023 | Q37 : Consider the C function foo and the binary tree shown. typedef struct node

GATE CS 2023 | Question: 37 Consider the C function foo and the binary tree shown. typedef struct node { int val; struct node *left, *right; } node; int foo(node *p) { int retval; if (p == NULL) return 0; else { retval =p→val+foo(p →left)+foo(p →right); printf(“%d “, retval); return retval; } } When foo is called with a pointer to the root node of the given binary tree, what will it print? (A) 3 8 5 13 11 10 (B) 3 5 8 10 11 13 (C) 3 8 16 13 24 50 (D) 3 16 8 50 24 13 Ans :(C) 0:00 Question 0:25 Solution ---------------------------------------------------- Subscribe my channel for more updates    / monalisacs   ---------------------------------------------------------- Join Telegram GATE CSE study group: https://t.me/MonalisaCSE ---------------------------------------------- GATE General Aptitude (GA) solved by Monalisa    • General Aptitude PYQ solved by Monalisa Pr...   ---------------------------------------------------------------- Algorithm Lectures :   • Algorithm Lectures for GATE CSE by Monalis...   Algorithm GATE PYQ:    • Algorithm GATE CS & DA PYQ(2010-2025) solv...   ---------------------------------------------------------------- Compiler Design Lectures :   • Ch 1.1:Language Processing System |CD Lect...   Compiler Design PYQ :   • Ch 1.1:Language Processing System |CD Lect...   ---------------------------------------------------------------------- Theory Of Computation Lectures    • Video   TOC GATE PYQ:    • GATE CS 2010,Q39:Let L={w ∈ (0 + 1)* | w h...   ------------------------------------------------------------------- Data Structure Lecture:    • Data Structure Syllabus for GATE   Data Structure PYQ:    • Data Structure Syllabus for GATE   ----------------------------------------------------------------------- #gate_cs #gate #datastructure #tree #trees #gate2024 #gate2024preparation #gatecse #gate2023