dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX_CHAR = 26 ; bool adjSign ( string s , int i ) { if ( i == 0 ) return true ; if ( s [ i - 1 ] == ' - ' ) return false ; return true ; } ; void eval ( string s , vector < int > & v , bool add ) { stack < bool > stk ; stk . push ( true ) ; int i = 0 ; while ( s [ i ] != ' \0' ) { if ( s [ i ] == ' + ' s [ i ] == ' - ' ) { i ++ ; continue ; } if ( s [ i ] == ' ( ' ) { if ( adjSign ( s , i ) ) stk . push ( stk . top ( ) ) ; else stk . push ( ! stk . top ( ) ) ; } else if ( s [ i ] == ' ) ' ) stk . pop ( ) ; else { if ( stk . top ( ) ) v [ s [ i ] - ' a ' ] += ( adjSign ( s , i ) ? add ? 1 : -1 : add ? -1 : 1 ) ; else v [ s [ i ] - ' a ' ] += ( adjSign ( s , i ) ? add ? -1 : 1 : add ? 1 : -1 ) ; } i ++ ; } } ; bool areSame ( string expr1 , string expr2 ) { vector < int > v ( MAX_CHAR , 0 ) ; eval ( expr1 , v , true ) ; eval ( expr2 , v , false ) ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) if ( v [ i ] != 0 ) return false ; return true ; } int main ( ) { string expr1 = " - ( a + b + c ) " , expr2 = " - a - b - c " ; if ( areSame ( expr1 , expr2 ) ) cout << " Yes STRNEWLINE " ; else cout << " No STRNEWLINE " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void test ( string expression , int index ) { int i ; if ( expression [ index ] != ' [ ' ) { cout << expression << " , ▁ " << index << " : ▁ - 1 STRNEWLINE " ; return ; } stack < int > st ; for ( i = index ; i < expression . length ( ) ; i ++ ) { if ( expression [ i ] == ' [ ' ) st . push ( expression [ i ] ) ; else if ( expression [ i ] == ' ] ' ) { st . pop ( ) ; if ( st . empty ( ) ) { cout << expression << " , ▁ " << index << " : ▁ " << i << " STRNEWLINE " ; return ; } } } cout << expression << " , ▁ " << index << " : ▁ - 1 STRNEWLINE " ; } int main ( ) { test ( " [ ABC [ 23 ] ] [89 ] " , 0 ) ; test ( " [ ABC [ 23 ] ] [89 ] " , 4 ) ; test ( " [ ABC [ 23 ] ] [89 ] " , 9 ) ; test ( " [ ABC [ 23 ] ] [89 ] " , 1 ) ; return 0 ; }

Index/key variables: i, index
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * left ; struct Node * right ; } ; struct Node * newNode ( int key ) { struct Node * node = new Node ; node -> data = key ; node -> left = node -> right = NULL ; return node ; } void convertTree ( Node * root ) { if ( root == NULL ) return ; convertTree ( root -> left ) ; convertTree ( root -> right ) ; if ( root -> left != NULL && root -> right != NULL ) root -> data = ( root -> left -> data ) & ( root -> right -> data ) ; } void printInorder ( Node * root ) { if ( root == NULL ) return ; printInorder ( root -> left ) ; printf ( " % d ▁ " , root -> data ) ; printInorder ( root -> right ) ; } int main ( ) { Node * root = newNode ( 0 ) ; root -> left = newNode ( 1 ) ; root -> right = newNode ( 0 ) ; root -> left -> left = newNode ( 0 ) ; root -> left -> right = newNode ( 1 ) ; root -> right -> left = newNode ( 1 ) ; root -> right -> right = newNode ( 1 ) ; printf ( " Inorder traversal before conversion " printInorder ( root ) ; convertTree ( root ) ; printf ( " Inorder traversal after conversion " printInorder ( root ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool findDuplicateparenthesis ( string str ) { stack < char > Stack ; for ( char ch : str ) { if ( ch == ' ) ' ) { char top = Stack . top ( ) ; Stack . pop ( ) ; int elementsInside = 0 ; while ( top != ' ( ' ) { elementsInside ++ ; top = Stack . top ( ) ; Stack . pop ( ) ; } if ( elementsInside < 1 ) { return 1 ; } } else Stack . push ( ch ) ; } return false ; } int main ( ) { string str = " ( ( ( a + ( b ) ) + ( c + d ) ) ) " ; if ( findDuplicateparenthesis ( str ) ) cout << " Duplicate ▁ Found ▁ " ; else cout << " No ▁ Duplicates ▁ Found ▁ " ; return 0 ; }

Accumulator variables: elementsInside, stdc
Iterator variables: ch
C++ program:
#include <bits/stdc++.h>
using namespace std ; void nextGreater ( int arr [ ] , int n , int next [ ] , char order ) { stack < int > S ; for ( int i = n - 1 ; i >= 0 ; i -- ) { while ( ! S . empty ( ) && ( ( order == ' G ' ) ? arr [ S . top ( ) ] <= arr [ i ] : arr [ S . top ( ) ] >= arr [ i ] ) ) S . pop ( ) ; if ( ! S . empty ( ) ) next [ i ] = S . top ( ) ; else next [ i ] = -1 ; S . push ( i ) ; } } void nextSmallerOfNextGreater ( int arr [ ] , int n ) { int NG [ n ] ; int RS [ n ] ; nextGreater ( arr , n , NG , ' G ' ) ; nextGreater ( arr , n , RS , ' S ' ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( NG [ i ] != -1 && RS [ NG [ i ] ] != -1 ) cout << arr [ RS [ NG [ i ] ] ] << " ▁ " ; else cout << " - 1" << " ▁ " ; } } int main ( ) { int arr [ ] = { 5 , 1 , 9 , 2 , 5 , 1 , 7 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; nextSmallerOfNextGreater ( arr , n ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countNumber ( int n ) { int result = 0 ; stack < int > s ; for ( int i = 1 ; i <= 9 ; i ++ ) { if ( i <= n ) { s . push ( i ) ; result ++ ; } while ( ! s . empty ( ) ) { int tp = s . top ( ) ; s . pop ( ) ; for ( int j = tp % 10 ; j <= 9 ; j ++ ) { int x = tp * 10 + j ; if ( x <= n ) { s . push ( x ) ; result ++ ; } } } } return result ; } int main ( ) { int n = 15 ; cout << countNumber ( n ) << endl ; return 0 ; }

Accumulator variables: i, j, result, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int removeConsecutiveSame ( vector < string > v ) { int n = v . size ( ) ; for ( int i = 0 ; i < n - 1 ; ) { if ( v [ i ] . compare ( v [ i + 1 ] ) == 0 ) { v . erase ( v . begin ( ) + i ) ; v . erase ( v . begin ( ) + i ) ; if ( i > 0 ) i -- ; n = n - 2 ; } else i ++ ; } return v . size ( ) ; } int main ( ) { vector < string > v = { " tom " , " jerry " , " jerry " , " tom " } ; cout << removeConsecutiveSame ( v ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int removeConsecutiveSame ( vector < string > v ) { stack < string > st ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { if ( st . empty ( ) ) st . push ( v [ i ] ) ; else { string str = st . top ( ) ; if ( str . compare ( v [ i ] ) == 0 ) st . pop ( ) ; else st . push ( v [ i ] ) ; } } return st . size ( ) ; } int main ( ) { vector < string > V = { " ab " , " aa " , " aa " , " bcd " , " ab " } ; cout << removeConsecutiveSame ( V ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string decode ( string str ) { stack < int > integerstack ; stack < char > stringstack ; string temp = " " , result = " " ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { int count = 0 ; if ( str [ i ] >= '0' && str [ i ] <= '9' ) { while ( str [ i ] >= '0' && str [ i ] <= '9' ) { count = count * 10 + str [ i ] - '0' ; i ++ ; } i -- ; integerstack . push ( count ) ; } else if ( str [ i ] == ' ] ' ) { temp = " " ; count = 0 ; if ( ! integerstack . empty ( ) ) { count = integerstack . top ( ) ; integerstack . pop ( ) ; } while ( ! stringstack . empty ( ) && stringstack . top ( ) != ' [ ' ) { temp = stringstack . top ( ) + temp ; stringstack . pop ( ) ; } if ( ! stringstack . empty ( ) && stringstack . top ( ) == ' [ ' ) stringstack . pop ( ) ; for ( int j = 0 ; j < count ; j ++ ) result = result + temp ; for ( int j = 0 ; j < result . length ( ) ; j ++ ) stringstack . push ( result [ j ] ) ; result = " " ; } else if ( str [ i ] == ' [ ' ) { if ( str [ i - 1 ] >= '0' && str [ i - 1 ] <= '9' ) stringstack . push ( str [ i ] ) ; else { stringstack . push ( str [ i ] ) ; integerstack . push ( 1 ) ; } } else stringstack . push ( str [ i ] ) ; } while ( ! stringstack . empty ( ) ) { result = stringstack . top ( ) + result ; stringstack . pop ( ) ; } return result ; } int main ( ) { string str = "3 [ b2 [ ca ] ] " ; cout << decode ( str ) << endl ; return 0 ; }

Index/key variables: ca, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * left , * right ; } ; struct Node * newNode ( int data ) { struct Node * node = ( struct Node * ) malloc ( sizeof ( struct Node ) ) ; node -> data = data ; node -> left = node -> right = NULL ; return node ; } void printAncestors ( struct Node * root , int key ) { if ( root == NULL ) return ; stack < struct Node * > st ; while ( 1 ) { while ( root && root -> data != key ) { st . push ( root ) ; root = root -> left ; } if ( root && root -> data == key ) break ; if ( st . top ( ) -> right == NULL ) { root = st . top ( ) ; st . pop ( ) ; while ( ! st . empty ( ) && st . top ( ) -> right == root ) { root = st . top ( ) ; st . pop ( ) ; } } root = st . empty ( ) ? NULL : st . top ( ) -> right ; } while ( ! st . empty ( ) ) { cout << st . top ( ) -> data << " ▁ " ; st . pop ( ) ; } } int main ( ) { struct Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 7 ) ; root -> left -> left = newNode ( 3 ) ; root -> left -> right = newNode ( 5 ) ; root -> right -> left = newNode ( 8 ) ; root -> right -> right = newNode ( 9 ) ; root -> left -> left -> left = newNode ( 4 ) ; root -> left -> right -> right = newNode ( 6 ) ; root -> right -> right -> left = newNode ( 10 ) ; int key = 6 ; printAncestors ( root , key ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; class StackWithMax { stack < int > mainStack ; stack < int > trackStack ; public : void push ( int x ) { mainStack . push ( x ) ; if ( mainStack . size ( ) == 1 ) { trackStack . push ( x ) ; return ; } if ( x > trackStack . top ( ) ) trackStack . push ( x ) ; else trackStack . push ( trackStack . top ( ) ) ; } int getMax ( ) { return trackStack . top ( ) ; } int pop ( ) { mainStack . pop ( ) ; trackStack . pop ( ) ; } } ; int main ( ) { StackWithMax s ; s . push ( 20 ) ; cout << s . getMax ( ) << endl ; s . push ( 10 ) ; cout << s . getMax ( ) << endl ; s . push ( 50 ) ; cout << s . getMax ( ) << endl ; return 0 ; }

Accumulator variables: stdc
Class/struct names: StackWithMax
C++ program:
#include <bits/stdc++.h>
using namespace std ; stack < int > st ; void push_digits ( int number ) { while ( number != 0 ) { st . push ( number % 10 ) ; number = number / 10 ; } } int reverse_number ( int number ) { push_digits ( number ) ; int reverse = 0 ; int i = 1 ; while ( ! st . empty ( ) ) { reverse = reverse + ( st . top ( ) * i ) ; st . pop ( ) ; i = i * 10 ; } return reverse ; } int main ( ) { int number = 39997 ; cout << reverse_number ( number ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; Node * left , * right ; } ; struct Node * newNode ( int data ) { struct Node * temp = new struct Node ; temp -> data = data ; temp -> left = temp -> right = NULL ; return temp ; } Node * flipBinaryTree ( Node * root ) { if ( root == NULL ) return root ; if ( root -> left == NULL && root -> right == NULL ) return root ; Node * flippedRoot = flipBinaryTree ( root -> left ) ; root -> left -> left = root -> right ; root -> left -> right = root ; root -> left = root -> right = NULL ; return flippedRoot ; } void printLevelOrder ( Node * root ) { if ( root == NULL ) return ; queue < Node * > q ; q . push ( root ) ; while ( 1 ) { int nodeCount = q . size ( ) ; if ( nodeCount == 0 ) break ; while ( nodeCount > 0 ) { Node * node = q . front ( ) ; cout << node -> data << " ▁ " ; q . pop ( ) ; if ( node -> left != NULL ) q . push ( node -> left ) ; if ( node -> right != NULL ) q . push ( node -> right ) ; nodeCount -- ; } cout << endl ; } } int main ( ) { Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> right -> left = newNode ( 4 ) ; root -> right -> right = newNode ( 5 ) ; cout << " Level ▁ order ▁ traversal ▁ of ▁ given ▁ tree STRNEWLINE " ; printLevelOrder ( root ) ; root = flipBinaryTree ( root ) ; cout << " Level order traversal of the flipped " STRNEWLINE TABSYMBOL TABSYMBOL TABSYMBOL " tree " printLevelOrder ( root ) ; return 0 ; }

Accumulator variables: nodeCount, stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool pairWiseConsecutive ( stack < int > s ) { stack < int > aux ; while ( ! s . empty ( ) ) { aux . push ( s . top ( ) ) ; s . pop ( ) ; } bool result = true ; while ( aux . size ( ) > 1 ) { int x = aux . top ( ) ; aux . pop ( ) ; int y = aux . top ( ) ; aux . pop ( ) ; if ( abs ( x - y ) != 1 ) result = false ; s . push ( x ) ; s . push ( y ) ; } if ( aux . size ( ) == 1 ) s . push ( aux . top ( ) ) ; return result ; } int main ( ) { stack < int > s ; s . push ( 4 ) ; s . push ( 5 ) ; s . push ( -2 ) ; s . push ( -3 ) ; s . push ( 11 ) ; s . push ( 10 ) ; s . push ( 5 ) ; s . push ( 6 ) ; s . push ( 20 ) ; if ( pairWiseConsecutive ( s ) ) cout << " Yes " << endl ; else cout << " No " << endl ; cout << " Stack ▁ content ▁ ( from ▁ top ) " " ▁ after ▁ function ▁ call STRNEWLINE " ; while ( s . empty ( ) == false ) { cout << s . top ( ) << " ▁ " ; s . pop ( ) ; } return 0 ; }

Accumulator variables: stdc
Boolean variables: result
C++ program:
#include <bits/stdc++.h>
using namespace std ; char * simplify ( string str ) { int len = str . length ( ) ; char * res = new char ( len ) ; int index = 0 , i = 0 ; stack < int > s ; s . push ( 0 ) ; while ( i < len ) { if ( str [ i ] == ' + ' ) { if ( s . top ( ) == 1 ) res [ index ++ ] = ' - ' ; if ( s . top ( ) == 0 ) res [ index ++ ] = ' + ' ; } else if ( str [ i ] == ' - ' ) { if ( s . top ( ) == 1 ) res [ index ++ ] = ' + ' ; else if ( s . top ( ) == 0 ) res [ index ++ ] = ' - ' ; } else if ( str [ i ] == ' ( ' && i > 0 ) { if ( str [ i - 1 ] == ' - ' ) { int x = ( s . top ( ) == 1 ) ? 0 : 1 ; s . push ( x ) ; } else if ( str [ i - 1 ] == ' + ' ) s . push ( s . top ( ) ) ; } else if ( str [ i ] == ' ) ' ) s . pop ( ) ; else res [ index ++ ] = str [ i ] ; i ++ ; } return res ; } int main ( ) { string s1 = " a - ( b + c ) " ; string s2 = " a - ( b - c - ( d + e ) ) - f " ; cout << simplify ( s1 ) << endl ; cout << simplify ( s2 ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, index, stdc
C++ program:
#include <iostream>
using namespace std ; #define BOUND  4
int top = -1 ; int length = 0 ; int * create_new ( int * a ) { int * new_a = new int [ length + BOUND ] ; for ( int i = 0 ; i < length ; i ++ ) new_a [ i ] = a [ i ] ; length += BOUND ; return new_a ; } int * push ( int * a , int element ) { if ( top == length - 1 ) a = create_new ( a ) ; a [ ++ top ] = element ; return a ; } void pop ( int * a ) { top -- ; } void display ( int * a ) { if ( top == -1 ) cout << " Stack ▁ is ▁ Empty " << endl ; else { cout << " Stack : ▁ " ; for ( int i = 0 ; i <= top ; i ++ ) cout << a [ i ] << " ▁ " ; cout << endl ; } } int main ( ) { int * a = create_new ( a ) ; a = push ( a , 1 ) ; a = push ( a , 2 ) ; a = push ( a , 3 ) ; a = push ( a , 4 ) ; display ( a ) ; a = push ( a , 5 ) ; a = push ( a , 6 ) ; display ( a ) ; a = push ( a , 7 ) ; a = push ( a , 8 ) ; display ( a ) ; a = push ( a , 9 ) ; display ( a ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, length, top
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void constructBlanceArray ( int BOP [ ] , int BCP [ ] , char * str , int n ) { stack < int > stk ; int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' ( ' ) stk . push ( i ) ; else { if ( ! stk . empty ( ) ) { BCP [ i ] = 1 ; BOP [ stk . top ( ) ] = 1 ; stk . pop ( ) ; } else BCP [ i ] = 0 ; } } for ( int i = 1 ; i < n ; i ++ ) { BCP [ i ] += BCP [ i - 1 ] ; BOP [ i ] += BOP [ i - 1 ] ; } } int query ( int BOP [ ] , int BCP [ ] , int s , int e ) { if ( BOP [ s - 1 ] == BOP [ s ] ) { return ( BCP [ e ] - BOP [ s ] ) * 2 ; } else { return ( BCP [ e ] - BOP [ s ] + 1 ) * 2 ; } } int main ( ) { char str [ ] = " ( ) ) ( ( ) ) ( ( ) ) ( " ; int n = strlen ( str ) ; int BCP [ n + 1 ] = { 0 } ; int BOP [ n + 1 ] = { 0 } ; constructBlanceArray ( BOP , BCP , str , n ) ; int startIndex = 5 , endIndex = 11 ; cout << " Maximum ▁ Length ▁ Correct ▁ Bracket " " ▁ Subsequence ▁ between ▁ " << startIndex << " ▁ and ▁ " << endIndex << " ▁ = ▁ " << query ( BOP , BCP , startIndex , endIndex ) << endl ; startIndex = 4 , endIndex = 5 ; cout << " Maximum ▁ Length ▁ Correct ▁ Bracket " " ▁ Subsequence ▁ between ▁ " << startIndex << " ▁ and ▁ " << endIndex << " ▁ = ▁ " << query ( BOP , BCP , startIndex , endIndex ) << endl ; startIndex = 1 , endIndex = 5 ; cout << " Maximum ▁ Length ▁ Correct ▁ Bracket " " ▁ Subsequence ▁ between ▁ " << startIndex << " ▁ and ▁ " << endIndex << " ▁ = ▁ " << query ( BOP , BCP , startIndex , endIndex ) << endl ; return 0 ; }

Index/key variables: e, i, s
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void heapify ( int arr [ ] , int n , int i ) { int largest = i ; int l = 2 * i + 1 ; int r = 2 * i + 2 ; if ( l < n && arr [ l ] > arr [ largest ] ) largest = l ; if ( r < n && arr [ r ] > arr [ largest ] ) largest = r ; if ( largest != i ) { swap ( arr [ i ] , arr [ largest ] ) ; heapify ( arr , n , largest ) ; } } void heapSort ( int arr [ ] , int n ) { for ( int i = n / 2 - 1 ; i >= 0 ; i -- ) heapify ( arr , n , i ) ; for ( int i = n - 1 ; i > 0 ; i -- ) { swap ( arr [ 0 ] , arr [ i ] ) ; heapify ( arr , i , 0 ) ; } } void printArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; ++ i ) cout << arr [ i ] << " ▁ " ; cout << " STRNEWLINE " ; } int main ( ) { int arr [ ] = { 12 , 11 , 13 , 5 , 6 , 7 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; heapSort ( arr , n ) ; cout << " Sorted ▁ array ▁ is ▁ STRNEWLINE " ; printArray ( arr , n ) ; }

Index/key variables: i, l, largest, r
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void buildMaxHeap ( int arr [ ] , int n ) { for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] > arr [ ( i - 1 ) / 2 ] ) { int j = i ; while ( arr [ j ] > arr [ ( j - 1 ) / 2 ] ) { swap ( arr [ j ] , arr [ ( j - 1 ) / 2 ] ) ; j = ( j - 1 ) / 2 ; } } } } void heapSort ( int arr [ ] , int n ) { buildMaxHeap ( arr , n ) ; for ( int i = n - 1 ; i > 0 ; i -- ) { swap ( arr [ 0 ] , arr [ i ] ) ; int j = 0 , index ; do { index = ( 2 * j + 1 ) ; if ( arr [ index ] < arr [ index + 1 ] && index < ( i - 1 ) ) index ++ ; if ( arr [ j ] < arr [ index ] && index < i ) swap ( arr [ j ] , arr [ index ] ) ; j = index ; } while ( index < i ) ; } } int main ( ) { int arr [ ] = { 10 , 20 , 15 , 17 , 9 , 21 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printf ( " Given ▁ array : ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) printf ( " % d ▁ " , arr [ i ] ) ; printf ( " STRNEWLINE STRNEWLINE " ) ; heapSort ( arr , n ) ; printf ( " Sorted ▁ array : ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) printf ( " % d ▁ " , arr [ i ] ) ; return 0 ; }

Index/key variables: i, index, j
Accumulator variables: i, index, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; Node * left , * right ; } ; struct Node * newNode ( int data ) { struct Node * temp = new struct Node ; temp -> data = data ; temp -> left = temp -> right = NULL ; return temp ; } Node * flipBinaryTree ( Node * root ) { Node * curr = root ; Node * next = NULL ; Node * temp = NULL ; Node * prev = NULL ; while ( curr ) { next = curr -> left ; curr -> left = temp ; temp = curr -> right ; curr -> right = prev ; prev = curr ; curr = next ; } return prev ; } void printLevelOrder ( Node * root ) { if ( root == NULL ) return ; queue < Node * > q ; q . push ( root ) ; while ( 1 ) { int nodeCount = q . size ( ) ; if ( nodeCount == 0 ) break ; while ( nodeCount > 0 ) { Node * node = q . front ( ) ; cout << node -> data << " ▁ " ; q . pop ( ) ; if ( node -> left != NULL ) q . push ( node -> left ) ; if ( node -> right != NULL ) q . push ( node -> right ) ; nodeCount -- ; } cout << endl ; } } int main ( ) { Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> right -> left = newNode ( 4 ) ; root -> right -> right = newNode ( 5 ) ; cout << " Level ▁ order ▁ traversal ▁ of ▁ given ▁ tree STRNEWLINE " ; printLevelOrder ( root ) ; root = flipBinaryTree ( root ) ; cout << " Level order traversal of the flipped " STRNEWLINE TABSYMBOL TABSYMBOL TABSYMBOL " tree " printLevelOrder ( root ) ; return 0 ; }

Accumulator variables: nodeCount, stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define bool  int
#define true  1
#define false  0
class node { public : int data ; node * left ; node * right ; } ; bool IsFoldableUtil ( node * n1 , node * n2 ) ; bool IsFoldable ( node * root ) { if ( root == NULL ) { return true ; } return IsFoldableUtil ( root -> left , root -> right ) ; } bool IsFoldableUtil ( node * n1 , node * n2 ) { if ( n1 == NULL && n2 == NULL ) { return true ; } if ( n1 == NULL n2 == NULL ) { return false ; } return IsFoldableUtil ( n1 -> left , n2 -> right ) && IsFoldableUtil ( n1 -> right , n2 -> left ) ; } node * newNode ( int data ) { node * Node = new node ( ) ; Node -> data = data ; Node -> left = NULL ; Node -> right = NULL ; return ( Node ) ; } int main ( void ) { node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> right = newNode ( 4 ) ; root -> right -> left = newNode ( 5 ) ; if ( IsFoldable ( root ) == true ) { cout << " Tree ▁ is ▁ foldable " ; } else { cout << " Tree ▁ is ▁ not ▁ foldable " ; } return 0 ; }

Accumulator variables: stdc
Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct node { int data ; struct node * left ; struct node * right ; } ; int isSumProperty ( struct node * node ) { int left_data = 0 , right_data = 0 ; if ( node == NULL || ( node -> left == NULL && node -> right == NULL ) ) return 1 ; else { if ( node -> left != NULL ) left_data = node -> left -> data ; if ( node -> right != NULL ) right_data = node -> right -> data ; if ( ( node -> data == left_data + right_data ) && isSumProperty ( node -> left ) && isSumProperty ( node -> right ) ) return 1 ; else return 0 ; } } struct node * newNode ( int data ) { struct node * node = ( struct node * ) malloc ( sizeof ( struct node ) ) ; node -> data = data ; node -> left = NULL ; node -> right = NULL ; return ( node ) ; } int main ( ) { struct node * root = newNode ( 10 ) ; root -> left = newNode ( 8 ) ; root -> right = newNode ( 2 ) ; root -> left -> left = newNode ( 3 ) ; root -> left -> right = newNode ( 5 ) ; root -> right -> right = newNode ( 2 ) ; if ( isSumProperty ( root ) ) cout << " The ▁ given ▁ tree ▁ satisfies ▁ " << " the ▁ children ▁ sum ▁ property ▁ " ; else cout << " The ▁ given ▁ tree ▁ does ▁ not ▁ satisfy ▁ " << " the ▁ children ▁ sum ▁ property ▁ " ; getchar ( ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: node
C++ program:
#include <limits.h>
#include <stdio.h>
bool isHeap ( int arr [ ] , int i , int n ) { if ( i >= ( n - 2 ) / 2 ) return true ; if ( arr [ i ] >= arr [ 2 * i + 1 ] && arr [ i ] >= arr [ 2 * i + 2 ] && isHeap ( arr , 2 * i + 1 , n ) && isHeap ( arr , 2 * i + 2 , n ) ) return true ; return false ; } int main ( ) { int arr [ ] = { 90 , 15 , 10 , 7 , 12 , 2 , 7 , 3 } ; int n = sizeof ( arr ) / sizeof ( int ) - 1 ; isHeap ( arr , 0 , n ) ? printf ( " Yes " ) : printf ( " No " ) ; return 0 ; }

Index/key variables: i
C++ program:
#include <stdio.h>
#include <limits.h>
bool isHeap ( int arr [ ] , int n ) { for ( int i = 0 ; i <= ( n - 2 ) / 2 ; i ++ ) { if ( arr [ 2 * i + 1 ] > arr [ i ] ) return false ; if ( 2 * i + 2 < n && arr [ 2 * i + 2 ] > arr [ i ] ) return false ; } return true ; } int main ( ) { int arr [ ] = { 90 , 15 , 10 , 7 , 12 , 2 , 7 , 3 } ; int n = sizeof ( arr ) / sizeof ( int ) ; isHeap ( arr , n ) ? printf ( " Yes " ) : printf ( " No " ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i