dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool [ ] prime = new bool [ 100006 ] ; static void SieveOfEratosthenes ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) prime [ i ] = true ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= n ; i += p ) prime [ i ] = false ; } } } static void sortedArray ( int [ ] arr , int n ) { SieveOfEratosthenes ( 100005 ) ; List < int > v = new List < int > ( ) ; for ( int i = 0 ; i < n ; ++ i ) { if ( prime [ arr [ i ] ] == false ) v . Add ( arr [ i ] ) ; } v . Sort ( ) ; int j = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( prime [ arr [ i ] ] == true ) Console . Write ( arr [ i ] + " ▁ " ) ; else { Console . Write ( v [ j ] + " ▁ " ) ; j ++ ; } } } public static void Main ( ) { int n = 6 ; int [ ] arr = { 100 , 11 , 500 , 2 , 17 , 1 } ; sortedArray ( arr , n ) ; } }

Index/key variables: i, j, p
Accumulator variables: i, j, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; public class GFG { public class Node { public int key ; public Node left , right ; } public static Node newNode ( int key ) { Node node = new Node ( ) ; node . key = key ; node . left = node . right = null ; return ( node ) ; } public static int addBT ( Node root ) { if ( root == null ) { return 0 ; } return ( root . key + addBT ( root . left ) + addBT ( 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 ( 6 ) ; root . right . right = newNode ( 7 ) ; root . right . left . right = newNode ( 8 ) ; int sum = addBT ( root ) ; Console . WriteLine ( " Sum ▁ of ▁ all ▁ the ▁ elements ▁ is : ▁ " + sum ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MaxSumDifference ( int [ ] a , int n ) { List < int > finalSequence = new List < int > ( ) ; Array . Sort ( a ) ; for ( int i = 0 ; i < n / 2 ; ++ i ) { finalSequence . Add ( a [ i ] ) ; finalSequence . Add ( a [ n - i - 1 ] ) ; } if ( n % 2 != 0 ) finalSequence . Add ( a [ n / 2 ] ) ; int MaximumSum = 0 ; for ( int i = 0 ; i < n - 1 ; ++ i ) { MaximumSum = MaximumSum + Math . Abs ( finalSequence [ i ] - finalSequence [ i + 1 ] ) ; } MaximumSum = MaximumSum + Math . Abs ( finalSequence [ n - 1 ] - finalSequence [ 0 ] ) ; return MaximumSum ; } public static void Main ( ) { int [ ] a = { 1 , 2 , 4 , 8 } ; int n = a . Length ; Console . WriteLine ( MaxSumDifference ( a , n ) ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minSwap ( int [ ] arr , int n , int k ) { int count = 0 ; for ( int i = 0 ; i < n ; ++ i ) if ( arr [ i ] <= k ) ++ count ; int bad = 0 ; for ( int i = 0 ; i < count ; ++ i ) if ( arr [ i ] > k ) ++ bad ; int ans = bad ; for ( int i = 0 , j = count ; j < n ; ++ i , ++ j ) { if ( arr [ i ] > k ) -- bad ; if ( arr [ j ] > k ) ++ bad ; ans = Math . Min ( ans , bad ) ; } return ans ; } public static void Main ( ) { int [ ] arr = { 2 , 1 , 5 , 6 , 3 } ; int n = arr . Length ; int k = 3 ; Console . WriteLine ( minSwap ( arr , n , k ) ) ; int [ ] arr1 = { 2 , 7 , 9 , 5 , 8 , 7 , 4 } ; n = arr1 . Length ; k = 5 ; Console . WriteLine ( minSwap ( arr1 , n , k ) ) ; } }

Index/key variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printArray ( int [ ] array , int length ) { Console . Write ( " [ " ) ; for ( int i = 0 ; i < length ; i ++ ) { Console . Write ( array [ i ] ) ; if ( i < ( length - 1 ) ) Console . Write ( " , " ) ; else Console . Write ( " ] STRNEWLINE " ) ; } } static void reverse ( int [ ] array , int start , int end ) { while ( start < end ) { int temp = array [ start ] ; array [ start ] = array [ end ] ; array [ end ] = temp ; start ++ ; end -- ; } } static void rearrange ( int [ ] array , int start , int end ) { if ( start == end ) return ; rearrange ( array , ( start + 1 ) , end ) ; if ( array [ start ] >= 0 ) { reverse ( array , ( start + 1 ) , end ) ; reverse ( array , start , end ) ; } } public static void Main ( string [ ] args ) { int [ ] array = { - 12 , - 11 , - 13 , - 5 , - 6 , 7 , 5 , 3 , 6 } ; int length = array . Length ; int countNegative = 0 ; for ( int i = 0 ; i < length ; i ++ ) { if ( array [ i ] < 0 ) countNegative ++ ; } Console . Write ( " array : ▁ " ) ; printArray ( array , length ) ; rearrange ( array , 0 , ( length - 1 ) ) ; reverse ( array , countNegative , ( length - 1 ) ) ; Console . Write ( " rearranged ▁ array : ▁ " ) ; printArray ( array , length ) ; } }

Index/key variables: end, i, start
Accumulator variables: countNegative, end, i, start
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void mergeArray ( int [ ] arr1 , int [ ] arr2 ) { int n = arr1 . Length ; int m = arr2 . Length ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr1 [ i ] > arr2 [ 0 ] ) { int temp = arr1 [ i ] ; arr1 [ i ] = arr2 [ 0 ] ; arr2 [ 0 ] = temp ; int firstElement = arr2 [ 0 ] ; int k ; for ( k = 1 ; k < m && arr2 [ k ] < firstElement ; k ++ ) { arr2 [ k - 1 ] = arr2 [ k ] ; } arr2 [ k - 1 ] = firstElement ; } } foreach ( int i in arr1 ) { Console . Write ( i + " ▁ " ) ; } Console . WriteLine ( ) ; foreach ( int i in arr2 ) { Console . Write ( i + " ▁ " ) ; } } static public void Main ( ) { int [ ] arr1 = { 1 , 3 , 5 , 7 } ; int [ ] arr2 = { 0 , 2 , 6 , 8 , 9 } ; mergeArray ( arr1 , arr2 ) ; } }

Index/key variables: i, k
Accumulator variables: i, k
Iterator variables: i, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxProductSubarrayOfSizeK ( int [ ] A , int n , int k ) { Array . Sort ( A ) ; int product = 1 ; int i ; if ( A [ n - 1 ] == 0 && k % 2 != 0 ) return 0 ; if ( A [ n - 1 ] <= 0 && k % 2 != 0 ) { for ( i = n - 1 ; i >= n - k ; i -- ) product *= A [ i ] ; return product ; } i = 0 ; int j = n - 1 ; if ( k % 2 != 0 ) { product *= A [ j ] ; j -- ; k -- ; } k >>= 1 ; for ( int itr = 0 ; itr < k ; itr ++ ) { int left_product = A [ i ] * A [ i + 1 ] ; int right_product = A [ j ] * A [ j - 1 ] ; if ( left_product > right_product ) { product *= left_product ; i += 2 ; } else { product *= right_product ; j -= 2 ; } } return product ; } public static void Main ( ) { int [ ] A = { 1 , 2 , - 1 , - 3 , - 6 , 4 } ; int n = A . Length ; int k = 4 ; Console . WriteLine ( maxProductSubarrayOfSizeK ( A , n , k ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, itr, j, k, product
Iterator variables: i, itr
Class/struct names: GFG
C# program:
using System ; public class Test { static int [ ] arr = new int [ ] { 50 , 40 , 70 , 60 , 90 } ; static int [ ] index = new int [ ] { 3 , 0 , 4 , 1 , 2 } ; static void reorder ( ) { int [ ] temp = new int [ arr . Length ] ; for ( int i = 0 ; i < arr . Length ; i ++ ) temp [ index [ i ] ] = arr [ i ] ; for ( int i = 0 ; i < arr . Length ; i ++ ) { arr [ i ] = temp [ i ] ; index [ i ] = i ; } } public static void Main ( ) { reorder ( ) ; Console . WriteLine ( " Reordered ▁ array ▁ is : ▁ " ) ; Console . WriteLine ( string . Join ( " , " , arr ) ) ; Console . WriteLine ( " Modified ▁ Index ▁ array ▁ is : " ) ; Console . WriteLine ( string . Join ( " , " , index ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: Test
C# program:
using System ; class GFG { static void selectionSort ( string [ ] arr , int n ) { for ( int i = 0 ; i < n - 1 ; i ++ ) { int min_index = i ; string minStr = arr [ i ] ; for ( int j = i + 1 ; j < n ; j ++ ) { if ( arr [ j ] . CompareTo ( minStr ) != 0 ) { minStr = arr [ j ] ; min_index = j ; } } if ( min_index != i ) { string temp = arr [ min_index ] ; arr [ min_index ] = arr [ i ] ; arr [ i ] = temp ; } } } static void Main ( ) { string [ ] arr = { " GeeksforGeeks " , " Practice . GeeksforGeeks " , " GeeksQuiz " } ; int n = arr . Length ; Console . WriteLine ( " Given ▁ array ▁ is " ) ; for ( int i = 0 ; i < n ; i ++ ) { Console . WriteLine ( i + " : ▁ " + arr [ i ] ) ; } Console . WriteLine ( ) ; selectionSort ( arr , n ) ; Console . WriteLine ( " Sorted ▁ array ▁ is " ) ; for ( int i = 0 ; i < n ; i ++ ) { Console . WriteLine ( i + " : ▁ " + arr [ i ] ) ; } } }

Index/key variables: i, j, min_index
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class Test { static int [ ] arr = new int [ ] { 50 , 40 , 70 , 60 , 90 } ; static int [ ] index = new int [ ] { 3 , 0 , 4 , 1 , 2 } ; static void reorder ( ) { for ( int i = 0 ; i < arr . Length ; i ++ ) { while ( index [ i ] != i ) { int oldTargetI = index [ index [ i ] ] ; char oldTargetE = ( char ) arr [ index [ i ] ] ; arr [ index [ i ] ] = arr [ i ] ; index [ index [ i ] ] = index [ i ] ; index [ i ] = oldTargetI ; arr [ i ] = oldTargetE ; } } } public static void Main ( ) { reorder ( ) ; Console . WriteLine ( " Reordered ▁ array ▁ is : ▁ " ) ; Console . WriteLine ( String . Join ( " ▁ " , arr ) ) ; Console . WriteLine ( " Modified ▁ Index ▁ array ▁ is : " ) ; Console . WriteLine ( String . Join ( " ▁ " , index ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: Test
C# program:
using System ; class GFG { static void stoogesort ( int [ ] arr , int l , int h ) { if ( l >= h ) return ; if ( arr [ l ] > arr [ h ] ) { int t = arr [ l ] ; arr [ l ] = arr [ h ] ; arr [ h ] = t ; } if ( h - l + 1 > 2 ) { int t = ( h - l + 1 ) / 3 ; stoogesort ( arr , l , h - t ) ; stoogesort ( arr , l + t , h ) ; stoogesort ( arr , l , h - t ) ; } } public static void Main ( ) { int [ ] arr = { 2 , 4 , 5 , 3 , 1 } ; int n = arr . Length ; stoogesort ( arr , 0 , n - 1 ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: h, i, l
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int heapSize ; public static void heapify ( int [ ] arr , int [ ] index , int i ) { int largest = i ; int left = 2 * i + 1 ; int right = 2 * i + 2 ; if ( left < heapSize && index [ left ] > index [ largest ] ) { largest = left ; } if ( right < heapSize && index [ right ] > index [ largest ] ) { largest = right ; } if ( largest != i ) { int temp = arr [ largest ] ; arr [ largest ] = arr [ i ] ; arr [ i ] = temp ; temp = index [ largest ] ; index [ largest ] = index [ i ] ; index [ i ] = temp ; heapify ( arr , index , largest ) ; } } public static void heapSort ( int [ ] arr , int [ ] index , int n ) { for ( int i = ( n - 1 ) / 2 ; i >= 0 ; i -- ) { heapify ( arr , index , i ) ; } for ( int i = n - 1 ; i > 0 ; i -- ) { int temp = index [ 0 ] ; index [ 0 ] = index [ i ] ; index [ i ] = temp ; temp = arr [ 0 ] ; arr [ 0 ] = arr [ i ] ; arr [ i ] = temp ; heapSize -- ; heapify ( arr , index , 0 ) ; } } static void Main ( ) { int [ ] arr = { 50 , 40 , 70 , 60 , 90 } ; int [ ] index = { 3 , 0 , 4 , 1 , 2 } ; int n = arr . Length ; heapSize = n ; heapSort ( arr , index , n ) ; Console . WriteLine ( " Reordered ▁ array ▁ is : ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; Console . WriteLine ( " Modified ▁ Index ▁ array ▁ is : ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( index [ i ] + " ▁ " ) ; } }

Index/key variables: i, largest, left, right
Accumulator variables: heapSize, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { public static int sum = 0 ; public class Node { public int data ; public Node left , right ; } public static Node getNode ( int data ) { Node newNode = new Node ( ) ; newNode . data = data ; newNode . left = newNode . right = null ; return newNode ; } public static void sumOfParentOfX ( Node root , int x ) { if ( root == null ) { return ; } if ( ( root . left != null && root . left . data == x ) || ( root . right != null && root . right . data == x ) ) { sum += root . data ; } sumOfParentOfX ( root . left , x ) ; sumOfParentOfX ( root . right , x ) ; } public static int sumOfParentOfXUtil ( Node root , int x ) { sum = 0 ; sumOfParentOfX ( root , x ) ; return sum ; } public static void Main ( string [ ] args ) { Node root = getNode ( 4 ) ; root . left = getNode ( 2 ) ; root . right = getNode ( 5 ) ; root . left . left = getNode ( 7 ) ; root . left . right = getNode ( 2 ) ; root . right . left = getNode ( 2 ) ; root . right . right = getNode ( 3 ) ; int x = 2 ; Console . WriteLine ( " Sum ▁ = ▁ " + sumOfParentOfXUtil ( root , x ) ) ; } }

Accumulator variables: sum
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static void bitonicGenerator ( int [ ] arr , int n ) { int i = 1 ; int j = n - 1 ; if ( j % 2 != 0 ) j -- ; while ( i < j ) { arr = swap ( arr , i , j ) ; i += 2 ; j -= 2 ; } Array . Sort ( arr , 0 , ( n + 1 ) / 2 ) ; Array . Sort ( arr , ( n + 1 ) / 2 , n - ( ( n + 1 ) / 2 ) ) ; int low = ( n + 1 ) / 2 , high = n - 1 ; while ( low < high ) { int temp = arr [ low ] ; arr [ low ] = arr [ high ] ; arr [ high ] = temp ; low ++ ; high -- ; } } static int [ ] swap ( int [ ] arr , int i , int j ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; return arr ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 5 , 8 , 9 , 6 , 7 , 3 , 4 , 2 , 0 } ; int n = arr . Length ; bitonicGenerator ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: high, i, j, low
Accumulator variables: high, i, j, low
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int numofsubset ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int count = 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] + 1 != arr [ i + 1 ] ) count ++ ; } return count ; } public static void Main ( ) { int [ ] arr = { 100 , 56 , 5 , 6 , 102 , 58 , 101 , 57 , 7 , 103 , 59 } ; int n = arr . Length ; Console . WriteLine ( numofsubset ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void gnomeSort ( int [ ] arr , int n ) { int index = 0 ; while ( index < n ) { if ( index == 0 ) index ++ ; if ( arr [ index ] >= arr [ index - 1 ] ) index ++ ; else { int temp = 0 ; temp = arr [ index ] ; arr [ index ] = arr [ index - 1 ] ; arr [ index - 1 ] = temp ; index -- ; } } return ; } public static void Main ( ) { int [ ] arr = { 34 , 2 , 10 , - 9 } ; gnomeSort ( arr , arr . Length ) ; Console . Write ( " Sorted ▁ sequence ▁ after ▁ applying ▁ Gnome ▁ sort : ▁ " ) ; for ( int i = 0 ; i < arr . Length ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: i, index
Accumulator variables: i, index
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void cocktailSort ( int [ ] a ) { bool swapped = true ; int start = 0 ; int end = a . Length ; while ( swapped == true ) { swapped = false ; for ( int i = start ; i < end - 1 ; ++ i ) { if ( a [ i ] > a [ i + 1 ] ) { int temp = a [ i ] ; a [ i ] = a [ i + 1 ] ; a [ i + 1 ] = temp ; swapped = true ; } } if ( swapped == false ) break ; swapped = false ; end = end - 1 ; for ( int i = end - 1 ; i >= start ; i -- ) { if ( a [ i ] > a [ i + 1 ] ) { int temp = a [ i ] ; a [ i ] = a [ i + 1 ] ; a [ i + 1 ] = temp ; swapped = true ; } } start = start + 1 ; } } static void printArray ( int [ ] a ) { int n = a . Length ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( a [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; } public static void Main ( ) { int [ ] a = { 5 , 1 , 4 , 2 , 8 , 0 , 2 } ; cocktailSort ( a ) ; Console . WriteLine ( " Sorted ▁ array ▁ " ) ; printArray ( a ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: swapped
Class/struct names: GFG
C# program:
using System ; class GFG { static void findMaxGuests ( int [ ] arrl , int [ ] exit , int n ) { Array . Sort ( arrl ) ; Array . Sort ( exit ) ; int guests_in = 1 , max_guests = 1 , time = arrl [ 0 ] ; int i = 1 , j = 0 ; while ( i < n && j < n ) { if ( arrl [ i ] <= exit [ j ] ) { guests_in ++ ; if ( guests_in > max_guests ) { max_guests = guests_in ; time = arrl [ i ] ; } i ++ ; } else { guests_in -- ; j ++ ; } } Console . Write ( " Maximum ▁ Number ▁ of ▁ Guests ▁ = ▁ " + max_guests + " ▁ at ▁ time ▁ " + time ) ; } public static void Main ( ) { int [ ] arrl = { 1 , 2 , 10 , 5 , 5 } ; int [ ] exit = { 4 , 5 , 12 , 9 , 12 } ; int n = arrl . Length ; findMaxGuests ( arrl , exit , n ) ; } }

Index/key variables: i, j
Accumulator variables: guests_in, i, j
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { public static void maxOverlap ( int [ ] start , int [ ] end , int n ) { int maxa = start . Max ( ) ; int maxb = end . Max ( ) ; int maxc = Math . Max ( maxa , maxb ) ; int [ ] x = new int [ maxc + 2 ] ; int cur = 0 , idx = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ++ x [ start [ i ] ] ; -- x [ end [ i ] + 1 ] ; } int maxy = int . MinValue ; for ( int i = 0 ; i <= maxc ; i ++ ) { cur += x [ i ] ; if ( maxy < cur ) { maxy = cur ; idx = i ; } } Console . WriteLine ( " Maximum ▁ value ▁ is ▁ " + maxy + " ▁ at ▁ position : ▁ " + idx + " " ) ; } public static void Main ( ) { int [ ] start = { 13 , 28 , 29 , 14 , 40 , 17 , 3 } ; int [ ] end = { 107 , 95 , 111 , 105 , 70 , 127 , 74 } ; int n = start . Length ; maxOverlap ( start , end , n ) ; } }

Index/key variables: i
Accumulator variables: cur, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class RearrangeArray { void rearrangeNaive ( int [ ] arr , int n ) { int [ ] temp = new int [ n ] ; int i ; for ( i = 0 ; i < n ; i ++ ) temp [ arr [ i ] ] = i ; for ( i = 0 ; i < n ; i ++ ) arr [ i ] = temp [ i ] ; } void printArray ( int [ ] arr , int n ) { int i ; for ( i = 0 ; i < n ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } Console . WriteLine ( " " ) ; } public static void Main ( ) { RearrangeArray arrange = new RearrangeArray ( ) ; int [ ] arr = { 1 , 3 , 0 , 2 } ; int n = arr . Length ; Console . WriteLine ( " Given ▁ array ▁ is ▁ " ) ; arrange . printArray ( arr , n ) ; arrange . rearrangeNaive ( arr , n ) ; Console . WriteLine ( " Modified ▁ array ▁ is ▁ " ) ; arrange . printArray ( arr , n ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: RearrangeArray
C# program:
using System ; class GFG { static void rearrange ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) { arr [ arr [ i ] % n ] += i * n ; } for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] /= n ; } } static void printArray ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; } static public void Main ( ) { int [ ] arr = { 2 , 0 , 1 , 4 , 5 , 3 } ; int n = arr . Length ; Console . WriteLine ( " Given ▁ array ▁ is ▁ : ▁ " ) ; printArray ( arr , n ) ; rearrange ( arr , n ) ; Console . WriteLine ( " Modified ▁ array ▁ is ▁ : " ) ; printArray ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void rearrage ( int [ ] arr , int n ) { int [ ] temp = new int [ n ] ; int small = 0 , large = n - 1 ; bool flag = true ; for ( int i = 0 ; i < n ; i ++ ) { if ( flag ) temp [ i ] = arr [ large -- ] ; else temp [ i ] = arr [ small ++ ] ; flag = ! flag ; } for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = temp [ i ] ; } static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 } ; Console . WriteLine ( " Original ▁ Array " ) ; for ( int i = 0 ; i < arr . Length ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; rearrage ( arr , arr . Length ) ; Console . WriteLine ( " STRNEWLINE Modified ▁ Array " ) ; for ( int i = 0 ; i < arr . Length ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: i, n
Accumulator variables: i, large, small
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; public class GFG { static int minimumcoins ( int [ ] arr , int N ) { int coins = 0 ; int j = 0 ; if ( arr [ 0 ] == 1 ) coins ++ ; for ( int i = 1 ; i < N ; i ++ ) { if ( arr [ i ] == 2 ) continue ; j = i ; while ( j < N && arr [ j ] == 1 ) { j ++ ; } int x = ( j - i ) ; coins += x / 3 ; i = j - 1 ; } return coins ; } public static void Main ( String [ ] args ) { int N = 8 ; int [ ] arr = { 1 , 2 , 1 , 1 , 2 , 1 , 1 , 1 } ; Console . WriteLine ( minimumcoins ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: coins, i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class main { public static void rearrange ( int [ ] arr , int n ) { int max_idx = n - 1 , min_idx = 0 ; int max_elem = arr [ n - 1 ] + 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) { arr [ i ] += ( arr [ max_idx ] % max_elem ) * max_elem ; max_idx -- ; } else { arr [ i ] += ( arr [ min_idx ] % max_elem ) * max_elem ; min_idx ++ ; } } for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = arr [ i ] / max_elem ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; int n = arr . Length ; Console . WriteLine ( " Original ▁ Array " ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; rearrange ( arr , n ) ; Console . WriteLine ( " Modified ▁ Array " ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: i, max_idx, min_idx
Accumulator variables: i, max_idx, min_idx
Iterator variables: i
Class/struct names: main
C# program:
using System ; class GFG { public static void rearrange ( int [ ] arr , int n ) { int max_ele = arr [ n - 1 ] ; int min_ele = arr [ 0 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) { arr [ i ] = max_ele ; max_ele -= 1 ; } else { arr [ i ] = min_ele ; min_ele += 1 ; } } } static public void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; int n = arr . Length ; Console . WriteLine ( " Original ▁ Array " ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; rearrange ( arr , n ) ; Console . Write ( " STRNEWLINE Modified ▁ Array STRNEWLINE " ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: i
Accumulator variables: i, max_ele, min_ele
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } public class BinaryTree { public Node root ; public virtual bool isLeaf ( Node node ) { if ( node == null ) { return false ; } if ( node . left == null && node . right == null ) { return true ; } return false ; } public virtual int leftLeavesSum ( Node node ) { int res = 0 ; if ( node != null ) { if ( isLeaf ( node . left ) ) { res += node . left . data ; } else { res += leftLeavesSum ( node . left ) ; } res += leftLeavesSum ( node . right ) ; } return res ; } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 20 ) ; tree . root . left = new Node ( 9 ) ; tree . root . right = new Node ( 49 ) ; tree . root . left . right = new Node ( 12 ) ; tree . root . left . left = new Node ( 5 ) ; tree . root . right . left = new Node ( 23 ) ; tree . root . right . right = new Node ( 52 ) ; tree . root . left . right . right = new Node ( 12 ) ; tree . root . right . right . left = new Node ( 50 ) ; Console . WriteLine ( " The ▁ sum ▁ of ▁ leaves ▁ is ▁ " + tree . leftLeavesSum ( tree . root ) ) ; } }

Accumulator variables: res
Class/struct names: BinaryTree, Node