dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * next ; } ; bool isCircular ( struct Node * head ) { if ( head == NULL ) return true ; struct Node * node = head -> next ; while ( node != NULL && node != head ) node = node -> next ; return ( node == head ) ; } Node * newNode ( int data ) { struct Node * temp = new Node ; temp -> data = data ; temp -> next = NULL ; return temp ; } int main ( ) { struct Node * head = newNode ( 1 ) ; head -> next = newNode ( 2 ) ; head -> next -> next = newNode ( 3 ) ; head -> next -> next -> next = newNode ( 4 ) ; isCircular ( head ) ? cout << " Yes STRNEWLINE " : cout << " No STRNEWLINE " ; head -> next -> next -> next -> next = head ; isCircular ( head ) ? cout << " Yes STRNEWLINE " : cout << " No STRNEWLINE " ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
struct Node * addToEmpty ( struct Node * last , int data ) { if ( last != NULL ) return last ; struct Node * temp = ( struct Node * ) malloc ( sizeof ( struct Node ) ) ; temp -> data = data ; last = temp ; temp -> next = last ; return last ; }

Class/struct names: Node
C++ program:
struct Node * addBegin ( struct Node * last , int data ) { if ( last == NULL ) return addToEmpty ( last , data ) ; struct Node * temp = ( struct Node * ) malloc ( sizeof ( struct Node ) ) ; temp -> data = data ; temp -> next = last -> next ; last -> next = temp ; return last ; }

Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; Node * left , * right ; } ; void diagonalPrintUtil ( Node * root , int d , map < int , vector < int > > & diagonalPrint ) { if ( ! root ) return ; diagonalPrint [ d ] . push_back ( root -> data ) ; diagonalPrintUtil ( root -> left , d + 1 , diagonalPrint ) ; diagonalPrintUtil ( root -> right , d , diagonalPrint ) ; } void diagonalPrint ( Node * root ) { map < int , vector < int > > diagonalPrint ; diagonalPrintUtil ( root , 0 , diagonalPrint ) ; cout << " Diagonal ▁ Traversal ▁ of ▁ binary ▁ tree ▁ : ▁ STRNEWLINE " ; for ( auto it : diagonalPrint ) { vector < int > v = it . second ; for ( auto it : v ) cout << it << " ▁ " ; cout << endl ; } } Node * newNode ( int data ) { Node * node = new Node ; node -> data = data ; node -> left = node -> right = NULL ; return node ; } int main ( ) { Node * root = newNode ( 8 ) ; root -> left = newNode ( 3 ) ; root -> right = newNode ( 10 ) ; root -> left -> left = newNode ( 1 ) ; root -> left -> right = newNode ( 6 ) ; root -> right -> right = newNode ( 14 ) ; root -> right -> right -> left = newNode ( 13 ) ; root -> left -> right -> left = newNode ( 4 ) ; root -> left -> right -> right = newNode ( 7 ) ; diagonalPrint ( root ) ; return 0 ; }

Index/key variables: d
Accumulator variables: stdc
Iterator variables: it
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; char tree [ 10 ] ; int root ( char key ) { if ( tree [ 0 ] != ' \0' ) cout << " Tree ▁ already ▁ had ▁ root " ; else tree [ 0 ] = key ; return 0 ; } int set_left ( char key , int parent ) { if ( tree [ parent ] == ' \0' ) cout << " Can ' set child at " << ( parent * 2 ) + 1 << " ▁ , ▁ no ▁ parent ▁ found " ; else tree [ ( parent * 2 ) + 1 ] = key ; return 0 ; } int set_right ( char key , int parent ) { if ( tree [ parent ] == ' \0' ) cout << " Can ' set child at " << ( parent * 2 ) + 2 << " ▁ , ▁ no ▁ parent ▁ found " ; else tree [ ( parent * 2 ) + 2 ] = key ; return 0 ; } int print_tree ( ) { cout << " STRNEWLINE " ; for ( int i = 0 ; i < 10 ; i ++ ) { if ( tree [ i ] != ' \0' ) cout << tree [ i ] ; else cout << " - " ; } return 0 ; } int main ( ) { root ( ' A ' ) ; set_right ( ' C ' , 0 ) ; set_left ( ' D ' , 1 ) ; set_right ( ' E ' , 1 ) ; set_right ( ' F ' , 2 ) ; print_tree ( ) ; return 0 ; }

Index/key variables: i, parent
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * next ; } ; 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 ; } void printList ( struct Node * node ) { while ( node != NULL ) { cout << node -> data << " ▁ " ; node = node -> next ; } cout << endl ; } int countNodes ( struct Node * s ) { int count = 0 ; while ( s != NULL ) { count ++ ; s = s -> next ; } return count ; } void swapKth ( struct Node * * head_ref , int k ) { int n = countNodes ( * head_ref ) ; if ( n < k ) return ; if ( 2 * k - 1 == n ) return ; Node * x = * head_ref ; Node * x_prev = NULL ; for ( int i = 1 ; i < k ; i ++ ) { x_prev = x ; x = x -> next ; } Node * y = * head_ref ; Node * y_prev = NULL ; for ( int i = 1 ; i < n - k + 1 ; i ++ ) { y_prev = y ; y = y -> next ; } if ( x_prev ) x_prev -> next = y ; if ( y_prev ) y_prev -> next = x ; Node * temp = x -> next ; x -> next = y -> next ; y -> next = temp ; if ( k == 1 ) * head_ref = y ; if ( k == n ) * head_ref = x ; } int main ( ) { struct Node * head = NULL ; for ( int i = 8 ; i >= 1 ; i -- ) push ( & head , i ) ; cout << " Original ▁ Linked ▁ List : ▁ " ; printList ( head ) ; for ( int k = 1 ; k < 9 ; k ++ ) { swapKth ( & head , k ) ; cout << " Modified List for k = " printList ( head ) ; } return 0 ; }

Accumulator variables: count, i, k, stdc
Iterator variables: i, k
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * next , * prev ; } ; void pairSum ( struct Node * head , int x ) { struct Node * first = head ; struct Node * second = head ; while ( second -> next != NULL ) second = second -> next ; bool found = false ; while ( first != second && second -> next != first ) { if ( ( first -> data + second -> data ) == x ) { found = true ; cout << " ( " << first -> data << " , ▁ " << second -> data << " ) " << endl ; first = first -> next ; second = second -> prev ; } else { if ( ( first -> data + second -> data ) < x ) first = first -> next ; else second = second -> prev ; } } if ( found == false ) cout << " No ▁ pair ▁ found " ; } void insert ( struct Node * * head , int data ) { struct Node * temp = new Node ; temp -> data = data ; temp -> next = temp -> prev = NULL ; if ( ! ( * head ) ) ( * head ) = temp ; else { temp -> next = * head ; ( * head ) -> prev = temp ; ( * head ) = temp ; } } int main ( ) { struct Node * head = NULL ; insert ( & head , 9 ) ; insert ( & head , 8 ) ; insert ( & head , 6 ) ; insert ( & head , 5 ) ; insert ( & head , 4 ) ; insert ( & head , 2 ) ; insert ( & head , 1 ) ; int x = 7 ; pairSum ( head , x ) ; return 0 ; }

Accumulator variables: stdc
Boolean variables: found
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; Node * left , * right ; } ; Node * newNode ( int data ) { Node * node = ( Node * ) malloc ( sizeof ( Node ) ) ; node -> data = data ; node -> left = node -> right = NULL ; return ( node ) ; } void diagonalPrint ( Node * root ) { if ( root == NULL ) return ; queue < Node * > q ; q . push ( root ) ; q . push ( NULL ) ; while ( ! q . empty ( ) ) { Node * temp = q . front ( ) ; q . pop ( ) ; if ( temp == NULL ) { if ( q . empty ( ) ) return ; cout << endl ; q . push ( NULL ) ; } else { while ( temp ) { cout << temp -> data << " ▁ " ; if ( temp -> left ) q . push ( temp -> left ) ; temp = temp -> right ; } } } } int main ( ) { Node * root = newNode ( 8 ) ; root -> left = newNode ( 3 ) ; root -> right = newNode ( 10 ) ; root -> left -> left = newNode ( 1 ) ; root -> left -> right = newNode ( 6 ) ; root -> right -> right = newNode ( 14 ) ; root -> right -> right -> left = newNode ( 13 ) ; root -> left -> right -> left = newNode ( 4 ) ; root -> left -> right -> right = newNode ( 7 ) ; diagonalPrint ( root ) ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * next , * prev ; } ; int countPairs ( struct Node * first , struct Node * second , int value ) { int count = 0 ; while ( first != NULL && second != NULL && first != second && second -> next != first ) { if ( ( first -> data + second -> data ) == value ) { count ++ ; first = first -> next ; second = second -> prev ; } else if ( ( first -> data + second -> data ) > value ) second = second -> prev ; else first = first -> next ; } return count ; } int countTriplets ( struct Node * head , int x ) { if ( head == NULL ) return 0 ; struct Node * current , * first , * last ; int count = 0 ; last = head ; while ( last -> next != NULL ) last = last -> next ; for ( current = head ; current != NULL ; current = current -> next ) { first = current -> next ; count += countPairs ( first , last , x - current -> data ) ; } return count ; } void insert ( struct Node * * head , int data ) { struct Node * temp = new Node ( ) ; temp -> data = data ; temp -> next = temp -> prev = NULL ; if ( ( * head ) == NULL ) ( * head ) = temp ; else { temp -> next = * head ; ( * head ) -> prev = temp ; ( * head ) = temp ; } } int main ( ) { struct Node * head = NULL ; insert ( & head , 9 ) ; insert ( & head , 8 ) ; insert ( & head , 6 ) ; insert ( & head , 5 ) ; insert ( & head , 4 ) ; insert ( & head , 2 ) ; insert ( & head , 1 ) ; int x = 17 ; cout << " Count ▁ = ▁ " << countTriplets ( head , x ) ; return 0 ; }

Accumulator variables: count, stdc
Iterator variables: current
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * next ; struct Node * prev ; } ; void deleteNode ( struct Node * * head_ref , struct Node * del ) { if ( * head_ref == NULL del == NULL ) return ; if ( * head_ref == del ) * head_ref = del -> next ; if ( del -> next != NULL ) del -> next -> prev = del -> prev ; if ( del -> prev != NULL ) del -> prev -> next = del -> next ; free ( del ) ; } void removeDuplicates ( struct Node * * head_ref ) { if ( ( * head_ref ) == NULL || ( * head_ref ) -> next == NULL ) return ; struct Node * ptr1 , * ptr2 ; for ( ptr1 = * head_ref ; ptr1 != NULL ; ptr1 = ptr1 -> next ) { ptr2 = ptr1 -> next ; while ( ptr2 != NULL ) { if ( ptr1 -> data == ptr2 -> data ) { struct Node * next = ptr2 -> next ; deleteNode ( head_ref , ptr2 ) ; ptr2 = next ; } else ptr2 = ptr2 -> next ; } } } 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 -> prev = NULL ; new_node -> next = ( * head_ref ) ; if ( ( * head_ref ) != NULL ) ( * head_ref ) -> prev = new_node ; ( * head_ref ) = new_node ; } void printList ( struct Node * head ) { if ( head == NULL ) cout << " Doubly ▁ Linked ▁ list ▁ empty " ; while ( head != NULL ) { cout << head -> data << " ▁ " ; head = head -> next ; } } int main ( ) { struct Node * head = NULL ; push ( & head , 12 ) ; push ( & head , 12 ) ; push ( & head , 10 ) ; push ( & head , 4 ) ; push ( & head , 8 ) ; push ( & head , 4 ) ; push ( & head , 6 ) ; push ( & head , 4 ) ; push ( & head , 4 ) ; push ( & head , 8 ) ; cout << " Original ▁ Doubly ▁ linked ▁ list : n " ; printList ( head ) ; removeDuplicates ( & head ) ; cout << " Doubly linked list after " STRNEWLINE TABSYMBOL TABSYMBOL TABSYMBOL " removing duplicates : n " ; printList ( head ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: ptr1
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * next ; struct Node * prev ; } ; void deleteNode ( struct Node * * head_ref , struct Node * del ) { if ( * head_ref == NULL del == NULL ) return ; if ( * head_ref == del ) * head_ref = del -> next ; if ( del -> next != NULL ) del -> next -> prev = del -> prev ; if ( del -> prev != NULL ) del -> prev -> next = del -> next ; free ( del ) ; } void removeDuplicates ( struct Node * * head_ref ) { if ( ( * head_ref ) == NULL ) return ; unordered_set < int > us ; struct Node * current = * head_ref , * next ; while ( current != NULL ) { if ( us . find ( current -> data ) != us . end ( ) ) { next = current -> next ; deleteNode ( head_ref , current ) ; current = next ; } else { us . insert ( current -> data ) ; current = current -> next ; } } } 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 -> prev = NULL ; new_node -> next = ( * head_ref ) ; if ( ( * head_ref ) != NULL ) ( * head_ref ) -> prev = new_node ; ( * head_ref ) = new_node ; } void printList ( struct Node * head ) { if ( head == NULL ) cout << " Doubly ▁ Linked ▁ list ▁ empty " ; while ( head != NULL ) { cout << head -> data << " ▁ " ; head = head -> next ; } } int main ( ) { struct Node * head = NULL ; push ( & head , 12 ) ; push ( & head , 12 ) ; push ( & head , 10 ) ; push ( & head , 4 ) ; push ( & head , 8 ) ; push ( & head , 4 ) ; push ( & head , 6 ) ; push ( & head , 4 ) ; push ( & head , 4 ) ; push ( & head , 8 ) ; cout << " Original ▁ Doubly ▁ linked ▁ list : n " ; printList ( head ) ; removeDuplicates ( & head ) ; cout << " Doubly linked list after " STRNEWLINE TABSYMBOL TABSYMBOL TABSYMBOL " removing duplicates : n " ; printList ( head ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; class Node { public : Node * prev ; int info ; Node * next ; } ; void nodeInsetail ( Node * * head , Node * * tail , int key ) { Node * p = new Node ( ) ; p -> info = key ; p -> next = NULL ; if ( ( * head ) == NULL ) { ( * head ) = p ; ( * tail ) = p ; ( * head ) -> prev = NULL ; return ; } if ( ( p -> info ) < ( ( * head ) -> info ) ) { p -> prev = NULL ; ( * head ) -> prev = p ; p -> next = ( * head ) ; ( * head ) = p ; return ; } if ( ( p -> info ) > ( ( * tail ) -> info ) ) { p -> prev = ( * tail ) ; ( * tail ) -> next = p ; ( * tail ) = p ; return ; } Node * temp = ( * head ) -> next ; while ( ( temp -> info ) < ( p -> info ) ) temp = temp -> next ; ( temp -> prev ) -> next = p ; p -> prev = temp -> prev ; temp -> prev = p ; p -> next = temp ; } void printList ( Node * temp ) { while ( temp != NULL ) { cout << temp -> info << " ▁ " ; temp = temp -> next ; } } int main ( ) { Node * left = NULL , * right = NULL ; nodeInsetail ( & left , & right , 30 ) ; nodeInsetail ( & left , & right , 50 ) ; nodeInsetail ( & left , & right , 90 ) ; nodeInsetail ( & left , & right , 10 ) ; nodeInsetail ( & left , & right , 40 ) ; nodeInsetail ( & left , & right , 110 ) ; nodeInsetail ( & left , & right , 60 ) ; nodeInsetail ( & left , & right , 95 ) ; nodeInsetail ( & left , & right , 23 ) ; cout << " Doubly ▁ linked ▁ list ▁ on ▁ printing " " ▁ from ▁ left ▁ to ▁ right STRNEWLINE " ; printList ( left ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
void insertEnd ( struct Node * * start , int value ) { if ( * start == NULL ) { struct Node * new_node = new Node ; new_node -> data = value ; new_node -> next = new_node -> prev = new_node ; * start = new_node ; return ; } Node * last = ( * start ) -> prev ; struct Node * new_node = new Node ; new_node -> data = value ; new_node -> next = * start ; ( * start ) -> prev = new_node ; new_node -> prev = last ; last -> next = new_node ; }

Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * next ; struct Node * prev ; } ; void insertEnd ( struct Node * * start , int value ) { if ( * start == NULL ) { struct Node * new_node = new Node ; new_node -> data = value ; new_node -> next = new_node -> prev = new_node ; * start = new_node ; return ; } Node * last = ( * start ) -> prev ; struct Node * new_node = new Node ; new_node -> data = value ; new_node -> next = * start ; ( * start ) -> prev = new_node ; new_node -> prev = last ; last -> next = new_node ; } void insertBegin ( struct Node * * start , int value ) { struct Node * last = ( * start ) -> prev ; struct Node * new_node = new Node ; new_node -> data = value ; new_node -> next = * start ; new_node -> prev = last ; last -> next = ( * start ) -> prev = new_node ; * start = new_node ; } void insertAfter ( struct Node * * start , int value1 , int value2 ) { struct Node * new_node = new Node ; new_node -> data = value1 ; struct Node * temp = * start ; while ( temp -> data != value2 ) temp = temp -> next ; struct Node * next = temp -> next ; temp -> next = new_node ; new_node -> prev = temp ; new_node -> next = next ; next -> prev = new_node ; } void display ( struct Node * start ) { struct Node * temp = start ; printf ( " Traversal in forward direction " while ( temp -> next != start ) { printf ( " % d ▁ " , temp -> data ) ; temp = temp -> next ; } printf ( " % d ▁ " , temp -> data ) ; printf ( " Traversal in reverse direction " Node * last = start -> prev ; temp = last ; while ( temp -> prev != last ) { printf ( " % d ▁ " , temp -> data ) ; temp = temp -> prev ; } printf ( " % d ▁ " , temp -> data ) ; } int main ( ) { struct Node * start = NULL ; insertEnd ( & start , 5 ) ; insertBegin ( & start , 4 ) ; insertEnd ( & start , 7 ) ; insertEnd ( & start , 8 ) ; insertAfter ( & start , 6 , 5 ) ; printf ( " Created ▁ circular ▁ doubly ▁ linked ▁ list ▁ is : ▁ " ) ; display ( start ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <stdio.h>
#include <stdlib.h>
struct node { int data ; struct node * left , * right ; } ; void printLeaves ( struct node * root ) { if ( root == NULL ) return ; printLeaves ( root -> left ) ; if ( ! ( root -> left ) && ! ( root -> right ) ) printf ( " % d ▁ " , root -> data ) ; printLeaves ( root -> right ) ; } void printBoundaryLeft ( struct node * root ) { if ( root == NULL ) return ; if ( root -> left ) { printf ( " % d ▁ " , root -> data ) ; printBoundaryLeft ( root -> left ) ; } else if ( root -> right ) { printf ( " % d ▁ " , root -> data ) ; printBoundaryLeft ( root -> right ) ; } } void printBoundaryRight ( struct node * root ) { if ( root == NULL ) return ; if ( root -> right ) { printBoundaryRight ( root -> right ) ; printf ( " % d ▁ " , root -> data ) ; } else if ( root -> left ) { printBoundaryRight ( root -> left ) ; printf ( " % d ▁ " , root -> data ) ; } } void printBoundary ( struct node * root ) { if ( root == NULL ) return ; printf ( " % d ▁ " , root -> data ) ; printBoundaryLeft ( root -> left ) ; printLeaves ( root -> left ) ; printLeaves ( root -> right ) ; printBoundaryRight ( root -> right ) ; } struct node * newNode ( int data ) { struct node * temp = ( struct node * ) malloc ( sizeof ( struct node ) ) ; temp -> data = data ; temp -> left = temp -> right = NULL ; return temp ; } int main ( ) { struct node * root = newNode ( 20 ) ; root -> left = newNode ( 8 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 12 ) ; root -> left -> right -> left = newNode ( 10 ) ; root -> left -> right -> right = newNode ( 14 ) ; root -> right = newNode ( 22 ) ; root -> right -> right = newNode ( 25 ) ; printBoundary ( root ) ; return 0 ; }

Class/struct names: node
C++ program:
#include <stdio.h>
#include <stdlib.h>
struct Node { int data ; struct Node * next ; } ; void printReverse ( struct Node * * head_ref , int n ) { int j = 0 ; struct Node * current = * head_ref ; while ( current != NULL ) { for ( int i = 0 ; i < 2 * ( n - j ) ; i ++ ) printf ( " ▁ " ) ; printf ( " % d \r " , current -> data ) ; current = current -> next ; j ++ ; } } 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 printList ( struct Node * head ) { int i = 0 ; struct Node * temp = head ; while ( temp != NULL ) { printf ( " % d ▁ " , temp -> data ) ; temp = temp -> next ; i ++ ; } return i ; } int main ( ) { struct Node * head = NULL ; push ( & head , 1 ) ; push ( & head , 2 ) ; push ( & head , 3 ) ; push ( & head , 4 ) ; push ( & head , 5 ) ; push ( & head , 6 ) ; printf ( " Given ▁ linked ▁ list : STRNEWLINE " ) ; int n = printList ( head ) ; printf ( " Reversed Linked list : " printReverse ( & head , n ) ; printf ( " STRNEWLINE " ) ; return 0 ; }

Accumulator variables: i, j
Iterator variables: i
Class/struct names: Node
C++ program:
struct Node { int data ; struct Node * next ; } ;

Class/struct names: Node
C++ program:
void fun1 ( struct Node * head ) { if ( head == NULL ) return ; fun1 ( head -> next ) ; cout << head -> data << " ▁ " ; }

Class/struct names: Node
C++ program:
void fun2 ( struct Node * head ) { if ( head == NULL ) return ; cout << head -> data << " ▁ " ; if ( head -> next != NULL ) fun2 ( head -> next -> next ) ; cout << head -> data << " ▁ " ; }

Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; class Node { public : int data ; Node * next ; } ; void fun1 ( Node * head ) { if ( head == NULL ) return ; fun1 ( head -> next ) ; cout << head -> data << " ▁ " ; } void fun2 ( Node * start ) { if ( start == NULL ) return ; cout << start -> data << " ▁ " ; if ( start -> next != NULL ) fun2 ( start -> next -> next ) ; cout << start -> data << " ▁ " ; } 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 main ( ) { Node * head = NULL ; push ( & head , 5 ) ; push ( & head , 4 ) ; push ( & head , 3 ) ; push ( & head , 2 ) ; push ( & head , 1 ) ; cout << " Output ▁ of ▁ fun1 ( ) ▁ for ▁ list ▁ 1 - > 2 - > 3 - > 4 - > 5 ▁ STRNEWLINE " ; fun1 ( head ) ; cout << " Output of fun2 ( ) for list 1 -> 2 -> 3 -> 4 -> 5 " ; fun2 ( head ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
struct Node { int data ; Node * left , * right ; } ; Node * newNode ( int data ) { Node * node = new Node ; node -> data = data ; node -> left = node -> right = NULL ; return node ; } int heighAndSize ( Node * node , int & size ) { if ( node == NULL ) return 0 ; int l = heighAndSize ( node -> left , size ) ; int r = heighAndSize ( node -> right , size ) ; size ++ ; return ( l > r ) ? l + 1 : r + 1 ; } float density ( Node * root ) { if ( root == NULL ) return 0 ; int size = 0 ; int _height = heighAndSize ( root , size ) ; return ( float ) size / _height ; } int main ( ) { Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; printf ( " Density ▁ of ▁ given ▁ binary ▁ tree ▁ is ▁ % f " , density ( root ) ) ; return 0 ; }

Accumulator variables: size, stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; class Node { public : int data ; Node * next ; } ; int printsqrtn ( Node * head ) { Node * sqrtn = NULL ; int i = 1 , j = 1 ; while ( head != NULL ) { if ( i == j * j ) { if ( sqrtn == NULL ) sqrtn = head ; else sqrtn = sqrtn -> next ; j ++ ; } i ++ ; head = head -> next ; } return sqrtn -> data ; } void print ( Node * head ) { while ( head != NULL ) { cout << head -> data << " ▁ " ; head = head -> next ; } cout << endl ; } 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 main ( ) { Node * head = NULL ; push ( & head , 40 ) ; push ( & head , 30 ) ; push ( & head , 20 ) ; push ( & head , 10 ) ; cout << " Given ▁ linked ▁ list ▁ is : " ; print ( head ) ; cout << " sqrt ( n ) th ▁ node ▁ is ▁ " << printsqrtn ( head ) ; return 0 ; }

Accumulator variables: i, j, stdc
Class/struct names: Node