dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int MAX = 26 ; static bool targetstring ( string str1 , string str2 ) { int l1 = str1 . Length ; int l2 = str2 . Length ; if ( l1 != l2 ) return false ; int [ ] map = new int [ MAX ] ; Array . Clear ( map , 0 , 26 ) ; for ( int i = 0 ; i < l1 ; i ++ ) map [ str1 [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < l2 ; i ++ ) { map [ str2 [ i ] - ' a ' ] -- ; if ( map [ str2 [ i ] - ' a ' ] < 0 ) return false ; } return true ; } static void Main ( ) { string str1 = " geeksforgeeks " ; string str2 = " geegeeksksfor " ; if ( targetstring ( str1 , str2 ) ) Console . Write ( " YES " ) ; else Console . Write ( " NO " ) ; } }

Index/key variables: MAX, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isDigitPresent ( int x , int d ) { while ( x > 0 ) { if ( x % 10 == d ) break ; x = x / 10 ; } return ( x > 0 ) ; } static void printNumbers ( int n , int d ) { for ( int i = 0 ; i <= n ; i ++ ) if ( i == d || isDigitPresent ( i , d ) ) Console . Write ( i + " ▁ " ) ; } public static void Main ( ) { int n = 47 , d = 7 ; printNumbers ( n , d ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static char findExtraCharcter ( char [ ] strA , char [ ] strB ) { int [ ] m1 = new int [ 256 ] ; for ( int i = 0 ; i < strB . Length ; i ++ ) m1 [ strB [ i ] ] ++ ; for ( int i = 0 ; i < strA . Length ; i ++ ) m1 [ strA [ i ] ] -- ; for ( int i = 0 ; i < m1 . Length ; i ++ ) { if ( m1 [ i ] == 1 ) return ( char ) i ; } return char . MinValue ; } public static void Main ( String [ ] args ) { String strA = " abcd " ; String strB = " cbdad " ; Console . WriteLine ( findExtraCharcter ( strA . ToCharArray ( ) , strB . ToCharArray ( ) ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static char findExtraCharcter ( string strA , string strB ) { int res = 0 , i ; for ( i = 0 ; i < strA . Length ; i ++ ) { res ^= strA [ i ] ; } for ( i = 0 ; i < strB . Length ; i ++ ) { res ^= strB [ i ] ; } return ( ( char ) ( res ) ) ; } public static void Main ( ) { string strA = " abcd " ; string strB = " cbdad " ; Console . WriteLine ( findExtraCharcter ( strA , strB ) ) ; } }

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { private static char findExtraCharacter ( String s1 , String s2 ) { String smallStr ; String largeStr ; if ( s1 . Length > s2 . Length ) { smallStr = s2 ; largeStr = s1 ; } else { smallStr = s1 ; largeStr = s2 ; } int smallStrCodeTotal = 0 ; int largeStrCodeTotal = 0 ; int i = 0 ; for ( ; i < smallStr . Length ; i ++ ) { smallStrCodeTotal += smallStr [ i ] ; largeStrCodeTotal += largeStr [ i ] ; } largeStrCodeTotal += largeStr [ i ] ; int intChar = largeStrCodeTotal - smallStrCodeTotal ; return ( char ) intChar ; } public static void Main ( String [ ] args ) { String s1 = " abcd " ; String s2 = " cbdae " ; char extraChar = findExtraCharacter ( s1 , s2 ) ; Console . WriteLine ( " Extra ▁ character : ▁ " + extraChar ) ; } }

Index/key variables: i
Accumulator variables: i, largeStrCodeTotal, smallStrCodeTotal
Class/struct names: GFG
C# program:
using System ; class GFG { static void myCopy ( char [ ] s1 , char [ ] s2 ) { int i = 0 ; for ( i = 0 ; i < s1 . Length ; i ++ ) s2 [ i ] = s1 [ i ] ; } public static void Main ( String [ ] args ) { char [ ] s1 = " GEEKSFORGEEKS " . ToCharArray ( ) ; char [ ] s2 = new char [ s1 . Length ] ; myCopy ( s1 , s2 ) ; Console . WriteLine ( String . Join ( " " , s2 ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int calculateSum ( string [ ] arr , int n ) { if ( n == 0 ) return 0 ; string s = arr [ 0 ] ; int value = int . Parse ( s ) ; int sum = value ; for ( int i = 2 ; i < n ; i = i + 2 ) { s = arr [ i ] ; value = int . Parse ( s ) ; char operation = arr [ i - 1 ] [ 0 ] ; if ( operation == ' + ' ) sum += value ; else sum -= value ; } return sum ; } public static void Main ( ) { string [ ] arr = { "3" , " + " , "4" , " - " , "7" , " + " , "13" } ; int n = arr . Length ; Console . Write ( calculateSum ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX_CHAR = 26 ; static bool twoStrings ( String s1 , String s2 ) { bool [ ] v = new bool [ MAX_CHAR ] ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) v [ i ] = false ; for ( int i = 0 ; i < s1 . Length ; i ++ ) v [ s1 [ i ] - ' a ' ] = true ; for ( int i = 0 ; i < s2 . Length ; i ++ ) if ( v [ s2 [ i ] - ' a ' ] ) return true ; return false ; } public static void Main ( ) { String str1 = " hello " ; String str2 = " world " ; if ( twoStrings ( str1 , str2 ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void LargestString ( string [ ] na ) { int N = na . Length ; int [ ] c = new int [ N ] ; int m = 0 ; for ( int j = 0 ; j < N ; j ++ ) { bool [ ] character = new bool [ 26 ] ; for ( int k = 0 ; k < na [ j ] . Length ; k ++ ) { int x = na [ j ] [ k ] - ' A ' ; if ( ( na [ j ] [ k ] != ' ▁ ' ) && ( character [ x ] == false ) ) { c [ j ] ++ ; character [ x ] = true ; } } if ( c [ j ] > c [ m ] ) m = j ; } Console . Write ( na [ m ] ) ; } public static void Main ( ) { string [ ] na = { " BOB " , " A ▁ AB ▁ C ▁ JOHNSON " , " ANJALI " , " ASKRIT " , " ARMAN ▁ MALLIK " } ; LargestString ( na ) ; } }

Index/key variables: N, j, k, m, x
Accumulator variables: j, k
Iterator variables: j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int LongestWordLength ( string str ) { String [ ] words = str . Split ( ' ▁ ' ) ; int length = 0 ; for ( int i = 0 ; i < words . Length ; i ++ ) { if ( length < words [ i ] . Length ) { length = words [ i ] . Length ; } } return length ; } static void Main ( ) { string str = " I ▁ am ▁ an ▁ intern ▁ at ▁ geeksforgeeks " ; Console . Write ( LongestWordLength ( str ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static string morseEncode ( char x ) { switch ( x ) { case ' a ' : return " . - " ; case ' b ' : return " - . . . " ; case ' c ' : return " - . - . " ; case ' d ' : return " - . . " ; case ' e ' : return " . " ; case ' f ' : return " . . - . " ; case ' g ' : return " - - . " ; case ' h ' : return " . . . . " ; case ' i ' : return " . . " ; case ' j ' : return " . - - - " ; case ' k ' : return " - . - " ; case ' l ' : return " . - . . " ; case ' m ' : return " - - " ; case ' n ' : return " - . " ; case ' o ' : return " - - - " ; case ' p ' : return " . - - . " ; case ' q ' : return " - - . - " ; case ' r ' : return " . - . " ; case ' s ' : return " . . . " ; case ' t ' : return " - " ; case ' u ' : return " . . - " ; case ' v ' : return " . . . - " ; case ' w ' : return " . - - " ; case ' x ' : return " - . . - " ; case ' y ' : return " - . - - " ; case ' z ' : return " - - . . " ; case '1' : return " . - - - - " ; case '2' : return " . . - - - " ; case '3' : return " . . . - - " ; case '4' : return " . . . . - " ; case '5' : return " . . . . . " ; case '6' : return " - . . . . " ; case '7' : return " - - . . . " ; case '8' : return " - - - . . " ; case '9' : return " - - - - . " ; case '0' : return " - - - - - " ; } return " " ; } static void morseCode ( string s ) { for ( int i = 0 ; i < s . Length ; i ++ ) Console . Write ( morseEncode ( s [ i ] ) ) ; Console . WriteLine ( ) ; } public static void Main ( ) { string s = " geeksforgeeks " ; morseCode ( s ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void polybiusCipher ( string s ) { int row , col ; for ( int i = 0 ; i < s . Length ; i ++ ) { row = ( int ) Math . Floor ( ( s [ i ] - ' a ' ) / 5.0 ) + 1 ; col = ( ( s [ i ] - ' a ' ) % 5 ) + 1 ; if ( s [ i ] == ' k ' ) { row = row - 1 ; col = 5 - col + 1 ; } else if ( s [ i ] >= ' j ' ) { if ( col == 1 ) { col = 6 ; row = row - 1 ; } col = col - 1 ; } Console . Write ( row + " " + col ) ; } Console . WriteLine ( ) ; } static void Main ( ) { string s = " geeksforgeeks " ; polybiusCipher ( s ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX_CHAR = 26 ; static int minRemoval ( string str ) { int [ ] hash = new int [ MAX_CHAR ] ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) hash [ i ] = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) hash [ str [ i ] - ' a ' ] ++ ; int count = 0 ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) if ( hash [ i ] % 2 == 1 ) count ++ ; return ( count == 0 ) ? 0 : count - 1 ; } public static void Main ( ) { string str = " geeksforgeeks " ; Console . Write ( minRemoval ( str ) ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MAX_VERTEX = 101 ; static int [ ] Arr = new int [ MAX_VERTEX ] ; static int [ ] size = new int [ MAX_VERTEX ] ; static void initialize ( int n ) { for ( int i = 0 ; i <= n ; i ++ ) { Arr [ i ] = i ; size [ i ] = 1 ; } } static int find ( int i ) { while ( Arr [ i ] != i ) { Arr [ i ] = Arr [ Arr [ i ] ] ; i = Arr [ i ] ; } return i ; } static void _union ( int xr , int yr ) { if ( size [ xr ] < size [ yr ] ) { Arr [ xr ] = Arr [ yr ] ; size [ yr ] += size [ xr ] ; } else { Arr [ yr ] = Arr [ xr ] ; size [ xr ] += size [ yr ] ; } } static int isCycle ( List < int > [ ] adj , int V ) { for ( int i = 0 ; i < V ; i ++ ) { for ( int j = 0 ; j < adj [ i ] . Count ; j ++ ) { int x = find ( i ) ; int y = find ( adj [ i ] [ j ] ) ; if ( x == y ) return 1 ; _union ( x , y ) ; } } return 0 ; } public static void Main ( String [ ] args ) { int V = 3 ; initialize ( V ) ; List < int > [ ] adj = new List < int > [ V ] ; for ( int i = 0 ; i < V ; i ++ ) adj [ i ] = new List < int > ( ) ; adj [ 0 ] . Add ( 1 ) ; adj [ 0 ] . Add ( 2 ) ; adj [ 1 ] . Add ( 2 ) ; if ( isCycle ( adj , V ) == 1 ) Console . Write ( " Graph ▁ contains ▁ Cycle . STRNEWLINE " ) ; else Console . Write ( " Graph ▁ does ▁ not ▁ contain ▁ Cycle . STRNEWLINE " ) ; } }

Index/key variables: MAX_VERTEX, V, i, j, xr, yr
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX_LEN = 1005 ; static int MAX_CHAR = 26 ; static int [ , ] cnt = new int [ MAX_LEN , MAX_CHAR ] ; static void preProcess ( string s ) { int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) cnt [ i , s [ i ] - ' a ' ] ++ ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 0 ; j < 26 ; j ++ ) cnt [ i , j ] += cnt [ i - 1 , j ] ; } } static int findCharFreq ( int l , int r , char c ) { return ( cnt [ r , c - 97 ] - cnt [ l , c - 97 ] ) ; } public static void Main ( string [ ] args ) { string s = " geeksforgeeks " ; int Q = 4 ; preProcess ( s ) ; Console . WriteLine ( findCharFreq ( 0 , 5 , ' e ' ) ) ; Console . WriteLine ( findCharFreq ( 2 , 6 , ' f ' ) ) ; Console . WriteLine ( findCharFreq ( 4 , 7 , ' m ' ) ) ; Console . WriteLine ( findCharFreq ( 0 , 12 , ' e ' ) ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GfG { static int findLUSlength ( String a , String b ) { if ( a . Equals ( b ) == true ) return 0 ; return Math . Max ( a . Length , b . Length ) ; } public static void Main ( ) { String a = " abcdabcd " , b = " abcabc " ; Console . Write ( findLUSlength ( a , b ) ) ; } }

Class/struct names: GfG
C# program:
using System ; class GFG { static void swapTwoHalves ( string a , string b ) { int la = a . Length ; int lb = b . Length ; string c = a . Substring ( 0 , la / 2 ) + b . Substring ( lb / 2 , lb / 2 + 1 ) ; string d = b . Substring ( 0 , lb / 2 ) + a . Substring ( la / 2 , la / 2 ) ; Console . Write ( c + " STRNEWLINE " + d + " STRNEWLINE " ) ; } static void Main ( ) { string a = " remuneration " ; string b = " day " ; swapTwoHalves ( a , b ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void solve ( string a , string b , int k ) { string s = " " ; int la = a . Length ; int lb = b . Length ; int l = la + lb ; int indexa = 0 , indexb = 0 ; while ( l > 0 ) { int pa = 0 , pb = 0 ; if ( la - indexa >= k ) { s = s + a . Substring ( indexa , k ) ; indexa = indexa + k ; pa = k ; } else if ( la - indexa < k && la - indexa > 0 ) { s = s + a . Substring ( indexa , la - indexa ) ; pa = la - indexa ; indexa = la ; } else if ( indexa >= la ) pa = 0 ; if ( lb - indexb >= k ) { s = s + b . Substring ( indexb , k ) ; pb = k ; indexb = indexb + k ; } else if ( lb - indexb < k && lb - indexb > 0 ) { s = s + b . Substring ( indexb , lb - indexb ) ; pb = lb - indexb ; indexb = lb ; } else if ( indexb >= lb ) pb = 0 ; l = l - pa - pb ; } Console . Write ( s ) ; } static void Main ( ) { string a = " determination " , b = " stance " ; int k = 3 ; solve ( a , b , k ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public class Node { public Node left ; public int data ; public Node right ; } ; static void modifiedLevelOrder ( Node node ) { if ( node == null ) return ; if ( node . left == null && node . right == null ) { Console . Write ( node . data ) ; return ; } Queue < Node > myQueue = new Queue < Node > ( ) ; Stack < Node > myStack = new Stack < Node > ( ) ; Node temp = null ; int sz ; int ct = 0 ; bool rightToLeft = false ; myQueue . Enqueue ( node ) ; while ( myQueue . Count != 0 ) { ct ++ ; sz = myQueue . Count ; for ( int i = 0 ; i < sz ; i ++ ) { temp = myQueue . Peek ( ) ; myQueue . Dequeue ( ) ; if ( rightToLeft == false ) Console . Write ( temp . data + " ▁ " ) ; else myStack . Push ( temp ) ; if ( temp . left != null ) myQueue . Enqueue ( temp . left ) ; if ( temp . right != null ) myQueue . Enqueue ( temp . right ) ; } if ( rightToLeft == true ) { while ( myStack . Count != 0 ) { temp = myStack . Peek ( ) ; myStack . Pop ( ) ; Console . Write ( temp . data + " ▁ " ) ; } } if ( ct == 2 ) { rightToLeft = ! rightToLeft ; ct = 0 ; } Console . Write ( " STRNEWLINE " ) ; } } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = temp . right = null ; return temp ; } 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 ( 6 ) ; root . right . right = newNode ( 7 ) ; root . left . left . left = newNode ( 8 ) ; root . left . left . right = newNode ( 9 ) ; root . left . right . left = newNode ( 3 ) ; root . left . right . right = newNode ( 1 ) ; root . right . left . left = newNode ( 4 ) ; root . right . left . right = newNode ( 2 ) ; root . right . right . left = newNode ( 7 ) ; root . right . right . right = newNode ( 2 ) ; root . left . right . left . left = newNode ( 16 ) ; root . left . right . left . right = newNode ( 17 ) ; root . right . left . right . left = newNode ( 18 ) ; root . right . right . left . right = newNode ( 19 ) ; modifiedLevelOrder ( root ) ; } }

Accumulator variables: ct, i
Iterator variables: i
Boolean variables: rightToLeft
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static int V = 5 ; static int minKey ( int [ ] key , Boolean [ ] mstSet ) { int min = int . MaxValue , min_index = 0 ; for ( int v = 0 ; v < V ; v ++ ) { if ( mstSet [ v ] == false && key [ v ] < min ) { min = key [ v ] ; min_index = v ; } } return min_index ; } static void printMST ( int [ ] parent , int n , int [ , ] graph ) { Console . Write ( " Edge ▁ Weight STRNEWLINE " ) ; int minProduct = 1 ; for ( int i = 1 ; i < V ; i ++ ) { Console . Write ( " { 0 } ▁ - ▁ { 1 } ▁ { 2 } ▁ STRNEWLINE " , parent [ i ] , i , graph [ i , parent [ i ] ] ) ; minProduct *= graph [ i , parent [ i ] ] ; } Console . Write ( " Minimum ▁ Obtainable ▁ product ▁ is ▁ { 0 } STRNEWLINE " , minProduct ) ; } static void primMST ( int [ , ] inputGraph , double [ , ] logGraph ) { int [ ] parent = new int [ V ] ; int [ ] key = new int [ V ] ; Boolean [ ] mstSet = new Boolean [ V ] ; for ( int i = 0 ; i < V ; i ++ ) { key [ i ] = int . MaxValue ; mstSet [ i ] = false ; } key [ 0 ] = 0 ; parent [ 0 ] = - 1 ; for ( int count = 0 ; count < V - 1 ; count ++ ) { int u = minKey ( key , mstSet ) ; mstSet [ u ] = true ; for ( int v = 0 ; v < V ; v ++ ) { if ( logGraph [ u , v ] > 0 && mstSet [ v ] == false && logGraph [ u , v ] < key [ v ] ) { parent [ v ] = u ; key [ v ] = ( int ) logGraph [ u , v ] ; } } } printMST ( parent , V , inputGraph ) ; } static void minimumProductMST ( int [ , ] graph ) { double [ , ] logGraph = new double [ V , V ] ; for ( int i = 0 ; i < V ; i ++ ) { for ( int j = 0 ; j < V ; j ++ ) { if ( graph [ i , j ] > 0 ) { logGraph [ i , j ] = Math . Log ( graph [ i , j ] ) ; } else { logGraph [ i , j ] = 0 ; } } } primMST ( graph , logGraph ) ; } public static void Main ( String [ ] args ) { int [ , ] graph = { { 0 , 2 , 0 , 6 , 0 } , { 2 , 0 , 3 , 8 , 5 } , { 0 , 3 , 0 , 0 , 7 } , { 6 , 8 , 0 , 0 , 9 } , { 0 , 5 , 7 , 9 , 0 } , } ; minimumProductMST ( graph ) ; } }

Index/key variables: V, i, u, v
Accumulator variables: count, i, j, minProduct, v
Iterator variables: count, i, j, v
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static readonly int LEFT = 0 ; static readonly int RIGHT = 1 ; static int ChangeDirection ( int Dir ) { Dir = 1 - Dir ; return Dir ; } public class node { public int data ; public node left , right ; } ; static node newNode ( int data ) { node temp = new node ( ) ; temp . data = data ; temp . left = temp . right = null ; return temp ; } static void modifiedLevelOrder ( node root ) { if ( root == null ) return ; int dir = LEFT ; node temp ; Queue < node > Q = new Queue < node > ( ) ; Stack < node > S = new Stack < node > ( ) ; S . Push ( root ) ; while ( Q . Count != 0 S . Count != 0 ) { while ( S . Count != 0 ) { temp = S . Peek ( ) ; S . Pop ( ) ; Console . Write ( temp . data + " ▁ " ) ; if ( dir == LEFT ) { if ( temp . left != null ) Q . Enqueue ( temp . left ) ; if ( temp . right != null ) Q . Enqueue ( temp . right ) ; } else { if ( temp . right != null ) Q . Enqueue ( temp . right ) ; if ( temp . left != null ) Q . Enqueue ( temp . left ) ; } } Console . WriteLine ( ) ; while ( Q . Count != 0 ) { temp = Q . Peek ( ) ; Q . Dequeue ( ) ; Console . Write ( temp . data + " ▁ " ) ; if ( dir == LEFT ) { if ( temp . left != null ) S . Push ( temp . left ) ; if ( temp . right != null ) S . Push ( temp . right ) ; } else { if ( temp . right != null ) S . Push ( temp . right ) ; if ( temp . left != null ) S . Push ( temp . left ) ; } } Console . WriteLine ( ) ; dir = ChangeDirection ( dir ) ; } } 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 ( 6 ) ; root . right . right = newNode ( 7 ) ; root . left . left . left = newNode ( 8 ) ; root . left . left . right = newNode ( 9 ) ; root . left . right . left = newNode ( 3 ) ; root . left . right . right = newNode ( 1 ) ; root . right . left . left = newNode ( 4 ) ; root . right . left . right = newNode ( 2 ) ; root . right . right . left = newNode ( 7 ) ; root . right . right . right = newNode ( 2 ) ; root . left . right . left . left = newNode ( 16 ) ; root . left . right . left . right = newNode ( 17 ) ; root . right . left . right . left = newNode ( 18 ) ; root . right . right . left . right = newNode ( 19 ) ; modifiedLevelOrder ( root ) ; } }

Class/struct names: GFG, node
C# program:
using System ; using System . Collections . Generic ; class GFG { public class Node { public int key ; public Node left , right ; public Node ( int key ) { this . key = key ; left = null ; right = null ; } } static Node root ; static void inorder ( Node temp ) { if ( temp == null ) return ; inorder ( temp . left ) ; Console . Write ( temp . key + " ▁ " ) ; inorder ( temp . right ) ; } static void insert ( Node temp , int key ) { if ( temp == null ) { root = new Node ( key ) ; return ; } Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( temp ) ; while ( q . Count != 0 ) { temp = q . Peek ( ) ; q . Dequeue ( ) ; if ( temp . left == null ) { temp . left = new Node ( key ) ; break ; } else q . Enqueue ( temp . left ) ; if ( temp . right == null ) { temp . right = new Node ( key ) ; break ; } else q . Enqueue ( temp . right ) ; } } public static void Main ( String [ ] args ) { root = new Node ( 10 ) ; root . left = new Node ( 11 ) ; root . left . left = new Node ( 7 ) ; root . right = new Node ( 9 ) ; root . right . left = new Node ( 15 ) ; root . right . right = new Node ( 8 ) ; Console . Write ( " Inorder ▁ traversal ▁ before ▁ insertion : " ) ; inorder ( root ) ; int key = 12 ; insert ( root , key ) ; Console . Write ( " STRNEWLINE Inorder ▁ traversal ▁ after ▁ insertion : " ) ; inorder ( root ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; class GFG { public int min_diff ; void TOWUtil ( int [ ] arr , int n , Boolean [ ] curr_elements , int no_of_selected_elements , Boolean [ ] soln , int sum , int curr_sum , int curr_position ) { if ( curr_position == n ) return ; if ( ( n / 2 - no_of_selected_elements ) > ( n - curr_position ) ) return ; TOWUtil ( arr , n , curr_elements , no_of_selected_elements , soln , sum , curr_sum , curr_position + 1 ) ; no_of_selected_elements ++ ; curr_sum = curr_sum + arr [ curr_position ] ; curr_elements [ curr_position ] = true ; if ( no_of_selected_elements == n / 2 ) { if ( Math . Abs ( sum / 2 - curr_sum ) < min_diff ) { min_diff = Math . Abs ( sum / 2 - curr_sum ) ; for ( int i = 0 ; i < n ; i ++ ) soln [ i ] = curr_elements [ i ] ; } } else { TOWUtil ( arr , n , curr_elements , no_of_selected_elements , soln , sum , curr_sum , curr_position + 1 ) ; } curr_elements [ curr_position ] = false ; } void tugOfWar ( int [ ] arr ) { int n = arr . Length ; Boolean [ ] curr_elements = new Boolean [ n ] ; Boolean [ ] soln = new Boolean [ n ] ; min_diff = int . MaxValue ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; curr_elements [ i ] = soln [ i ] = false ; } TOWUtil ( arr , n , curr_elements , 0 , soln , sum , 0 , 0 ) ; Console . Write ( " The ▁ first ▁ subset ▁ is : ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( soln [ i ] == true ) Console . Write ( arr [ i ] + " ▁ " ) ; } Console . Write ( " STRNEWLINE The ▁ second ▁ subset ▁ is : ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( soln [ i ] == false ) Console . Write ( arr [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 23 , 45 , - 34 , 12 , 0 , 98 , - 99 , 4 , 189 , - 1 , 4 } ; GFG a = new GFG ( ) ; a . tugOfWar ( arr ) ; } }

Index/key variables: curr_position, i, n
Accumulator variables: i, no_of_selected_elements, sum
Iterator variables: i
Class/struct names: GFG