dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static int convert ( List < int > p ) { int ans = 0 ; foreach ( int i in p ) { ans = ( ans << 1 ) | i ; } return ans ; } static int count ( int num ) { int ans = 0 ; while ( num > 0 ) { ans += num & 1 ; num >>= 1 ; } return ans ; } static void checkGoodMatrix ( int [ , ] mat ) { List < int > P = new List < int > ( ) ; List < int > S = new List < int > ( ) ; List < int > MR = new List < int > ( ) ; List < int > MC = new List < int > ( ) ; for ( int i = 0 ; i < mat . GetLength ( 0 ) ; i ++ ) { for ( int j = 0 ; j < mat . GetLength ( 1 ) ; j ++ ) { if ( i == j ) P . Add ( mat [ i , j ] ) ; if ( i + j == mat . GetLength ( 0 ) - 1 ) S . Add ( mat [ i , j ] ) ; if ( i == Math . Floor ( ( mat . GetLength ( 0 ) - 1 ) / 2.0 ) ) MR . Add ( mat [ i , j ] ) ; if ( j == Math . Floor ( ( mat . GetLength ( 0 ) - 1 ) / 2.0 ) ) MC . Add ( mat [ i , j ] ) ; } } S . Reverse ( ) ; int P0 = convert ( P ) ; int S0 = convert ( S ) ; int MR0 = convert ( MR ) ; int MC0 = convert ( MC ) ; int setBitsPS = count ( ( P0 & S0 ) ) ; int setBitsMM = count ( ( MR0 & MC0 ) ) ; if ( setBitsPS > setBitsMM ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } public static void Main ( string [ ] args ) { int [ , ] mat = { { 1 , 0 , 1 } , { 0 , 0 , 1 } , { 0 , 1 , 1 } } ; checkGoodMatrix ( mat ) ; } }

Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; public class GFG { static void assignValues ( int [ , ] Edges , int n ) { LinkedList < int > [ ] tree = new LinkedList < int > [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) tree [ i ] = new LinkedList < int > ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int u = Edges [ i , 0 ] ; int v = Edges [ i , 1 ] ; tree [ u ] . AddLast ( v ) ; tree [ v ] . AddLast ( u ) ; } bool [ ] visited = new bool [ n + 1 ] ; int [ ] answer = new int [ n + 1 ] ; int K = 1 ; Queue q = new Queue ( ) ; q . Enqueue ( 1 ) ; answer [ 1 ] = K ; while ( q . Count > 0 ) { int node = ( int ) q . Peek ( ) ; q . Dequeue ( ) ; visited [ node ] = true ; K = ( ( answer [ node ] == 1 ) ? 2 : 1 ) ; foreach ( var child in tree [ node ] ) { if ( ! visited [ child ] ) { q . Enqueue ( child ) ; answer [ child ] = K ; } } } for ( int i = 1 ; i <= n ; i ++ ) { Console . Write ( answer [ i ] + " ▁ " ) ; } } static public void Main ( ) { int N = 11 ; int [ , ] Edges = { { 1 , 2 } , { 1 , 3 } , { 1 , 4 } , { 1 , 5 } , { 2 , 6 } , { 2 , 10 } , { 10 , 11 } , { 3 , 7 } , { 4 , 8 } , { 5 , 9 } } ; assignValues ( Edges , N ) ; } }

Index/key variables: child, i, node, u, v
Accumulator variables: i
Iterator variables: child, i
Class/struct names: GFG
C# program:
using System ; class GFG { static int numoffbt ( int [ ] arr , int n ) { int maxvalue = - 2147483647 , minvalue = 2147483647 ; for ( int i = 0 ; i < n ; i ++ ) { maxvalue = Math . Max ( maxvalue , arr [ i ] ) ; minvalue = Math . Min ( minvalue , arr [ i ] ) ; } int [ ] mark = new int [ maxvalue + 2 ] ; int [ ] value = new int [ maxvalue + 2 ] ; for ( int i = 0 ; i < maxvalue + 2 ; i ++ ) { mark [ i ] = 0 ; value [ i ] = 0 ; } for ( int i = 0 ; i < n ; i ++ ) { mark [ arr [ i ] ] = 1 ; value [ arr [ i ] ] = 1 ; } int ans = 0 ; for ( int i = minvalue ; i <= maxvalue ; i ++ ) { if ( mark [ i ] != 0 ) { for ( int j = i + i ; j <= maxvalue && j / i <= i ; j += i ) { if ( mark [ j ] == 0 ) continue ; value [ j ] = value [ j ] + ( value [ i ] * value [ j / i ] ) ; if ( i != j / i ) value [ j ] = value [ j ] + ( value [ i ] * value [ j / i ] ) ; } } ans += value [ i ] ; } return ans ; } public static void Main ( ) { int [ ] arr = { 2 , 3 , 4 , 6 } ; int n = arr . Length ; Console . Write ( numoffbt ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int limit = 100000 ; static bool [ ] prime ; static void sieve ( ) { prime = new bool [ limit + 1 ] ; Array . Fill ( prime , true ) ; for ( int p = 2 ; p * p <= limit ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= limit ; i += p ) prime [ i ] = false ; } } } static int findOperations ( int [ ] arr , int n ) { sieve ( ) ; int minm = Int32 . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { minm = Math . Min ( minm , arr [ i ] ) ; } int val = minm ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == minm + 1 ) { val = minm - 2 ; break ; } } int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int D = arr [ i ] - val ; if ( D == 0 ) { continue ; } else if ( prime [ D ] == true ) { cnt += 1 ; } else if ( D % 2 == 0 ) { cnt += 2 ; } else { if ( prime [ D - 2 ] == true ) { cnt += 2 ; } else { cnt += 3 ; } } } return cnt ; } public static void Main ( string [ ] args ) { int [ ] arr = { 7 , 10 , 4 , 5 } ; int N = 4 ; Console . WriteLine ( findOperations ( arr , N ) ) ; } }

Index/key variables: D, i, p
Accumulator variables: cnt, i, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int calcScore ( List < int > p , int [ ] arr ) { int ans = 0 ; for ( int i = 0 ; i < arr . Length ; i ++ ) { ans += ( p [ i ] & arr [ i ] ) ; } return ans ; } static int getMaxUtil ( List < int > p , int [ ] arr , int ans , bool [ ] chosen , int N ) { if ( p . Count == N ) { ans = Math . Max ( ans , calcScore ( p , arr ) ) ; return ans ; } for ( int i = 0 ; i < N ; i ++ ) { if ( chosen [ i ] ) { continue ; } chosen [ i ] = true ; p . Add ( i ) ; ans = getMaxUtil ( p , arr , ans , chosen , N ) ; chosen [ i ] = false ; p . Remove ( p . Count - 1 ) ; } return ans ; } static void getMax ( int [ ] arr , int N ) { int ans = 0 ; bool [ ] chosen = new bool [ N ] ; List < int > p = new List < int > ( ) ; int res = getMaxUtil ( p , arr , ans , chosen , N ) ; Console . Write ( res ) ; } public static void Main ( ) { int [ ] arr = { 4 , 2 , 3 , 6 } ; int N = arr . Length ; getMax ( arr , N ) ; } }

Index/key variables: N, i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class solution { static int setBitCount ( int n ) { int ans = 0 ; while ( n > 0 ) { ans += n & 1 ; n >>= 1 ; } return ans ; } static void getSum ( int [ ] arr , int n ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int key = setBitCount ( arr [ i ] ) ; if ( mp . ContainsKey ( key ) ) mp [ key ] += 1 ; else mp [ key ] = 1 ; } for ( int i = 0 ; i < n ; i ++ ) { int key = setBitCount ( arr [ i ] ) ; if ( mp [ key ] == 1 ) ans += arr [ i ] ; } Console . Write ( ans ) ; } public static void Main ( ) { int [ ] arr = { 8 , 3 , 7 , 5 , 3 } ; int n = arr . Length ; getSum ( arr , n ) ; } }

Index/key variables: i, key
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: solution
C# program:
using System ; public class GFG { static void findSplit ( int [ ] arr , int N ) { int [ ] sum = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { sum [ i ] = arr [ i ] ; } for ( int i = 1 ; i < N ; i ++ ) { sum [ i ] += sum [ i - 1 ] ; } for ( int l = 1 ; l <= N - 4 ; l ++ ) { for ( int r = l + 2 ; r <= N - 2 ; r ++ ) { int lsum = 0 , rsum = 0 , msum = 0 ; lsum = sum [ l - 1 ] ; msum = sum [ r - 1 ] - sum [ l ] ; rsum = sum [ N - 1 ] - sum [ r ] ; if ( lsum == rsum && rsum == msum ) { Console . Write ( l + " ▁ " + r + " STRNEWLINE " ) ; return ; } } } Console . Write ( - 1 + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 5 , 12 , 7 , 19 , 4 , 3 } ; int N = arr . Length ; findSplit ( arr , N ) ; } }

Index/key variables: N, i, l, r
Accumulator variables: i, l, r
Iterator variables: i, l, r
Class/struct names: GFG
C# program:
using System ; class GFG { static void findSplit ( int [ ] arr , int N ) { int l = 1 , r = N - 2 ; int lsum , msum , rsum ; int [ ] sum = new int [ N ] ; sum [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { sum [ i ] = sum [ i - 1 ] + arr [ i ] ; } while ( l < r ) { lsum = sum [ l - 1 ] ; msum = sum [ r - 1 ] - sum [ l ] ; rsum = sum [ N - 1 ] - sum [ r ] ; if ( lsum == msum && msum == rsum ) { Console . Write ( l + " ▁ " + r ) ; return ; } if ( lsum < rsum ) l ++ ; else if ( lsum > rsum ) r -- ; else { l ++ ; r -- ; } } Console . Write ( - 1 ) ; } static void Main ( ) { int [ ] arr = { 2 , 5 , 12 , 7 , 19 , 4 , 3 } ; int N = arr . Length ; findSplit ( arr , N ) ; } }

Index/key variables: N, i, l, r
Accumulator variables: i, l, r
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; 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 = null ; node . right = null ; return ( node ) ; } public class P { public int pcount = 0 ; } static int countRec ( Node root , P p ) { if ( root == null ) return 0 ; int c = countRec ( root . left , p ) ; c += countRec ( root . right , p ) ; if ( root . data % 2 == 0 ) c += 1 ; if ( c % 2 != 0 ) ( p . pcount ) ++ ; return c ; } static int countSubtrees ( Node root ) { P p = new P ( ) ; countRec ( root , p ) ; return p . pcount ; } public static void Main ( String [ ] args ) { Node root = newNode ( 2 ) ; root . left = newNode ( 1 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 10 ) ; root . right . left = newNode ( 8 ) ; root . right . right = newNode ( 5 ) ; root . left . right . left = newNode ( 6 ) ; Console . WriteLine ( " Count ▁ = ▁ " + countSubtrees ( root ) ) ; } }

Accumulator variables: c
Class/struct names: GFG, Node, P
C# program:
using System ; class GFG { public class Node { public int data ; public Node left , right ; } public static Node temp = new Node ( ) ; public static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = temp . right = null ; return temp ; } public static Node leftMostNode ( Node node ) { while ( node != null && node . left != null ) { node = node . left ; } return node ; } public static Node rightMostNode ( Node node ) { while ( node != null && node . right != null ) { node = node . right ; } return node ; } public static Node findInorderRecursive ( Node root , Node x ) { if ( root == null ) { return null ; } if ( root == x || ( temp = findInorderRecursive ( root . left , x ) ) != null || ( temp = findInorderRecursive ( root . right , x ) ) != null ) { if ( temp != null ) { if ( root . left == temp ) { Console . Write ( " Inorder ▁ Successor ▁ of ▁ " + x . data ) ; Console . Write ( " ▁ is ▁ " + root . data + " STRNEWLINE " ) ; return null ; } } return root ; } return null ; } public static void inorderSuccesor ( Node root , Node x ) { if ( x . right != null ) { Node inorderSucc = leftMostNode ( x . right ) ; Console . Write ( " Inorder ▁ Successor ▁ of ▁ " + x . data + " ▁ is ▁ " ) ; Console . Write ( inorderSucc . data + " STRNEWLINE " ) ; } if ( x . right == null ) { int f = 0 ; Node rightMost = rightMostNode ( root ) ; if ( rightMost == x ) { Console . Write ( " No ▁ inorder ▁ successor ! ▁ " + " Right ▁ most ▁ node . STRNEWLINE " ) ; } else { findInorderRecursive ( root , x ) ; } } } public static void Main ( string [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 5 ) ; root . right . right = newNode ( 6 ) ; inorderSuccesor ( root , root . right ) ; inorderSuccesor ( root , root . left . left ) ; inorderSuccesor ( root , root . right . right ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; public class Node { public int key ; public Node left , right ; public Node ( int item ) { key = item ; left = right = null ; } } public class BinaryTree { Node root ; BinaryTree ( int key ) { root = new Node ( key ) ; } BinaryTree ( ) { root = null ; } public static 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 ) ; tree . root . left . left = new Node ( 4 ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; class GfG { class Node { public int data ; public Node left , right ; } static Node newNode ( int item ) { Node temp = new Node ( ) ; temp . data = item ; temp . left = null ; temp . right = null ; return temp ; } static int findDistance ( Node root , int x ) { if ( root == null ) return - 1 ; int dist = - 1 ; if ( ( root . data == x ) || ( dist = findDistance ( root . left , x ) ) >= 0 || ( dist = findDistance ( root . right , x ) ) >= 0 ) return dist + 1 ; return dist ; } public static void Main ( String [ ] args ) { Node root = newNode ( 5 ) ; root . left = newNode ( 10 ) ; root . right = newNode ( 15 ) ; root . left . left = newNode ( 20 ) ; root . left . right = newNode ( 25 ) ; root . left . right . right = newNode ( 45 ) ; root . right . left = newNode ( 30 ) ; root . right . right = newNode ( 35 ) ; Console . WriteLine ( findDistance ( root , 45 ) ) ; } }

Class/struct names: GfG, Node
C# program:
using System ; public class Right_Sibling { public class Node { public int data ; public Node left , right , parent ; public Node ( int data , Node parent ) { this . data = data ; left = null ; right = null ; this . parent = parent ; } } public static Node findRightSibling ( Node node , int level ) { if ( node == null node . parent == null ) { return null ; } while ( node . parent . right == node || ( node . parent . right == null && node . parent . left == node ) ) { if ( node . parent == null node . parent . parent == null ) { return null ; } node = node . parent ; level -- ; } node = node . parent . right ; while ( level < 0 ) { if ( node . left != null ) { node = node . left ; } else if ( node . right != null ) { node = node . right ; } else { break ; } level ++ ; } if ( level == 0 ) { return node ; } return findRightSibling ( node , level ) ; } public static void Main ( string [ ] args ) { Node root = new Node ( 1 , null ) ; root . left = new Node ( 2 , root ) ; root . right = new Node ( 3 , root ) ; root . left . left = new Node ( 4 , root . left ) ; root . left . right = new Node ( 6 , root . left ) ; root . left . left . left = new Node ( 7 , root . left . left ) ; root . left . left . left . left = new Node ( 10 , root . left . left . left ) ; root . left . right . right = new Node ( 9 , root . left . right ) ; root . right . right = new Node ( 5 , root . right ) ; root . right . right . right = new Node ( 8 , root . right . right ) ; root . right . right . right . right = new Node ( 12 , root . right . right . right ) ; Console . WriteLine ( findRightSibling ( root . left . left . left . left , 0 ) . data ) ; } }

Accumulator variables: level
Class/struct names: Node, Right_Sibling
C# program:
using System ; class GfG { public class V { public int value_level = 0 ; } public class Node { public Node left , right ; public int key ; } static Node newNode ( int key ) { Node temp = new Node ( ) ; temp . key = key ; temp . left = null ; temp . right = null ; return temp ; } static Node nextRightNode ( Node root , int k , int level , V value ) { if ( root == null ) return null ; if ( root . key == k ) { value . value_level = level ; return null ; } else if ( value . value_level != 0 ) { if ( level == value . value_level ) return root ; } Node leftNode = nextRightNode ( root . left , k , level + 1 , value ) ; if ( leftNode != null ) return leftNode ; return nextRightNode ( root . right , k , level + 1 , value ) ; } static Node nextRightNodeUtil ( Node root , int k ) { V v = new V ( ) ; return nextRightNode ( root , k , 1 , v ) ; } static void test ( Node root , int k ) { Node nr = nextRightNodeUtil ( root , k ) ; if ( nr != null ) Console . WriteLine ( " Next ▁ Right ▁ of ▁ " + k + " ▁ is ▁ " + nr . key ) ; else Console . WriteLine ( " No ▁ next ▁ right ▁ node " + " ▁ found ▁ for ▁ " + k ) ; } public static void Main ( String [ ] args ) { Node root = newNode ( 10 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 6 ) ; root . right . right = newNode ( 5 ) ; root . left . left = newNode ( 8 ) ; root . left . right = newNode ( 4 ) ; test ( root , 10 ) ; test ( root , 2 ) ; test ( root , 6 ) ; test ( root , 5 ) ; test ( root , 8 ) ; test ( root , 4 ) ; } }

Class/struct names: GfG, Node, V
C# program:
using System ; class GFG { public class Node { public int data ; public Node left ; public Node right ; } ; static int first , second , third ; static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = null ; node . right = null ; return ( node ) ; } static void threelargest ( Node root ) { if ( root == null ) return ; if ( root . data > first ) { third = second ; second = first ; first = root . data ; } else if ( root . data > second && root . data != first ) { third = second ; second = root . data ; } else if ( root . data > third && root . data != first && root . data != second ) third = root . data ; threelargest ( root . left ) ; threelargest ( root . right ) ; } public static void Main ( String [ ] args ) { Node 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 ( 4 ) ; root . right . right = newNode ( 5 ) ; first = 0 ; second = 0 ; third = 0 ; threelargest ( root ) ; Console . WriteLine ( " three ▁ largest ▁ elements ▁ are ▁ " + first + " ▁ " + second + " ▁ " + third ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; left = right = null ; } } public class BinaryTree { public Node root ; public static int findMax ( Node node ) { if ( node == null ) { return int . MinValue ; } int res = node . data ; int lres = findMax ( node . left ) ; int rres = findMax ( node . right ) ; if ( lres > res ) { res = lres ; } if ( rres > res ) { res = rres ; } return res ; } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 2 ) ; tree . root . left = new Node ( 7 ) ; tree . root . right = new Node ( 5 ) ; tree . root . left . right = new Node ( 6 ) ; tree . root . left . right . left = new Node ( 1 ) ; tree . root . left . right . right = new Node ( 11 ) ; tree . root . right . right = new Node ( 9 ) ; tree . root . right . right . left = new Node ( 4 ) ; Console . WriteLine ( " Maximum ▁ element ▁ is ▁ " + BinaryTree . findMax ( tree . root ) ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; right = left = null ; } } public class BinaryTree { Node root ; Node head ; Node prev ; public Node extractLeafList ( Node root ) { if ( root == null ) return null ; if ( root . left == null && root . right == null ) { if ( head == null ) { head = root ; prev = root ; } else { prev . right = root ; root . left = prev ; prev = root ; } return null ; } root . left = extractLeafList ( root . left ) ; root . right = extractLeafList ( root . right ) ; return root ; } void inorder ( Node node ) { if ( node == null ) return ; inorder ( node . left ) ; Console . Write ( node . data + " ▁ " ) ; inorder ( node . right ) ; } public void printDLL ( Node head ) { Node last = null ; while ( head != null ) { Console . Write ( head . data + " ▁ " ) ; last = head ; head = head . right ; } } public static 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 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; tree . root . right . right = new Node ( 6 ) ; tree . root . left . left . left = new Node ( 7 ) ; tree . root . left . left . right = new Node ( 8 ) ; tree . root . right . right . left = new Node ( 9 ) ; tree . root . right . right . right = new Node ( 10 ) ; Console . WriteLine ( " Inorder ▁ traversal ▁ of ▁ given ▁ tree ▁ is ▁ : ▁ " ) ; tree . inorder ( tree . root ) ; tree . extractLeafList ( tree . root ) ; Console . WriteLine ( " " ) ; Console . WriteLine ( " Extracted ▁ double ▁ link ▁ list ▁ is ▁ : ▁ " ) ; tree . printDLL ( tree . head ) ; Console . WriteLine ( " " ) ; Console . WriteLine ( " Inorder ▁ traversal ▁ of ▁ modified ▁ tree ▁ is ▁ : ▁ " ) ; tree . inorder ( tree . root ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; left = null ; right = null ; } } public class InorderSuccessor { Node root ; class PreviousNode { public Node pNode ; public PreviousNode ( ) { pNode = null ; } } private void inOrderSuccessorOfBinaryTree ( Node root , PreviousNode pre , int searchNode ) { if ( root . right != null ) inOrderSuccessorOfBinaryTree ( root . right , pre , searchNode ) ; if ( root . data == searchNode ) { Console . Write ( " inorder ▁ successor ▁ of ▁ " + searchNode + " ▁ is : ▁ " ) ; if ( pre . pNode != null ) Console . WriteLine ( pre . pNode . data ) ; else Console . WriteLine ( " null " ) ; } pre . pNode = root ; if ( root . left != null ) inOrderSuccessorOfBinaryTree ( root . left , pre , searchNode ) ; } public static void Main ( String [ ] args ) { InorderSuccessor tree = new InorderSuccessor ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; tree . root . right . right = new Node ( 6 ) ; tree . inOrderSuccessorOfBinaryTree ( tree . root , new PreviousNode ( ) , 3 ) ; tree . inOrderSuccessorOfBinaryTree ( tree . root , new PreviousNode ( ) , 4 ) ; tree . inOrderSuccessorOfBinaryTree ( tree . root , new PreviousNode ( ) , 6 ) ; } }

Class/struct names: InorderSuccessor, Node, PreviousNode
C# program:
using System ; using System . Collections . Generic ; class Graph { static void addEdge ( LinkedList < int > [ ] adj , int u , int v ) { adj [ u ] . AddLast ( v ) ; adj [ v ] . AddLast ( u ) ; } static void printGraph ( LinkedList < int > [ ] adj ) { for ( int i = 0 ; i < adj . Length ; i ++ ) { Console . WriteLine ( " STRNEWLINE Adjacency ▁ list ▁ of ▁ vertex ▁ " + i ) ; Console . Write ( " head " ) ; foreach ( var item in adj [ i ] ) { Console . Write ( " ▁ - > ▁ " + item ) ; } Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { int V = 5 ; LinkedList < int > [ ] adj = new LinkedList < int > [ V ] ; for ( int i = 0 ; i < V ; i ++ ) adj [ i ] = new LinkedList < int > ( ) ; addEdge ( adj , 0 , 1 ) ; addEdge ( adj , 0 , 4 ) ; addEdge ( adj , 1 , 2 ) ; addEdge ( adj , 1 , 3 ) ; addEdge ( adj , 1 , 4 ) ; addEdge ( adj , 2 , 3 ) ; addEdge ( adj , 3 , 4 ) ; printGraph ( adj ) ; Console . ReadKey ( ) ; } }

Index/key variables: V, i, u, v
Accumulator variables: i
Iterator variables: i, item
Class/struct names: Graph