dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; public class Node { public int data ; public Node next ; public Node ( int d ) { data = d ; next = null ; } } public class LinkedListIntersect { public static void Main ( String [ ] args ) { Node n1 = new Node ( 1 ) ; n1 . next = new Node ( 2 ) ; n1 . next . next = new Node ( 3 ) ; n1 . next . next . next = new Node ( 4 ) ; n1 . next . next . next . next = new Node ( 5 ) ; n1 . next . next . next . next . next = new Node ( 6 ) ; n1 . next . next . next . next . next . next = new Node ( 7 ) ; Node n2 = new Node ( 10 ) ; n2 . next = new Node ( 9 ) ; n2 . next . next = new Node ( 8 ) ; n2 . next . next . next = n1 . next . next . next ; Print ( n1 ) ; Print ( n2 ) ; Console . WriteLine ( MegeNode ( n1 , n2 ) . data ) ; } public static void Print ( Node n ) { Node cur = n ; while ( cur != null ) { Console . Write ( cur . data + " ▁ " ) ; cur = cur . next ; } Console . WriteLine ( ) ; } public static Node MegeNode ( Node n1 , Node n2 ) { HashSet < Node > hs = new HashSet < Node > ( ) ; while ( n1 != null ) { hs . Add ( n1 ) ; n1 = n1 . next ; } while ( n2 != null ) { if ( hs . Contains ( n2 ) ) { return n2 ; } n2 = n2 . next ; } return null ; } }

Class/struct names: LinkedListIntersect, Node
C# program:
using System ; class GFG { class Node { public int data ; public Node left , right ; public bool visited ; } static void postorder ( Node head ) { Node temp = head ; while ( temp != null && temp . visited == false ) { if ( temp . left != null && temp . left . visited == false ) temp = temp . left ; else if ( temp . right != null && temp . right . visited == false ) temp = temp . right ; else { Console . Write ( " { 0 } ▁ " , temp . data ) ; temp . visited = true ; temp = head ; } } } static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = null ; node . right = null ; node . visited = false ; return ( node ) ; } public static void Main ( String [ ] args ) { 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 ) ; } }

Boolean variables: visited
Class/struct names: GFG, Node
C# program:
using System ; public class GFG { public class Node { public int data ; public Node next ; } static bool isCircular ( Node head ) { if ( head == null ) return true ; Node node = head . next ; while ( node != null && node != head ) node = node . next ; return ( node == head ) ; } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . next = null ; return temp ; } public static void Main ( String [ ] args ) { Node head = newNode ( 1 ) ; head . next = newNode ( 2 ) ; head . next . next = newNode ( 3 ) ; head . next . next . next = newNode ( 4 ) ; Console . Write ( isCircular ( head ) ? " Yes STRNEWLINE " : " No STRNEWLINE " ) ; head . next . next . next . next = head ; Console . Write ( isCircular ( head ) ? " Yes STRNEWLINE " : " No STRNEWLINE " ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; public class GFG { class Node { public int data ; public Node next ; public Node ( int data ) { this . data = data ; } } static void getJosephusPosition ( int m , int n ) { Node head = new Node ( 1 ) ; Node prev = head ; for ( int i = 2 ; i <= n ; i ++ ) { prev . next = new Node ( i ) ; prev = prev . next ; } prev . next = head ; Node ptr1 = head , ptr2 = head ; while ( ptr1 . next != ptr1 ) { int count = 1 ; while ( count != m ) { ptr2 = ptr1 ; ptr1 = ptr1 . next ; count ++ ; } ptr2 . next = ptr1 . next ; ptr1 = ptr2 . next ; } Console . WriteLine ( " Last ▁ person ▁ left ▁ standing ▁ " + " ( Josephus ▁ Position ) ▁ is ▁ " + ptr1 . data ) ; } static public void Main ( String [ ] args ) { int n = 14 , m = 2 ; getJosephusPosition ( m , n ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; class Array_imp { static int root = 0 ; static String [ ] str = new String [ 10 ] ; public void Root ( String key ) { str [ 0 ] = key ; } public void set_Left ( String key , int root ) { int t = ( root * 2 ) + 1 ; if ( str [ root ] == null ) { Console . Write ( " Can ' t ▁ set ▁ child ▁ at ▁ { 0 } , ▁ no ▁ parent ▁ found STRNEWLINE " , t ) ; } else { str [ t ] = key ; } } public void set_Right ( String key , int root ) { int t = ( root * 2 ) + 2 ; if ( str [ root ] == null ) { Console . Write ( " Can ' t ▁ set ▁ child ▁ at ▁ { 0 } , ▁ no ▁ parent ▁ found STRNEWLINE " , t ) ; } else { str [ t ] = key ; } } public void print_Tree ( ) { for ( int i = 0 ; i < 10 ; i ++ ) { if ( str [ i ] != null ) Console . Write ( str [ i ] ) ; else Console . Write ( " - " ) ; } } } public class Tree { public static void Main ( String [ ] args ) { Array_imp obj = new Array_imp ( ) ; obj . Root ( " A " ) ; obj . set_Right ( " C " , 0 ) ; obj . set_Left ( " D " , 1 ) ; obj . set_Right ( " E " , 1 ) ; obj . set_Left ( " F " , 2 ) ; obj . print_Tree ( ) ; } }

Index/key variables: i, root, t
Accumulator variables: i
Iterator variables: i
Class/struct names: Array_imp, Tree
C# program:
using System ; public class Node { public int data ; public Node next ; public Node ( int d ) { data = d ; next = null ; } } public class LinkedList { Node head ; void push ( int new_data ) { Node new_node = new Node ( new_data ) ; new_node . next = head ; head = new_node ; } void printList ( ) { Node node = head ; while ( node != null ) { Console . Write ( node . data + " ▁ " ) ; node = node . next ; } Console . WriteLine ( " " ) ; } int countNodes ( ) { int count = 0 ; Node s = head ; while ( s != null ) { count ++ ; s = s . next ; } return count ; } void swapKth ( int k ) { int n = countNodes ( ) ; if ( n < k ) return ; if ( 2 * k - 1 == n ) return ; Node x = head ; Node x_prev = null ; for ( int i = 1 ; i < k ; i ++ ) { x_prev = x ; x = x . next ; } Node y = head ; Node y_prev = null ; for ( int i = 1 ; i < n - k + 1 ; i ++ ) { y_prev = y ; y = y . next ; } if ( x_prev != null ) x_prev . next = y ; if ( y_prev != null ) y_prev . next = x ; Node temp = x . next ; x . next = y . next ; y . next = temp ; if ( k == 1 ) head = y ; if ( k == n ) head = x ; } public static void Main ( String [ ] args ) { LinkedList llist = new LinkedList ( ) ; for ( int i = 8 ; i >= 1 ; i -- ) llist . push ( i ) ; Console . Write ( " Original ▁ linked ▁ list : ▁ " ) ; llist . printList ( ) ; Console . WriteLine ( " " ) ; for ( int i = 1 ; i < 9 ; i ++ ) { llist . swapKth ( i ) ; Console . WriteLine ( " Modified ▁ List ▁ for ▁ k ▁ = ▁ " + i ) ; llist . printList ( ) ; Console . WriteLine ( " " ) ; } } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: LinkedList, Node
C# program:
using System ; class GFG { class Node { public int data ; public Node next , prev ; } ; static void pairSum ( Node head , int x ) { Node first = head ; 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 ; Console . WriteLine ( " ( " + first . data + " , ▁ " + second . data + " ) " ) ; first = first . next ; second = second . prev ; } else { if ( ( first . data + second . data ) < x ) first = first . next ; else second = second . prev ; } } if ( found == false ) Console . WriteLine ( " No ▁ pair ▁ found " ) ; } static Node insert ( Node head , int data ) { 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 ; } return temp ; } public static void Main ( String [ ] args ) { Node head = null ; head = insert ( head , 9 ) ; head = insert ( head , 8 ) ; head = insert ( head , 6 ) ; head = insert ( head , 5 ) ; head = insert ( head , 4 ) ; head = insert ( head , 2 ) ; head = insert ( head , 1 ) ; int x = 7 ; pairSum ( head , x ) ; } }

Boolean variables: found
Class/struct names: GFG, Node
C# program:
using System ; using System . Collections ; class GFG { public class Node { public int data ; public Node left , right ; } ; static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = node . right = null ; return ( node ) ; } static void diagonalPrint ( Node root ) { if ( root == null ) return ; Queue q = new Queue ( ) ; q . Enqueue ( root ) ; q . Enqueue ( null ) ; while ( q . Count > 0 ) { Node temp = ( Node ) q . Peek ( ) ; q . Dequeue ( ) ; if ( temp == null ) { if ( q . Count == 0 ) return ; Console . WriteLine ( ) ; q . Enqueue ( null ) ; } else { while ( temp != null ) { Console . Write ( temp . data + " ▁ " ) ; if ( temp . left != null ) q . Enqueue ( temp . left ) ; temp = temp . right ; } } } } public static void Main ( String [ ] args ) { 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 ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; class GFG { class Node { public int data ; public Node next , prev ; } ; static int countPairs ( Node first , 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 ; } static int countTriplets ( Node head , int x ) { if ( head == null ) return 0 ; 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 ; } static Node insert ( Node head , int data ) { 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 ; } return head ; } public static void Main ( String [ ] args ) { Node head = null ; head = insert ( head , 9 ) ; head = insert ( head , 8 ) ; head = insert ( head , 6 ) ; head = insert ( head , 5 ) ; head = insert ( head , 4 ) ; head = insert ( head , 2 ) ; head = insert ( head , 1 ) ; int x = 17 ; Console . Write ( " Count ▁ = ▁ " + countTriplets ( head , x ) ) ; } }

Accumulator variables: count
Iterator variables: current
Class/struct names: GFG, Node
C# program:
using System ; class GFG { public class Node { public int data ; public Node next ; public Node prev ; } static Node deleteNode ( Node head_ref , Node del ) { if ( head_ref == null del == null ) return head_ref ; 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 ; return head_ref ; } static Node removeDuplicates ( Node head_ref ) { if ( ( head_ref ) == null || ( head_ref ) . next == null ) return head_ref ; ; Node ptr1 , ptr2 ; for ( ptr1 = head_ref ; ptr1 != null ; ptr1 = ptr1 . next ) { ptr2 = ptr1 . next ; while ( ptr2 != null ) { if ( ptr1 . data == ptr2 . data ) { Node next = ptr2 . next ; head_ref = deleteNode ( head_ref , ptr2 ) ; ptr2 = next ; } else ptr2 = ptr2 . next ; } } return head_ref ; } static Node push ( Node head_ref , int new_data ) { Node new_node = new 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 ; return head_ref ; } static void printList ( Node head ) { if ( head == null ) Console . Write ( " Doubly ▁ Linked ▁ list ▁ empty " ) ; while ( head != null ) { Console . Write ( head . data + " ▁ " ) ; head = head . next ; } } public static void Main ( String [ ] args ) { Node head = null ; head = push ( head , 12 ) ; head = push ( head , 12 ) ; head = push ( head , 10 ) ; head = push ( head , 4 ) ; head = push ( head , 8 ) ; head = push ( head , 4 ) ; head = push ( head , 6 ) ; head = push ( head , 4 ) ; head = push ( head , 4 ) ; head = push ( head , 8 ) ; Console . Write ( " Original ▁ Doubly ▁ linked ▁ list : STRNEWLINE " ) ; printList ( head ) ; head = removeDuplicates ( head ) ; Console . Write ( " STRNEWLINE Doubly ▁ linked ▁ list ▁ after " + " ▁ removing ▁ duplicates : STRNEWLINE " ) ; printList ( head ) ; } }

Iterator variables: ptr1
Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { public class Node { public int data ; public Node next ; public Node prev ; } ; static Node deleteNode ( Node head_ref , Node del ) { if ( head_ref == null del == null ) return null ; 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 ; return head_ref ; } static Node removeDuplicates ( Node head_ref ) { if ( ( head_ref ) == null ) return null ; HashSet < int > us = new HashSet < int > ( ) ; Node current = head_ref , next ; while ( current != null ) { if ( us . Contains ( current . data ) ) { next = current . next ; head_ref = deleteNode ( head_ref , current ) ; current = next ; } else { us . Add ( current . data ) ; current = current . next ; } } return head_ref ; } static Node push ( Node head_ref , int new_data ) { Node new_node = new 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 ; return head_ref ; } static void printList ( Node head ) { if ( head == null ) Console . Write ( " Doubly ▁ Linked ▁ list ▁ empty " ) ; while ( head != null ) { Console . Write ( head . data + " ▁ " ) ; head = head . next ; } } public static void Main ( String [ ] args ) { Node head = null ; head = push ( head , 12 ) ; head = push ( head , 12 ) ; head = push ( head , 10 ) ; head = push ( head , 4 ) ; head = push ( head , 8 ) ; head = push ( head , 4 ) ; head = push ( head , 6 ) ; head = push ( head , 4 ) ; head = push ( head , 4 ) ; head = push ( head , 8 ) ; Console . WriteLine ( " Original ▁ Doubly ▁ linked ▁ list : " ) ; printList ( head ) ; head = removeDuplicates ( head ) ; Console . WriteLine ( " STRNEWLINE Doubly ▁ linked ▁ list ▁ after ▁ " + " removing ▁ duplicates : " ) ; printList ( head ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; public class Node { public int info ; public Node prev , next ; } class GFG { static Node head , tail ; static void nodeInsetail ( 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 ; } static void printList ( Node temp ) { while ( temp != null ) { Console . Write ( temp . info + " ▁ " ) ; temp = temp . next ; } } public static void Main ( String [ ] args ) { head = tail = null ; nodeInsetail ( 30 ) ; nodeInsetail ( 50 ) ; nodeInsetail ( 90 ) ; nodeInsetail ( 10 ) ; nodeInsetail ( 40 ) ; nodeInsetail ( 110 ) ; nodeInsetail ( 60 ) ; nodeInsetail ( 95 ) ; nodeInsetail ( 23 ) ; Console . WriteLine ( " Doubly ▁ linked ▁ list ▁ on ▁ printing ▁ from ▁ left ▁ to ▁ right " ) ; printList ( head ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static Node start ; public class Node { public int data ; public Node next ; public Node prev ; } ; static void insertEnd ( int value ) { Node new_node ; if ( start == null ) { new_node = new Node ( ) ; new_node . data = value ; new_node . next = new_node . prev = new_node ; start = new_node ; return ; } Node last = ( start ) . prev ; new_node = new Node ( ) ; new_node . data = value ; new_node . next = start ; ( start ) . prev = new_node ; new_node . prev = last ; last . next = new_node ; } static void insertBegin ( int value ) { Node last = ( start ) . prev ; 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 ; } static void insertAfter ( int value1 , int value2 ) { Node new_node = new Node ( ) ; new_node . data = value1 ; Node temp = start ; while ( temp . data != value2 ) temp = temp . next ; Node next = temp . next ; temp . next = new_node ; new_node . prev = temp ; new_node . next = next ; next . prev = new_node ; } static void display ( ) { Node temp = start ; Console . Write ( " in forward direction " while ( temp . next != start ) { Console . Write ( " { 0 } ▁ " , temp . data ) ; = temp . next ; } Console . Write ( " { 0 } ▁ " , temp . data ) ; Console . Write ( " in reverse direction " Node last = start . prev ; temp = last ; while ( temp . prev != last ) { Console . Write ( " { 0 } ▁ " , temp . data ) ; temp = temp . prev ; } Console . Write ( " { 0 } ▁ " , temp . data ) ; } public static void Main ( String [ ] args ) { Node start = null ; insertEnd ( 5 ) ; insertBegin ( 4 ) ; insertEnd ( 7 ) ; insertEnd ( 8 ) ; insertAfter ( 6 , 5 ) ; Console . Write ( " Created ▁ circular ▁ doubly ▁ linked ▁ list ▁ is : ▁ " ) ; display ( ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } class GFG { public Node root ; public virtual void printLeaves ( Node node ) { if ( node == null ) return ; printLeaves ( node . left ) ; if ( node . left == null && node . right == null ) { Console . Write ( node . data + " ▁ " ) ; } printLeaves ( node . right ) ; } public virtual void printBoundaryLeft ( Node node ) { if ( node == null ) return ; if ( node . left != null ) { Console . Write ( node . data + " ▁ " ) ; printBoundaryLeft ( node . left ) ; } else if ( node . right != null ) { Console . Write ( node . data + " ▁ " ) ; printBoundaryLeft ( node . right ) ; } } public virtual void printBoundaryRight ( Node node ) { if ( node == null ) return ; if ( node . right != null ) { printBoundaryRight ( node . right ) ; Console . Write ( node . data + " ▁ " ) ; } else if ( node . left != null ) { printBoundaryRight ( node . left ) ; Console . Write ( node . data + " ▁ " ) ; } } public virtual void printBoundary ( Node node ) { if ( node == null ) return ; Console . Write ( node . data + " ▁ " ) ; printBoundaryLeft ( node . left ) ; printLeaves ( node . left ) ; printLeaves ( node . right ) ; printBoundaryRight ( node . right ) ; } public static void Main ( string [ ] args ) { GFG tree = new GFG ( ) ; tree . root = new Node ( 20 ) ; tree . root . left = new Node ( 8 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 12 ) ; tree . root . left . right . left = new Node ( 10 ) ; tree . root . left . right . right = new Node ( 14 ) ; tree . root . right = new Node ( 22 ) ; tree . root . right . right = new Node ( 25 ) ; tree . printBoundary ( tree . root ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; public class Node { public int data ; public Node next ; public Node ( int val ) { data = val ; next = null ; } } public class GFG { static void printReverse ( Node head , int n ) { int j = 0 ; Node current = head ; while ( current != null ) { for ( int i = 0 ; i < 2 * ( n - j ) ; i ++ ) Console . Write ( " ▁ " ) ; Console . Write ( " \r " + current . data ) ; current = current . next ; j ++ ; } } static Node push ( Node head , int data ) { Node new_node = new Node ( data ) ; new_node . next = head ; head = new_node ; return head ; } static int printList ( Node head ) { int i = 0 ; Node temp = head ; while ( temp != null ) { Console . Write ( temp . data + " ▁ " ) ; temp = temp . next ; i ++ ; } return i ; } public static void Main ( String [ ] args ) { Node head = null ; head = push ( head , 1 ) ; head = push ( head , 2 ) ; head = push ( head , 3 ) ; head = push ( head , 4 ) ; head = push ( head , 5 ) ; head = push ( head , 6 ) ; Console . WriteLine ( " Given ▁ linked ▁ list : ▁ " ) ; int n = printList ( head ) ; Console . WriteLine ( " Reversed ▁ Linked ▁ list : ▁ " ) ; printReverse ( head , n ) ; Console . WriteLine ( ) ; } }

Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG, Node
C# program:
public class Node { public int data ; public Node next ; } ;

Class/struct names: Node
C# program:
using System ; class GFG { public class Node { public int data ; public Node next ; } ; static void fun1 ( Node head ) { if ( head == null ) { return ; } fun1 ( head . next ) ; Console . Write ( head . data + " ▁ " ) ; } static void fun2 ( Node start ) { if ( start == null ) { return ; } Console . Write ( start . data + " ▁ " ) ; if ( start . next != null ) { fun2 ( start . next . next ) ; } Console . Write ( start . data + " ▁ " ) ; } static Node 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 ; return head_ref ; } public static void Main ( String [ ] args ) { Node head = null ; head = Push ( head , 5 ) ; head = Push ( head , 4 ) ; head = Push ( head , 3 ) ; head = Push ( head , 2 ) ; head = Push ( head , 1 ) ; Console . Write ( " Output ▁ of ▁ fun1 ( ) ▁ for ▁ " + " list ▁ 1 - > 2 - > 3 - > 4 - > 5 ▁ STRNEWLINE " ) ; fun1 ( head ) ; Console . Write ( " fun2 ( ) for " ▁ + ▁ " 1 -> 2 -> 3 -> 4 -> 5 " ) ; fun2 ( head ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; left = right = null ; } } class Size { public int size = 0 ; } class BinaryTree { Node root ; int heighAndSize ( Node node , Size size ) { if ( node == null ) return 0 ; int l = heighAndSize ( node . left , size ) ; int r = heighAndSize ( node . right , size ) ; size . size ++ ; return ( l > r ) ? l + 1 : r + 1 ; } float density ( Node root ) { Size size = new Size ( ) ; if ( root == null ) return 0 ; int _height = heighAndSize ( root , size ) ; return ( float ) size . size / _height ; } static public void Main ( String [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; Console . WriteLine ( " Density ▁ of ▁ given ▁ " + " Binary ▁ Tree ▁ is ▁ : ▁ " + tree . density ( tree . root ) ) ; } }

Accumulator variables: size
Class/struct names: BinaryTree, Node, Size
C# program:
using System ; public class GfG { class Node { public int data ; public Node next ; } static Node head = null ; static 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 ; } static void print ( Node head ) { while ( head != null ) { Console . Write ( head . data + " ▁ " ) ; head = head . next ; } Console . WriteLine ( ) ; } static void push ( int new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = head ; head = new_node ; } public static void Main ( String [ ] args ) { push ( 40 ) ; push ( 30 ) ; push ( 20 ) ; push ( 10 ) ; Console . Write ( " Given ▁ linked ▁ list ▁ is : " ) ; print ( head ) ; Console . Write ( " sqrt ( n ) th ▁ node ▁ is ▁ " + printsqrtn ( head ) ) ; } }

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