dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static void maxModProdSubarr ( int [ ] arr , int n , int M ) { int ans = 0 ; int length = n ; for ( int i = 0 ; i < n ; i ++ ) { int product = 1 ; for ( int j = i ; j < n ; j ++ ) { product = ( product * arr [ i ] ) % M ; if ( product > ans ) { ans = product ; if ( length > j - i + 1 ) { length = j - i + 1 ; } } } } Console . WriteLine ( " Maximum ▁ subarray ▁ product ▁ is ▁ " + ans ) ; Console . WriteLine ( " Minimum ▁ length ▁ of ▁ the ▁ maximum ▁ " + " product ▁ subarray ▁ is ▁ " + length ) ; } static void Main ( ) { int [ ] arr = { 2 , 3 , 4 , 2 } ; int N = arr . Length ; int M = 5 ; maxModProdSubarr ( arr , N , M ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int GCD ( int a , int b ) { return b == 0 ? a : GCD ( b , a % b ) ; } static bool coprime ( int a , int b ) { if ( GCD ( a , b ) == 1 ) return true ; return false ; } static int numOfPairs ( List < string > arr , int N ) { int count = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { if ( coprime ( Int32 . Parse ( arr [ i ] ) , Int32 . Parse ( arr [ j ] ) ) ) { count = count + 1 ; } } } return count ; } static void noOfCoPrimePairs ( int N , int d1 , int d2 ) { List < string > l = new List < string > ( ) ; l . Add ( d1 . ToString ( ) ) ; l . Add ( d2 . ToString ( ) ) ; l . Sort ( ) ; if ( N < Int32 . Parse ( l [ 1 ] ) ) return ; List < string > total = new List < string > ( l ) ; List < string > temp2 = new List < string > ( l ) ; int flag = 0 ; List < string > temp3 = new List < string > ( ) ; while ( l [ 0 ] . Length < 10 ) { for ( int i = 0 ; i < l . Count ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { if ( Int32 . Parse ( l [ i ] + temp2 [ j ] ) > N ) { flag = 1 ; break ; } total . Add ( l [ i ] + temp2 [ j ] ) ; temp3 . Add ( l [ i ] + temp2 [ j ] ) ; } if ( flag == 1 ) break ; } if ( flag == 1 ) break ; l = temp3 ; temp3 . Clear ( ) ; } int lenOfTotal = total . Count ; int ans = numOfPairs ( total , lenOfTotal ) ; Console . WriteLine ( ans ) ; } public static void Main ( ) { int N = 30 , d1 = 2 , d2 = 3 ; noOfCoPrimePairs ( N , d1 , d2 ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void tile_placing ( int [ , ] grid , int N ) { int [ ] dp = new int [ N + 5 ] ; for ( int i = 0 ; i < N + 5 ; i ++ ) { dp [ i ] = 0 ; } int orig_cost = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { orig_cost += grid [ i , j ] ; } } dp [ 0 ] = 0 ; dp [ 1 ] = Math . Abs ( grid [ 0 , 0 ] - grid [ 1 , 0 ] ) ; for ( int i = 2 ; i <= N ; i ++ ) { dp [ i ] = Math . Max ( dp [ i - 1 ] + Math . Abs ( grid [ 0 , i - 1 ] - grid [ 1 , i - 1 ] ) , dp [ i - 2 ] + Math . Abs ( grid [ 0 , i - 2 ] - grid [ 0 , i - 1 ] ) + Math . Abs ( grid [ 1 , i - 2 ] - grid [ 1 , i - 1 ] ) ) ; } Console . Write ( orig_cost - dp [ N ] ) ; } public static void Main ( ) { int [ , ] M = { { 7 , 5 , 1 , 3 } , { 8 , 6 , 0 , 2 } } ; int N = 4 ; tile_placing ( M , N ) ; } }

Index/key variables: N, i
Accumulator variables: i, j, orig_cost
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void findSplit ( int [ ] arr , int N ) { for ( int l = 1 ; l <= N - 4 ; l ++ ) { for ( int r = l + 2 ; r <= N - 2 ; r ++ ) { int lsum = 0 , rsum = 0 , msum = 0 ; for ( int i = 0 ; i <= l - 1 ; i ++ ) { lsum += arr [ i ] ; } for ( int i = l + 1 ; i <= r - 1 ; i ++ ) { msum += arr [ i ] ; } for ( int i = r + 1 ; i < N ; i ++ ) { rsum += arr [ i ] ; } if ( lsum == rsum && rsum == msum ) { Console . WriteLine ( l + " ▁ " + r ) ; return ; } } } Console . Write ( - 1 ) ; } 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: i
Accumulator variables: i, l, lsum, msum, r, rsum
Iterator variables: i, l, r
Class/struct names: GFG
C# program:
using System ; class GFG { static int solve ( int [ ] A , int n , int [ ] Q , int q ) { int one = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( A [ i ] == 1 ) one ++ ; int glows = 0 , count = 0 ; if ( one >= ( int ) Math . Ceiling ( ( double ) n / 2 ) ) glows = 1 ; for ( int i = 0 ; i < q ; i ++ ) { int prev = glows ; if ( A [ Q [ i ] - 1 ] == 1 ) one -- ; if ( A [ Q [ i ] - 1 ] == 0 ) one ++ ; A [ Q [ i ] - 1 ] ^= 1 ; if ( one >= ( int ) Math . Ceiling ( ( double ) n / 2.0 ) ) { glows = 1 ; } else { glows = 0 ; } if ( prev != glows ) count ++ ; } return count ; } static public void Main ( ) { int n = 3 ; int [ ] arr = { 1 , 1 , 0 } ; int q = 3 ; int [ ] Q = { 3 , 2 , 1 } ; Console . WriteLine ( solve ( arr , n , Q , q ) ) ; } }

Index/key variables: i
Accumulator variables: count, i, one
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int sumOfDigits ( int N ) { int sum = 0 ; while ( N != 0 ) { sum += N % 10 ; N /= 10 ; } return sum ; } static void elementsHavingDigitSumK ( int [ ] arr , int N , int K ) { int count = 0 ; for ( int i = 0 ; i < N ; ++ i ) { if ( sumOfDigits ( arr [ i ] ) == K ) { count ++ ; } } Console . WriteLine ( count ) ; } static void Main ( ) { int [ ] arr = { 23 , 54 , 87 , 29 , 92 , 62 } ; int K = 11 ; int N = arr . Length ; elementsHavingDigitSumK ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: N, count, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static Boolean isOperand ( char x ) { return ( x >= ' a ' && x <= ' z ' ) || ( x >= ' A ' && x <= ' Z ' ) ; } static String getInfix ( String exp ) { Stack s = new Stack ( ) ; for ( int i = 0 ; i < exp . Length ; i ++ ) { if ( isOperand ( exp [ i ] ) ) { s . Push ( exp [ i ] + " " ) ; } else { String op1 = ( String ) s . Peek ( ) ; s . Pop ( ) ; String op2 = ( String ) s . Peek ( ) ; s . Pop ( ) ; s . Push ( " ( " + op2 + exp [ i ] + op1 + " ) " ) ; } } return ( String ) s . Peek ( ) ; } public static void Main ( String [ ] args ) { String exp = " ab * c + " ; Console . WriteLine ( getInfix ( exp ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GfG { class node { public int data ; public node left , right ; } static int updatetree ( node root ) { if ( root == null ) return 0 ; if ( root . left == null && root . right == null ) return root . data ; int leftsum = updatetree ( root . left ) ; int rightsum = updatetree ( root . right ) ; root . data += leftsum ; return root . data + rightsum ; } static void inorder ( node node ) { if ( node == null ) return ; inorder ( node . left ) ; Console . Write ( node . data + " ▁ " ) ; inorder ( node . right ) ; } static node newNode ( int data ) { node node = new node ( ) ; node . data = data ; node . left = null ; node . right = null ; return ( node ) ; } public static void Main ( ) { 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 ) ; updatetree ( root ) ; Console . WriteLine ( " Inorder ▁ traversal ▁ of ▁ the ▁ modified ▁ tree ▁ is " ) ; inorder ( root ) ; } }

Accumulator variables: data
Class/struct names: GfG, node
C# program:
using System ; class GFG { static void calculateSpan ( int [ ] price , int n , int [ ] S ) { S [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { S [ i ] = 1 ; for ( int j = i - 1 ; ( j >= 0 ) && ( price [ i ] >= price [ j ] ) ; j -- ) S [ i ] ++ ; } } static void printArray ( int [ ] arr ) { string result = string . Join ( " ▁ " , arr ) ; Console . WriteLine ( result ) ; } public static void Main ( ) { int [ ] price = { 10 , 4 , 5 , 90 , 120 , 80 } ; int n = price . Length ; int [ ] S = new int [ n ] ; calculateSpan ( price , n , S ) ; printArray ( S ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static void calculateSpan ( int [ ] price , int n , int [ ] S ) { Stack st = new Stack ( ) ; st . Push ( 0 ) ; S [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { while ( st . Count > 0 && price [ ( int ) st . Peek ( ) ] <= price [ i ] ) st . Pop ( ) ; S [ i ] = ( st . Count == 0 ) ? ( i + 1 ) : ( i - ( int ) st . Peek ( ) ) ; st . Push ( i ) ; } } static void printArray ( int [ ] arr ) { for ( int i = 0 ; i < arr . Length ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] price = { 10 , 4 , 5 , 90 , 120 , 80 } ; int n = price . Length ; int [ ] S = new int [ n ] ; calculateSpan ( price , n , S ) ; printArray ( S ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void calculateSpan ( int [ ] A , int n , int [ ] ans ) { ans [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { int counter = 1 ; while ( ( i - counter ) >= 0 && A [ i ] >= A [ i - counter ] ) { counter += ans [ i - counter ] ; } ans [ i ] = counter ; } } static void printArray ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] price = { 10 , 4 , 5 , 90 , 120 , 80 } ; int n = price . Length ; int [ ] S = new int [ n ] ; calculateSpan ( price , n , S ) ; printArray ( S , n ) ; } }

Index/key variables: i, n
Accumulator variables: counter, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printNGE ( int [ ] arr , int n ) { int next , i , j ; for ( i = 0 ; i < n ; i ++ ) { next = - 1 ; for ( j = i + 1 ; j < n ; j ++ ) { if ( arr [ i ] < arr [ j ] ) { next = arr [ j ] ; break ; } } Console . WriteLine ( arr [ i ] + " ▁ - - ▁ " + next ) ; } } public static void Main ( ) { int [ ] arr = { 11 , 13 , 21 , 3 } ; int n = arr . Length ; printNGE ( arr , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
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 ; } } class GFG { public Node root ; public virtual void mirror ( ) { root = mirror ( root ) ; } public virtual Node mirror ( Node node ) { if ( node == null ) { return node ; } Node left = mirror ( node . left ) ; Node right = mirror ( node . right ) ; node . left = right ; node . right = left ; return node ; } public virtual void inOrder ( ) { inOrder ( root ) ; } public virtual void inOrder ( Node node ) { if ( node == null ) { return ; } inOrder ( node . left ) ; Console . Write ( node . data + " ▁ " ) ; inOrder ( node . right ) ; } public static void Main ( string [ ] args ) { GFG tree = new GFG ( ) ; 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 ) ; Console . WriteLine ( " Inorder ▁ traversal ▁ " + " of ▁ input ▁ tree ▁ is ▁ : " ) ; tree . inOrder ( ) ; Console . WriteLine ( " " ) ; tree . mirror ( ) ; Console . WriteLine ( " Inorder ▁ traversal ▁ " + " of ▁ binary ▁ tree ▁ is ▁ : ▁ " ) ; tree . inOrder ( ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; using System . Collections ; class GFG { static void fillNext ( int [ ] next , int [ ] a , int n ) { Stack s = new Stack ( ) ; s . Push ( 0 ) ; for ( int i = 1 ; i < n ; i ++ ) { while ( s . Count > 0 ) { int cur = ( int ) s . Peek ( ) ; if ( a [ cur ] < a [ i ] ) { next [ cur ] = i ; s . Pop ( ) ; } else break ; } s . Push ( i ) ; } while ( s . Count > 0 ) { int cur = ( int ) s . Peek ( ) ; next [ cur ] = - 1 ; s . Pop ( ) ; } } static void count ( int [ ] a , int [ ] dp , int n ) { int [ ] next = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) next [ i ] = 0 ; fillNext ( next , a , n ) ; for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( next [ i ] == - 1 ) dp [ i ] = 0 ; else dp [ i ] = 1 + dp [ next [ i ] ] ; } } static int answerQuery ( int [ ] dp , int index ) { return dp [ index ] ; } public static void Main ( String [ ] args ) { int [ ] a = { 3 , 4 , 2 , 7 , 5 , 8 , 10 , 6 } ; int n = a . Length ; int [ ] dp = new int [ n ] ; count ( a , dp , n ) ; Console . WriteLine ( answerQuery ( dp , 3 ) ) ; Console . WriteLine ( answerQuery ( dp , 6 ) ) ; Console . WriteLine ( answerQuery ( dp , 1 ) ) ; } }

Index/key variables: cur, i, index, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static List < int > no_NGN ( int [ ] arr , int n ) { List < int > nxt = new List < int > ( ) ; Stack < int > s = new Stack < int > ( ) ; nxt . Add ( 0 ) ; s . Push ( n - 1 ) ; for ( int i = n - 2 ; i >= 0 ; i -- ) { while ( s . Count != 0 && arr [ i ] >= arr [ s . Peek ( ) ] ) s . Pop ( ) ; if ( s . Count == 0 ) nxt . Add ( 0 ) ; else nxt . Add ( nxt [ n - s . Peek ( ) - 1 ] + 1 ) ; s . Push ( i ) ; } nxt . Reverse ( ) ; return nxt ; } public static void Main ( String [ ] args ) { int n = 8 ; int [ ] arr = { 3 , 4 , 2 , 7 , 5 , 8 , 10 , 6 } ; List < int > nxt = no_NGN ( arr , n ) ; Console . Write ( nxt [ 3 ] + " STRNEWLINE " ) ; Console . Write ( nxt [ 6 ] + " STRNEWLINE " ) ; Console . Write ( nxt [ 1 ] + " STRNEWLINE " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MAX = 1000 ; static int [ ] nextGreaterInLeft ( int [ ] a , int n ) { int [ ] left_index = new int [ MAX ] ; Stack < int > s = new Stack < int > ( ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { while ( s . Count != 0 && a [ i ] > a [ s . Peek ( ) - 1 ] ) { int r = s . Peek ( ) ; s . Pop ( ) ; left_index [ r - 1 ] = i + 1 ; } s . Push ( i + 1 ) ; } return left_index ; } static int [ ] nextGreaterInRight ( int [ ] a , int n ) { int [ ] right_index = new int [ MAX ] ; Stack < int > s = new Stack < int > ( ) ; for ( int i = 0 ; i < n ; ++ i ) { while ( s . Count != 0 && a [ i ] > a [ s . Peek ( ) - 1 ] ) { int r = s . Peek ( ) ; s . Pop ( ) ; right_index [ r - 1 ] = i + 1 ; } s . Push ( i + 1 ) ; } return right_index ; } static int LRProduct ( int [ ] arr , int n ) { int [ ] left = nextGreaterInLeft ( arr , n ) ; int [ ] right = nextGreaterInRight ( arr , n ) ; int ans = - 1 ; for ( int i = 1 ; i <= n ; i ++ ) { ans = Math . Max ( ans , left [ i ] * right [ i ] ) ; } return ans ; } static void Main ( ) { int [ ] arr = new int [ ] { 5 , 4 , 3 , 4 , 5 } ; int n = arr . Length ; Console . Write ( LRProduct ( arr , n ) ) ; } }

Index/key variables: MAX, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static readonly int N = 8 ; static int [ , ] MATRIX = { { 0 , 0 , 1 , 0 } , { 0 , 0 , 1 , 0 } , { 0 , 0 , 0 , 0 } , { 0 , 0 , 1 , 0 } } ; static int knows ( int a , int b ) { return MATRIX [ a , b ] ; } static int findCelebrity ( int n ) { int [ ] indegree = new int [ n ] ; int [ ] outdegree = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { int x = knows ( i , j ) ; outdegree [ i ] += x ; indegree [ j ] += x ; } } for ( int i = 0 ; i < n ; i ++ ) if ( indegree [ i ] == n - 1 && outdegree [ i ] == 0 ) return i ; return - 1 ; } public static void Main ( String [ ] args ) { int n = 4 ; int id = findCelebrity ( n ) ; if ( id == - 1 ) Console . Write ( " No ▁ celebrity " ) ; else Console . Write ( " Celebrity ▁ ID ▁ " + id ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Text ; public class EvaluateString { public static bool hasPrecedence ( char op1 , char op2 ) { if ( op2 == ' ( ' op2 == ' ) ' ) { return false ; } if ( ( op1 == ' * ' op1 == ' / ' ) && ( op2 == ' + ' op2 == ' - ' ) ) { return false ; } else { return true ; } } public static int applyOp ( char op , int b , int a ) { switch ( op ) { case ' + ' : return a + b ; case ' - ' : return a - b ; case ' * ' : return a * b ; case ' / ' : if ( b == 0 ) { throw new System . NotSupportedException ( " Cannot ▁ divide ▁ by ▁ zero " ) ; } return a / b ; } return 0 ; } public static int evaluate ( string expression ) { char [ ] tokens = expression . ToCharArray ( ) ; Stack < int > values = new Stack < int > ( ) ; Stack < char > ops = new Stack < char > ( ) ; for ( int i = 0 ; i < tokens . Length ; i ++ ) { if ( tokens [ i ] == ' ▁ ' ) { continue ; } else if ( tokens [ i ] == ' ( ' ) { ops . Push ( tokens [ i ] ) ; } if ( tokens [ i ] >= '0' && tokens [ i ] <= '9' ) { StringBuilder sbuf = new StringBuilder ( ) ; while ( i < tokens . Length && tokens [ i ] >= '0' && tokens [ i ] <= '9' ) { sbuf . Append ( tokens [ i ++ ] ) ; } values . Push ( int . Parse ( sbuf . ToString ( ) ) ) ; i -- ; } else if ( tokens [ i ] == ' ) ' ) { while ( ops . Peek ( ) != ' ( ' ) { values . Push ( applyOp ( ops . Pop ( ) , values . Pop ( ) , values . Pop ( ) ) ) ; } ops . Pop ( ) ; } else if ( tokens [ i ] == ' + ' tokens [ i ] == ' - ' tokens [ i ] == ' * ' tokens [ i ] == ' / ' ) { while ( ops . Count > 0 && hasPrecedence ( tokens [ i ] , ops . Peek ( ) ) ) { values . Push ( applyOp ( ops . Pop ( ) , values . Pop ( ) , values . Pop ( ) ) ) ; } ops . Push ( tokens [ i ] ) ; } } while ( ops . Count > 0 ) { values . Push ( applyOp ( ops . Pop ( ) , values . Pop ( ) , values . Pop ( ) ) ) ; } return values . Pop ( ) ; } public static void Main ( string [ ] args ) { Console . WriteLine ( EvaluateString . evaluate ( "10 ▁ + ▁ 2 ▁ * ▁ 6" ) ) ; Console . WriteLine ( EvaluateString . evaluate ( "100 ▁ * ▁ 2 ▁ + ▁ 12" ) ) ; Console . WriteLine ( EvaluateString . evaluate ( "100 ▁ * ▁ ( ▁ 2 ▁ + ▁ 12 ▁ ) " ) ) ; Console . WriteLine ( EvaluateString . evaluate ( "100 ▁ * ▁ ( ▁ 2 ▁ + ▁ 12 ▁ ) ▁ / ▁ 14" ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: EvaluateString
C# program:
using System . Collections . Generic ; using System ; class GFG { public class Node { public int data ; public Node left ; public Node right ; } ; static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = node . right = null ; return ( node ) ; } static void mirror ( Node root ) { if ( root == null ) return ; Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( root ) ; while ( q . Count > 0 ) { Node curr = q . Peek ( ) ; q . Dequeue ( ) ; Node temp = curr . left ; curr . left = curr . right ; curr . right = temp ; ; if ( curr . left != null ) q . Enqueue ( curr . left ) ; if ( curr . right != null ) q . Enqueue ( curr . right ) ; } } static void inOrder ( Node node ) { if ( node == null ) return ; inOrder ( node . left ) ; Console . Write ( node . data + " ▁ " ) ; inOrder ( node . 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 ) ; Console . Write ( " STRNEWLINE ▁ Inorder ▁ traversal ▁ of ▁ the " + " ▁ coned ▁ tree ▁ is ▁ STRNEWLINE " ) ; inOrder ( root ) ; mirror ( root ) ; Console . Write ( " STRNEWLINE ▁ Inorder ▁ traversal ▁ of ▁ the ▁ " + " mirror ▁ tree ▁ is ▁ STRNEWLINE " ) ; inOrder ( root ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; class GFG { public class Stack { public int capacity ; public int top ; public int [ ] array ; } Stack createStack ( int capacity ) { Stack stack = new Stack ( ) ; stack . capacity = capacity ; stack . top = - 1 ; stack . array = new int [ capacity ] ; return stack ; } Boolean isFull ( Stack stack ) { return ( stack . top == stack . capacity - 1 ) ; } Boolean isEmpty ( Stack stack ) { return ( stack . top == - 1 ) ; } void push ( Stack stack , int item ) { if ( isFull ( stack ) ) return ; stack . array [ ++ stack . top ] = item ; } int pop ( Stack stack ) { if ( isEmpty ( stack ) ) return int . MinValue ; return stack . array [ stack . top -- ] ; } void moveDisk ( char fromPeg , char toPeg , int disk ) { Console . WriteLine ( " Move ▁ the ▁ disk ▁ " + disk + " ▁ from ▁ " + fromPeg + " ▁ to ▁ " + toPeg ) ; } void moveDisksBetweenTwoPoles ( Stack src , Stack dest , char s , char d ) { int pole1TopDisk = pop ( src ) ; int pole2TopDisk = pop ( dest ) ; if ( pole1TopDisk == int . MinValue ) { push ( src , pole2TopDisk ) ; moveDisk ( d , s , pole2TopDisk ) ; } else if ( pole2TopDisk == int . MinValue ) { push ( dest , pole1TopDisk ) ; moveDisk ( s , d , pole1TopDisk ) ; } else if ( pole1TopDisk > pole2TopDisk ) { push ( src , pole1TopDisk ) ; push ( src , pole2TopDisk ) ; moveDisk ( d , s , pole2TopDisk ) ; } else { push ( dest , pole2TopDisk ) ; push ( dest , pole1TopDisk ) ; moveDisk ( s , d , pole1TopDisk ) ; } } void tohIterative ( int num_of_disks , Stack src , Stack aux , Stack dest ) { int i , total_num_of_moves ; char s = ' S ' , d = ' D ' , a = ' A ' ; if ( num_of_disks % 2 == 0 ) { char temp = d ; d = a ; a = temp ; } total_num_of_moves = ( int ) ( Math . Pow ( 2 , num_of_disks ) - 1 ) ; for ( i = num_of_disks ; i >= 1 ; i -- ) push ( src , i ) ; for ( i = 1 ; i <= total_num_of_moves ; i ++ ) { if ( i % 3 == 1 ) moveDisksBetweenTwoPoles ( src , dest , s , d ) ; else if ( i % 3 == 2 ) moveDisksBetweenTwoPoles ( src , aux , s , a ) ; else if ( i % 3 == 0 ) moveDisksBetweenTwoPoles ( aux , dest , a , d ) ; } } public static void Main ( String [ ] args ) { int num_of_disks = 3 ; GFG ob = new GFG ( ) ; Stack src , dest , aux ; src = ob . createStack ( num_of_disks ) ; dest = ob . createStack ( num_of_disks ) ; aux = ob . createStack ( num_of_disks ) ; ob . tohIterative ( num_of_disks , src , aux , dest ) ; } }

Index/key variables: capacity
Accumulator variables: i, top
Iterator variables: i
Class/struct names: GFG, Stack
C# program:
using System ; using System . Collections . Generic ; class GFG { static void deleteMid ( Stack < char > st , int n , int curr = 0 ) { if ( st . Count == 0 curr == n ) return ; char x = st . Peek ( ) ; st . Pop ( ) ; deleteMid ( st , n , curr + 1 ) ; if ( curr != n / 2 ) st . Push ( x ) ; } public static void Main ( ) { Stack < char > st = new Stack < char > ( ) ; st . Push ( '1' ) ; st . Push ( '2' ) ; st . Push ( '3' ) ; st . Push ( '4' ) ; st . Push ( '5' ) ; st . Push ( '6' ) ; st . Push ( '7' ) ; deleteMid ( st , st . Count ) ; while ( st . Count != 0 ) { char p = st . Peek ( ) ; st . Pop ( ) ; Console . Write ( p + " ▁ " ) ; } } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static Stack < int > sortStack ( Stack < int > input ) { Stack < int > tmpStack = new Stack < int > ( ) ; while ( input . Count != 0 ) { int tmp = input . Peek ( ) ; input . Pop ( ) ; while ( tmpStack . Count != 0 && tmpStack . Peek ( ) < tmp ) { input . Push ( tmpStack . Peek ( ) ) ; tmpStack . Pop ( ) ; } tmpStack . Push ( tmp ) ; } return tmpStack ; } static void sortArrayUsingStacks ( int [ ] arr , int n ) { Stack < int > input = new Stack < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) input . Push ( arr [ i ] ) ; Stack < int > tmpStack = sortStack ( input ) ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = tmpStack . Peek ( ) ; tmpStack . Pop ( ) ; } } static void Main ( ) { int [ ] arr = new int [ ] { 10 , 5 , 15 , 45 } ; int n = arr . Length ; sortArrayUsingStacks ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG