dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { char key ; Node * left , * right ; } ; void preorder ( struct Node * root1 , struct Node * root2 , int lvl ) { if ( root1 == NULL root2 == NULL ) return ; if ( lvl % 2 == 0 ) swap ( root1 -> key , root2 -> key ) ; preorder ( root1 -> left , root2 -> right , lvl + 1 ) ; preorder ( root1 -> right , root2 -> left , lvl + 1 ) ; } void reverseAlternate ( struct Node * root ) { preorder ( root -> left , root -> right , 0 ) ; } void printInorder ( struct Node * root ) { if ( root == NULL ) return ; printInorder ( root -> left ) ; cout << root -> key << " ▁ " ; printInorder ( root -> right ) ; } Node * newNode ( int key ) { Node * temp = new Node ; temp -> left = temp -> right = NULL ; temp -> key = key ; return temp ; } int main ( ) { struct Node * root = newNode ( ' a ' ) ; root -> left = newNode ( ' b ' ) ; root -> right = newNode ( ' c ' ) ; root -> left -> left = newNode ( ' d ' ) ; root -> left -> right = newNode ( ' e ' ) ; root -> right -> left = newNode ( ' f ' ) ; root -> right -> right = newNode ( ' g ' ) ; root -> left -> left -> left = newNode ( ' h ' ) ; root -> left -> left -> right = newNode ( ' i ' ) ; root -> left -> right -> left = newNode ( ' j ' ) ; root -> left -> right -> right = newNode ( ' k ' ) ; root -> right -> left -> left = newNode ( ' l ' ) ; root -> right -> left -> right = newNode ( ' m ' ) ; root -> right -> right -> left = newNode ( ' n ' ) ; root -> right -> right -> right = newNode ( ' o ' ) ; cout << " Inorder ▁ Traversal ▁ of ▁ given ▁ tree STRNEWLINE " ; printInorder ( root ) ; reverseAlternate ( root ) ; cout << " Inorder Traversal of modified tree " ; printInorder ( root ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int key ; struct Node * left , * right ; } ; struct Node * newNode ( int key ) { struct Node * temp = new Node ; temp -> key = key ; temp -> left = temp -> right = NULL ; return temp ; } ; void inorder ( struct Node * temp ) { if ( ! temp ) return ; inorder ( temp -> left ) ; cout << temp -> key << " ▁ " ; inorder ( temp -> right ) ; } void deletDeepest ( struct Node * root , struct Node * d_node ) { queue < struct Node * > q ; q . push ( root ) ; struct Node * temp ; while ( ! q . empty ( ) ) { temp = q . front ( ) ; q . pop ( ) ; if ( temp == d_node ) { temp = NULL ; delete ( d_node ) ; return ; } if ( temp -> right ) { if ( temp -> right == d_node ) { temp -> right = NULL ; delete ( d_node ) ; return ; } else q . push ( temp -> right ) ; } if ( temp -> left ) { if ( temp -> left == d_node ) { temp -> left = NULL ; delete ( d_node ) ; return ; } else q . push ( temp -> left ) ; } } } Node * deletion ( struct Node * root , int key ) { if ( root == NULL ) return NULL ; if ( root -> left == NULL && root -> right == NULL ) { if ( root -> key == key ) return NULL ; else return root ; } queue < struct Node * > q ; q . push ( root ) ; struct Node * temp ; struct Node * key_node = NULL ; while ( ! q . empty ( ) ) { temp = q . front ( ) ; q . pop ( ) ; if ( temp -> key == key ) key_node = temp ; if ( temp -> left ) q . push ( temp -> left ) ; if ( temp -> right ) q . push ( temp -> right ) ; } if ( key_node != NULL ) { int x = temp -> key ; deletDeepest ( root , temp ) ; key_node -> key = x ; } return root ; } int main ( ) { struct Node * root = newNode ( 10 ) ; root -> left = newNode ( 11 ) ; root -> left -> left = newNode ( 7 ) ; root -> left -> right = newNode ( 12 ) ; root -> right = newNode ( 9 ) ; root -> right -> left = newNode ( 15 ) ; root -> right -> right = newNode ( 8 ) ; cout << " Inorder ▁ traversal ▁ before ▁ deletion ▁ : ▁ " ; inorder ( root ) ; int key = 11 ; root = deletion ( root , key ) ; cout << endl ; cout << " Inorder ▁ traversal ▁ after ▁ deletion ▁ : ▁ " ; inorder ( root ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSink ( int n , int m , int edgeFrom [ ] , int edgeTo [ ] ) { int mark [ n ] ; memset ( mark , 0 , sizeof mark ) ; for ( int i = 0 ; i < m ; i ++ ) mark [ edgeFrom [ i ] ] = 1 ; int count = 0 ; for ( int i = 1 ; i <= n ; i ++ ) if ( ! mark [ i ] ) count ++ ; return count ; } int main ( ) { int n = 4 , m = 2 ; int edgeFrom [ ] = { 2 , 4 } ; int edgeTo [ ] = { 3 , 3 } ; cout << countSink ( n , m , edgeFrom , edgeTo ) << endl ; return 0 ; }

Index/key variables: i, n
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int N = 6 ; int subsetGraph ( int C [ ] [ N ] ) { set < int > vertices ; for ( int i = 0 ; i < N ; ++ i ) vertices . insert ( i ) ; while ( ! vertices . empty ( ) ) { if ( vertices . size ( ) == 1 ) return 1 ; bool someone_removed = false ; for ( int x : vertices ) { set < int > values ; for ( int y : vertices ) if ( y != x ) values . insert ( C [ x ] [ y ] ) ; if ( values . size ( ) == 1 ) { vertices . erase ( x ) ; someone_removed = true ; break ; } } if ( ! someone_removed ) break ; } return ( vertices . size ( ) ) ; } int main ( ) { int C [ ] [ N ] = { { 0 , 9 , 2 , 4 , 7 , 8 } , { 9 , 0 , 9 , 9 , 7 , 9 } , { 2 , 9 , 0 , 3 , 7 , 6 } , { 4 , 9 , 3 , 0 , 7 , 1 } , { 7 , 7 , 7 , 7 , 0 , 7 } , { 8 , 9 , 6 , 1 , 7 , 0 } } ; cout << subsetGraph ( C ) ; return 0 ; }

Index/key variables: N, x, y
Accumulator variables: stdc
Iterator variables: i, x, y
Boolean variables: someone_removed
C++ program:
#include <bits/stdc++.h>
using namespace std ; class Graph { int V ; list < int > * adj ; public : Graph ( int V ) { this -> V = V ; adj = new list < int > [ V ] ; } void addEdge ( int u , int v ) ; int countEdges ( ) ; } ; void Graph :: addEdge ( int u , int v ) { adj [ u ] . push_back ( v ) ; adj [ v ] . push_back ( u ) ; } int Graph :: countEdges ( ) { int sum = 0 ; for ( int i = 0 ; i < V ; i ++ ) sum += adj [ i ] . size ( ) ; return sum / 2 ; } int main ( ) { int V = 9 ; Graph g ( V ) ; g . addEdge ( 0 , 1 ) ; g . addEdge ( 0 , 7 ) ; g . addEdge ( 1 , 2 ) ; g . addEdge ( 1 , 7 ) ; g . addEdge ( 2 , 3 ) ; g . addEdge ( 2 , 8 ) ; g . addEdge ( 2 , 5 ) ; g . addEdge ( 3 , 4 ) ; g . addEdge ( 3 , 5 ) ; g . addEdge ( 4 , 5 ) ; g . addEdge ( 5 , 6 ) ; g . addEdge ( 6 , 7 ) ; g . addEdge ( 6 , 8 ) ; g . addEdge ( 7 , 8 ) ; cout << g . countEdges ( ) << endl ; return 0 ; }

Index/key variables: V, i, u, v
Accumulator variables: i, stdc, sum
Iterator variables: i
Class/struct names: Graph
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int V = 5 ; bool isBipartiteUtil ( int G [ ] [ V ] , int src , int colorArr [ ] ) { colorArr [ src ] = 1 ; queue < int > q ; q . push ( src ) ; while ( ! q . empty ( ) ) { int u = q . front ( ) ; q . pop ( ) ; for ( int v = 0 ; v < V ; ++ v ) { if ( G [ u ] [ v ] && colorArr [ v ] == -1 ) { colorArr [ v ] = 1 - colorArr [ u ] ; q . push ( v ) ; } else if ( G [ u ] [ v ] && colorArr [ v ] == colorArr [ u ] ) return false ; } } return true ; } bool isBipartite ( int G [ ] [ V ] ) { int colorArr [ V ] ; for ( int i = 0 ; i < V ; ++ i ) colorArr [ i ] = -1 ; for ( int i = 0 ; i < V ; i ++ ) if ( colorArr [ i ] == -1 ) if ( isBipartiteUtil ( G , i , colorArr ) == false ) return false ; return true ; } bool canBeDividedinTwoCliques ( int G [ ] [ V ] ) { int GC [ V ] [ V ] ; for ( int i = 0 ; i < V ; i ++ ) for ( int j = 0 ; j < V ; j ++ ) GC [ i ] [ j ] = ( i != j ) ? ! G [ i ] [ j ] : 0 ; return isBipartite ( GC ) ; } int main ( ) { int G [ ] [ V ] = { { 0 , 1 , 1 , 1 , 0 } , { 1 , 0 , 1 , 0 , 0 } , { 1 , 1 , 0 , 0 , 0 } , { 0 , 1 , 0 , 0 , 1 } , { 0 , 0 , 0 , 1 , 0 } } ; canBeDividedinTwoCliques ( G ) ? cout << " Yes " : cout << " No " ; return 0 ; }

Index/key variables: V, i, j, src, u, v
Accumulator variables: i, j, stdc
Iterator variables: i, j, v
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( int degree [ ] , int n ) { int deg_sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) deg_sum += degree [ i ] ; return ( 2 * ( n - 1 ) == deg_sum ) ; } int main ( ) { int n = 5 ; int degree [ ] = { 2 , 3 , 1 , 1 , 1 } ; if ( check ( degree , n ) ) cout << " Tree " ; else cout << " Graph " ; return 0 ; }

Index/key variables: i
Accumulator variables: deg_sum, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define maxn  25
using namespace std ; bool gr [ maxn ] [ maxn ] ; bool isCover ( int V , int k , int E ) { int set = ( 1 << k ) - 1 ; int limit = ( 1 << V ) ; bool vis [ maxn ] [ maxn ] ; while ( set < limit ) { memset ( vis , 0 , sizeof vis ) ; int cnt = 0 ; for ( int j = 1 , v = 1 ; j < limit ; j = j << 1 , v ++ ) { if ( set & j ) { for ( int k = 1 ; k <= V ; k ++ ) { if ( gr [ v ] [ k ] && ! vis [ v ] [ k ] ) { vis [ v ] [ k ] = 1 ; vis [ k ] [ v ] = 1 ; cnt ++ ; } } } } if ( cnt == E ) return true ; int c = set & - set ; int r = set + c ; set = ( ( ( r ^ set ) >> 2 ) / c ) | r ; } return false ; } int findMinCover ( int n , int m ) { int left = 1 , right = n ; while ( right > left ) { int mid = ( left + right ) >> 1 ; if ( isCover ( n , mid , m ) == false ) left = mid + 1 ; else right = mid ; } return left ; } void insertEdge ( int u , int v ) { gr [ u ] [ v ] = 1 ; gr [ v ] [ u ] = 1 ; } int main ( ) { int V = 6 , E = 6 ; insertEdge ( 1 , 2 ) ; insertEdge ( 2 , 3 ) ; insertEdge ( 1 , 3 ) ; insertEdge ( 1 , 4 ) ; insertEdge ( 1 , 5 ) ; insertEdge ( 1 , 6 ) ; cout << " Minimum ▁ size ▁ of ▁ a ▁ vertex ▁ cover ▁ = ▁ " << findMinCover ( V , E ) << endl ; memset ( gr , 0 , sizeof gr ) ; V = 6 , E = 7 ; insertEdge ( 1 , 2 ) ; insertEdge ( 1 , 3 ) ; insertEdge ( 2 , 3 ) ; insertEdge ( 2 , 4 ) ; insertEdge ( 3 , 5 ) ; insertEdge ( 4 , 5 ) ; insertEdge ( 4 , 6 ) ; cout << " Minimum ▁ size ▁ of ▁ a ▁ vertex ▁ cover ▁ = ▁ " << findMinCover ( V , E ) << endl ; return 0 ; }

Index/key variables: k, maxn, u, v
Accumulator variables: cnt, k, stdc, v
Iterator variables: j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; class node { public : int data ; node * left , * right ; } ; node * newNode ( int data ) { node * temp = new node ( ) ; temp -> data = data ; temp -> left = temp -> right = NULL ; return temp ; } void morrisTraversalPreorder ( node * root ) { while ( root ) { if ( root -> left == NULL ) { cout << root -> data << " ▁ " ; root = root -> right ; } else { node * current = root -> left ; while ( current -> right && current -> right != root ) current = current -> right ; if ( current -> right == root ) { current -> right = NULL ; root = root -> right ; } else { cout << root -> data << " ▁ " ; current -> right = root ; root = root -> left ; } } } } void preorder ( node * root ) { if ( root ) { cout << root -> data << " ▁ " ; preorder ( root -> left ) ; preorder ( root -> right ) ; } } int main ( ) { node * root = NULL ; root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 5 ) ; root -> right -> left = newNode ( 6 ) ; root -> right -> right = newNode ( 7 ) ; root -> left -> left -> left = newNode ( 8 ) ; root -> left -> left -> right = newNode ( 9 ) ; root -> left -> right -> left = newNode ( 10 ) ; root -> left -> right -> right = newNode ( 11 ) ; morrisTraversalPreorder ( root ) ; cout << endl ; preorder ( root ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; void addEdge ( vector < int > adj [ ] , int u , int v ) { adj [ u ] . push_back ( v ) ; } int findSum ( vector < int > adj [ ] , int V ) { int sum = 0 ; for ( int u = 0 ; u < V ; u ++ ) sum += adj [ u ] . size ( ) ; return sum ; } int main ( ) { int V = 4 ; vector < int > adj [ V ] ; addEdge ( adj , 0 , 2 ) ; addEdge ( adj , 0 , 3 ) ; addEdge ( adj , 1 , 3 ) ; addEdge ( adj , 2 , 3 ) ; cout << " Sum ▁ of ▁ dependencies ▁ is ▁ " << findSum ( adj , V ) ; return 0 ; }

Index/key variables: V, u
Accumulator variables: stdc, sum, u
Iterator variables: u
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct node { int data ; struct node * left ; struct node * right ; } ; struct node * newNode ( int data ) { struct node * node = new struct node ; node -> data = data ; node -> left = NULL ; node -> right = NULL ; return ( node ) ; } void iterativePreorder ( node * root ) { if ( root == NULL ) return ; stack < node * > nodeStack ; nodeStack . push ( root ) ; while ( nodeStack . empty ( ) == false ) { struct node * node = nodeStack . top ( ) ; printf ( " % d ▁ " , node -> data ) ; nodeStack . pop ( ) ; if ( node -> right ) nodeStack . push ( node -> right ) ; if ( node -> left ) nodeStack . push ( node -> left ) ; } } 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 -> left = newNode ( 2 ) ; iterativePreorder ( root ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; Node * left , * right ; Node ( int data ) { this -> data = data ; this -> left = this -> right = NULL ; } } ; void preorderIterative ( Node * root ) { if ( root == NULL ) return ; stack < Node * > st ; Node * curr = root ; while ( ! st . empty ( ) curr != NULL ) { while ( curr != NULL ) { cout << curr -> data << " ▁ " ; if ( curr -> right ) st . push ( curr -> right ) ; curr = curr -> left ; } if ( st . empty ( ) == false ) { curr = st . top ( ) ; st . pop ( ) ; } } } int main ( ) { Node * root = new Node ( 10 ) ; root -> left = new Node ( 20 ) ; root -> right = new Node ( 30 ) ; root -> left -> left = new Node ( 40 ) ; root -> left -> left -> left = new Node ( 70 ) ; root -> left -> right = new Node ( 50 ) ; root -> right -> left = new Node ( 60 ) ; root -> left -> left -> right = new Node ( 80 ) ; preorderIterative ( root ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * next ; } ; int frequency = 0 ; void push ( struct Node * * head_ref , int new_data ) { struct Node * new_node = ( struct Node * ) malloc ( sizeof ( struct Node ) ) ; new_node -> data = new_data ; new_node -> next = ( * head_ref ) ; ( * head_ref ) = new_node ; } int count ( struct Node * head , int key ) { if ( head == NULL ) return frequency ; if ( head -> data == key ) frequency ++ ; return count ( head -> next , key ) ; } int main ( ) { struct Node * head = NULL ; push ( & head , 1 ) ; push ( & head , 3 ) ; push ( & head , 1 ) ; push ( & head , 2 ) ; push ( & head , 1 ) ; cout << " count ▁ of ▁ 1 ▁ is ▁ " << count ( head , 1 ) ; return 0 ; }

Accumulator variables: frequency, stdc
Class/struct names: Node
C++ program:
int count ( struct Node * head , int key ) { if ( head == NULL ) return 0 ; if ( head -> data == key ) return 1 + count ( head -> next , key ) ; return count ( head -> next , key ) ; }

Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * next ; int flag ; } ; void push ( struct Node * * head_ref , int new_data ) { struct Node * new_node = new Node ; new_node -> data = new_data ; new_node -> flag = 0 ; new_node -> next = ( * head_ref ) ; ( * head_ref ) = new_node ; } bool detectLoop ( struct Node * h ) { while ( h != NULL ) { if ( h -> flag == 1 ) return true ; h -> flag = 1 ; h = h -> next ; } return false ; } int main ( ) { struct Node * head = NULL ; push ( & head , 20 ) ; push ( & head , 4 ) ; push ( & head , 15 ) ; push ( & head , 10 ) ; head -> next -> next -> next -> next = head ; if ( detectLoop ( head ) ) cout << " Loop ▁ found " ; else cout << " No ▁ Loop " ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; class Node { public : int data ; Node * next ; } ; void push ( Node * * head_ref , int new_data ) { Node * new_node = new Node ( ) ; new_node -> data = new_data ; new_node -> next = ( * head_ref ) ; ( * head_ref ) = new_node ; } int detectLoop ( Node * list ) { Node * slow_p = list , * fast_p = list ; while ( slow_p && fast_p && fast_p -> next ) { slow_p = slow_p -> next ; fast_p = fast_p -> next -> next ; if ( slow_p == fast_p ) { return 1 ; } } return 0 ; } int main ( ) { Node * head = NULL ; push ( & head , 20 ) ; push ( & head , 4 ) ; push ( & head , 15 ) ; push ( & head , 10 ) ; head -> next -> next -> next -> next = head ; if ( detectLoop ( head ) ) cout << " Loop ▁ found " ; else cout << " No ▁ Loop " ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int key ; struct Node * next ; } ; Node * newNode ( int key ) { Node * temp = new Node ; temp -> key = key ; temp -> next = NULL ; return temp ; } void printList ( Node * head ) { while ( head != NULL ) { cout << head -> key << " ▁ " ; head = head -> next ; } cout << endl ; } bool detectLoop ( Node * head ) { Node * temp = new Node ; while ( head != NULL ) { if ( head -> next == NULL ) { return false ; } if ( head -> next == temp ) { return true ; } Node * nex = head -> next ; head -> next = temp ; head = nex ; } return false ; } int main ( ) { Node * head = newNode ( 1 ) ; head -> next = newNode ( 2 ) ; head -> next -> next = newNode ( 3 ) ; head -> next -> next -> next = newNode ( 4 ) ; head -> next -> next -> next -> next = newNode ( 5 ) ; head -> next -> next -> next -> next -> next = head -> next -> next ; bool found = detectLoop ( head ) ; if ( found ) cout << " Loop ▁ Found " ; else cout << " No ▁ Loop " ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int key ; struct Node * next ; } ; Node * newNode ( int key ) { Node * temp = new Node ; temp -> key = key ; temp -> next = NULL ; return temp ; } void printList ( Node * head ) { while ( head != NULL ) { cout << head -> key << " ▁ " ; head = head -> next ; } cout << endl ; } int distance ( Node * first , Node * last ) { int counter = 0 ; Node * curr ; curr = first ; while ( curr != last ) { counter += 1 ; curr = curr -> next ; } return counter + 1 ; } bool detectLoop ( Node * head ) { Node * temp = new Node ; Node * first , * last ; first = head ; last = head ; int current_length = 0 ; int prev_length = -1 ; while ( current_length > prev_length && last != NULL ) { prev_length = current_length ; current_length = distance ( first , last ) ; last = last -> next ; } if ( last == NULL ) { return false ; } else { return true ; } } int main ( ) { Node * head = newNode ( 1 ) ; head -> next = newNode ( 2 ) ; head -> next -> next = newNode ( 3 ) ; head -> next -> next -> next = newNode ( 4 ) ; head -> next -> next -> next -> next = newNode ( 5 ) ; head -> next -> next -> next -> next -> next = head -> next -> next ; bool found = detectLoop ( head ) ; if ( found ) cout << " Loop ▁ Found " ; else cout << " No ▁ Loop ▁ Found " ; return 0 ; }

Accumulator variables: counter, stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; Node * next ; Node ( ) { data = 0 ; next = NULL ; } } ; void push ( Node * * head_ref , int new_data ) { Node * new_node = new Node ( ) ; new_node -> data = new_data ; new_node -> next = ( * head_ref ) ; ( * head_ref ) = new_node ; } void printList ( Node * node ) { while ( node != NULL ) { cout << node -> data << " ▁ " ; node = node -> next ; } } void removeDuplicates ( Node * head ) { unordered_map < int , bool > track ; Node * temp = head ; while ( temp ) { if ( track . find ( temp -> data ) == track . end ( ) ) { cout << temp -> data << " ▁ " ; } track [ temp -> data ] = true ; temp = temp -> next ; } } int main ( ) { Node * head = NULL ; push ( & head , 20 ) ; push ( & head , 13 ) ; push ( & head , 13 ) ; push ( & head , 11 ) ; push ( & head , 11 ) ; push ( & head , 11 ) ; cout << " Linked ▁ list ▁ before ▁ duplicate ▁ removal ▁ " ; printList ( head ) ; cout << " Linked list after duplicate removal " ; removeDuplicates ( head ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; class Node { public : int data ; Node * next ; } ; void swapNodes ( Node * * head_ref , int x , int y ) { if ( x == y ) return ; Node * prevX = NULL , * currX = * head_ref ; while ( currX && currX -> data != x ) { prevX = currX ; currX = currX -> next ; } Node * prevY = NULL , * currY = * head_ref ; while ( currY && currY -> data != y ) { prevY = currY ; currY = currY -> next ; } if ( currX == NULL currY == NULL ) return ; if ( prevX != NULL ) prevX -> next = currY ; else * head_ref = currY ; if ( prevY != NULL ) prevY -> next = currX ; else * head_ref = currX ; Node * temp = currY -> next ; currY -> next = currX -> next ; currX -> next = temp ; } void push ( Node * * head_ref , int new_data ) { Node * new_node = new Node ( ) ; new_node -> data = new_data ; new_node -> next = ( * head_ref ) ; ( * head_ref ) = new_node ; } void printList ( Node * node ) { while ( node != NULL ) { cout << node -> data << " ▁ " ; node = node -> next ; } } int main ( ) { Node * start = NULL ; push ( & start , 7 ) ; push ( & start , 6 ) ; push ( & start , 5 ) ; push ( & start , 4 ) ; push ( & start , 3 ) ; push ( & start , 2 ) ; push ( & start , 1 ) ; cout << " Linked ▁ list ▁ before ▁ calling ▁ swapNodes ( ) ▁ " ; printList ( start ) ; swapNodes ( & start , 4 , 3 ) ; cout << " Linked list after calling swapNodes ( ) " ; printList ( start ) ; 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 , * right ; } ; void postorder ( struct Node * head ) { struct Node * temp = head ; unordered_set < Node * > visited ; while ( temp && visited . find ( temp ) == visited . end ( ) ) { if ( temp -> left && visited . find ( temp -> left ) == visited . end ( ) ) temp = temp -> left ; else if ( temp -> right && visited . find ( temp -> right ) == visited . end ( ) ) temp = temp -> right ; else { printf ( " % d ▁ " , temp -> data ) ; visited . insert ( temp ) ; temp = head ; } } } struct Node * newNode ( int data ) { struct Node * node = new Node ; node -> data = data ; node -> left = NULL ; node -> right = NULL ; return ( node ) ; } int main ( ) { struct Node * root = newNode ( 8 ) ; root -> left = newNode ( 3 ) ; root -> right = newNode ( 10 ) ; root -> left -> left = newNode ( 1 ) ; root -> left -> right = newNode ( 6 ) ; root -> left -> right -> left = newNode ( 4 ) ; root -> left -> right -> right = newNode ( 7 ) ; root -> right -> right = newNode ( 14 ) ; root -> right -> right -> left = newNode ( 13 ) ; postorder ( root ) ; 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 , * right ; bool visited ; } ; void postorder ( struct Node * head ) { struct Node * temp = head ; while ( temp && temp -> visited == false ) { if ( temp -> left && temp -> left -> visited == false ) temp = temp -> left ; else if ( temp -> right && temp -> right -> visited == false ) temp = temp -> right ; else { printf ( " % d ▁ " , temp -> data ) ; temp -> visited = true ; temp = head ; } } } struct Node * newNode ( int data ) { struct Node * node = new Node ; node -> data = data ; node -> left = NULL ; node -> right = NULL ; node -> visited = false ; return ( node ) ; } int main ( ) { struct Node * root = newNode ( 8 ) ; root -> left = newNode ( 3 ) ; root -> right = newNode ( 10 ) ; root -> left -> left = newNode ( 1 ) ; root -> left -> right = newNode ( 6 ) ; root -> left -> right -> left = newNode ( 4 ) ; root -> left -> right -> right = newNode ( 7 ) ; root -> right -> right = newNode ( 14 ) ; root -> right -> right -> left = newNode ( 13 ) ; postorder ( root ) ; return 0 ; }

Accumulator variables: stdc
Boolean variables: visited
Class/struct names: Node