dhyuti-n/xlcost-variable-roles huggingface dataset:
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 convertTree ( Node node ) { int left_data = 0 , right_data = 0 , diff ; if ( node == null || ( node . left == null && node . right == null ) ) { return ; } else { convertTree ( node . left ) ; convertTree ( node . right ) ; if ( node . left != null ) { left_data = node . left . data ; } if ( node . right != null ) { right_data = node . right . data ; } diff = left_data + right_data - node . data ; if ( diff > 0 ) { node . data = node . data + diff ; } if ( diff < 0 ) { increment ( node , - diff ) ; } } } public virtual void increment ( Node node , int diff ) { if ( node . left != null ) { node . left . data = node . left . data + diff ; increment ( node . left , diff ) ; } else if ( node . right != null ) { node . right . data = node . right . data + diff ; increment ( node . right , diff ) ; } } public virtual void printInorder ( Node node ) { if ( node == null ) { return ; } printInorder ( node . left ) ; Console . Write ( node . data + " ▁ " ) ; printInorder ( node . right ) ; } public static void Main ( string [ ] args ) { GFG tree = new GFG ( ) ; tree . root = new Node ( 50 ) ; tree . root . left = new Node ( 7 ) ; tree . root . right = new Node ( 2 ) ; tree . root . left . left = new Node ( 3 ) ; tree . root . left . right = new Node ( 5 ) ; tree . root . right . left = new Node ( 1 ) ; tree . root . right . right = new Node ( 30 ) ; Console . WriteLine ( " Inorder ▁ traversal ▁ " + " before ▁ conversion ▁ is ▁ : " ) ; tree . printInorder ( tree . root ) ; tree . convertTree ( tree . root ) ; Console . WriteLine ( " " ) ; Console . WriteLine ( " Inorder ▁ traversal ▁ " + " after ▁ conversion ▁ is ▁ : " ) ; tree . printInorder ( tree . root ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; using System . Collections ; class GFG { public class Queue { public Stack s1 = new Stack ( ) ; public Stack s2 = new Stack ( ) ; public void enQueue ( int x ) { while ( s1 . Count > 0 ) { s2 . Push ( s1 . Pop ( ) ) ; s1 . Pop ( ) ; } s1 . Push ( x ) ; while ( s2 . Count > 0 ) { s1 . Push ( s2 . Pop ( ) ) ; s2 . Pop ( ) ; } } public int deQueue ( ) { if ( s1 . Count == 0 ) { Console . WriteLine ( " Q ▁ is ▁ Empty " ) ; } int x = ( int ) s1 . Peek ( ) ; s1 . Pop ( ) ; return x ; } } ; public static void Main ( ) { Queue q = new Queue ( ) ; q . enQueue ( 1 ) ; q . enQueue ( 2 ) ; q . enQueue ( 3 ) ; Console . Write ( q . deQueue ( ) + " ▁ " ) ; Console . Write ( q . deQueue ( ) + " ▁ " ) ; Console . Write ( q . deQueue ( ) ) ; } }

Class/struct names: GFG, Queue
C# program:
using System ; class GFG { public class node { public int key ; public node left , right ; public node ( int key ) { this . key = key ; this . left = null ; this . right = null ; } } public static void convert ( node root ) { if ( root == null ) { return ; } convert ( root . left ) ; convert ( root . right ) ; if ( root . left == null ) { root . left = root . right ; } else { root . left . right = root . right ; } root . right = null ; } public static void downRightTraversal ( node root ) { if ( root != null ) { Console . Write ( root . key + " ▁ " ) ; downRightTraversal ( root . right ) ; downRightTraversal ( root . left ) ; } } public static node newNode ( int key ) { node temp = new node ( 0 ) ; temp . key = key ; temp . left = null ; temp . right = null ; return temp ; } public static void Main ( string [ ] args ) { node root = new node ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . right . left = newNode ( 4 ) ; root . right . right = newNode ( 5 ) ; root . right . left . left = newNode ( 6 ) ; root . right . right . left = newNode ( 7 ) ; root . right . right . right = newNode ( 8 ) ; convert ( root ) ; Console . WriteLine ( " Traversal ▁ of ▁ the ▁ tree ▁ " + " converted ▁ to ▁ down - right ▁ form " ) ; downRightTraversal ( root ) ; } }

Class/struct names: GFG, node
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } class GFG { public Node root ; public virtual int toSumTree ( Node node ) { if ( node == null ) { return 0 ; } int old_val = node . data ; node . data = toSumTree ( node . left ) + toSumTree ( node . right ) ; return node . data + old_val ; } public virtual void printInorder ( Node node ) { if ( node == null ) { return ; } printInorder ( node . left ) ; Console . Write ( node . data + " ▁ " ) ; printInorder ( node . right ) ; } public static void Main ( string [ ] args ) { GFG tree = new GFG ( ) ; tree . root = new Node ( 10 ) ; tree . root . left = new Node ( - 2 ) ; tree . root . right = new Node ( 6 ) ; tree . root . left . left = new Node ( 8 ) ; tree . root . left . right = new Node ( - 4 ) ; tree . root . right . left = new Node ( 7 ) ; tree . root . right . right = new Node ( 5 ) ; tree . toSumTree ( tree . root ) ; Console . WriteLine ( " Inorder ▁ Traversal ▁ of ▁ " + " the ▁ resultant ▁ tree ▁ is : " ) ; tree . printInorder ( tree . root ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; public class GFG { static int findPeak ( int [ ] arr , int n ) { if ( n == 1 ) return 0 ; if ( arr [ 0 ] >= arr [ 1 ] ) return 0 ; if ( arr [ n - 1 ] >= arr [ n - 2 ] ) return n - 1 ; for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( arr [ i ] >= arr [ i - 1 ] && arr [ i ] >= arr [ i + 1 ] ) return i ; } return 0 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 3 , 20 , 4 , 1 , 0 } ; int n = arr . Length ; Console . Write ( " Index ▁ of ▁ a ▁ peak ▁ point ▁ is ▁ " + findPeak ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findPeakUtil ( int [ ] arr , int low , int high , int n ) { int mid = low + ( high - low ) / 2 ; if ( ( mid == 0 arr [ mid - 1 ] <= arr [ mid ] ) && ( mid == n - 1 arr [ mid + 1 ] <= arr [ mid ] ) ) return mid ; else if ( mid > 0 && arr [ mid - 1 ] > arr [ mid ] ) return findPeakUtil ( arr , low , ( mid - 1 ) , n ) ; else return findPeakUtil ( arr , ( mid + 1 ) , high , n ) ; } static int findPeak ( int [ ] arr , int n ) { return findPeakUtil ( arr , 0 , n - 1 , n ) ; } static public void Main ( ) { int [ ] arr = { 1 , 3 , 20 , 4 , 1 , 0 } ; int n = arr . Length ; Console . WriteLine ( " Index ▁ of ▁ a ▁ peak ▁ " + " point ▁ is ▁ " + findPeak ( arr , n ) ) ; } }

Index/key variables: mid
Class/struct names: GFG
C# program:
using System ; class GFG { static void printRepeating ( int [ ] arr , int size ) { int i , j ; Console . Write ( " Repeated ▁ Elements ▁ are ▁ : " ) ; for ( i = 0 ; i < size ; i ++ ) { for ( j = i + 1 ; j < size ; j ++ ) { if ( arr [ i ] == arr [ j ] ) Console . Write ( arr [ i ] + " ▁ " ) ; } } } public static void Main ( ) { int [ ] arr = { 4 , 2 , 4 , 5 , 2 , 3 , 1 } ; int arr_size = arr . Length ; printRepeating ( arr , arr_size ) ; } }

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 printRepeating ( int [ ] arr , int size ) { int [ ] count = new int [ size ] ; int i ; Console . Write ( " Repeated ▁ elements ▁ are : ▁ " ) ; for ( i = 0 ; i < size ; i ++ ) { if ( count [ arr [ i ] ] == 1 ) Console . Write ( arr [ i ] + " ▁ " ) ; else count [ arr [ i ] ] ++ ; } } public static void Main ( ) { int [ ] arr = { 4 , 2 , 4 , 5 , 2 , 3 , 1 } ; int arr_size = arr . Length ; printRepeating ( arr , arr_size ) ; } }

Index/key variables: i, size
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printRepeating ( int [ ] arr , int size ) { int S = 0 ; int P = 1 ; int x , y ; int D ; int n = size - 2 , i ; for ( i = 0 ; i < size ; i ++ ) { S = S + arr [ i ] ; P = P * arr [ i ] ; } S = S - n * ( n + 1 ) / 2 ; P = P / fact ( n ) ; D = ( int ) Math . Sqrt ( S * S - 4 * P ) ; x = ( D + S ) / 2 ; y = ( S - D ) / 2 ; Console . WriteLine ( " The ▁ two " + " ▁ repeating ▁ elements ▁ are ▁ : " ) ; Console . Write ( x + " ▁ " + y ) ; } static int fact ( int n ) { return ( n == 0 ) ? 1 : n * fact ( n - 1 ) ; } public static void Main ( ) { int [ ] arr = { 4 , 2 , 4 , 5 , 2 , 3 , 1 } ; int arr_size = arr . Length ; printRepeating ( arr , arr_size ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printRepeating ( int [ ] arr , int size ) { int xor = arr [ 0 ] ; int set_bit_no ; int i ; int n = size - 2 ; int x = 0 , y = 0 ; for ( i = 1 ; i < size ; i ++ ) xor ^= arr [ i ] ; for ( i = 1 ; i <= n ; i ++ ) xor ^= i ; set_bit_no = ( xor & ~ ( xor - 1 ) ) ; for ( i = 0 ; i < size ; i ++ ) { int a = arr [ i ] & set_bit_no ; if ( a != 0 ) x = x ^ arr [ i ] ; else y = y ^ arr [ i ] ; } for ( i = 1 ; i <= n ; i ++ ) { int a = i & set_bit_no ; if ( a != 0 ) x = x ^ i ; else y = y ^ i ; } Console . WriteLine ( " The ▁ two " + " ▁ reppeated ▁ elements ▁ are ▁ : " ) ; Console . Write ( x + " ▁ " + y ) ; } public static void Main ( ) { int [ ] arr = { 4 , 2 , 4 , 5 , 2 , 3 , 1 } ; int arr_size = arr . Length ; printRepeating ( arr , arr_size ) ; } }

Index/key variables: i
Accumulator variables: i, xor
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printRepeating ( int [ ] arr , int size ) { int i ; Console . Write ( " The ▁ repeating ▁ elements ▁ are ▁ : ▁ " ) ; for ( i = 0 ; i < size ; i ++ ) { if ( arr [ Math . Abs ( arr [ i ] ) ] > 0 ) arr [ Math . Abs ( arr [ i ] ) ] = - arr [ Math . Abs ( arr [ i ] ) ] ; else Console . Write ( Math . Abs ( arr [ i ] ) + " ▁ " ) ; } } public static void Main ( ) { int [ ] arr = { 4 , 2 , 4 , 5 , 2 , 3 , 1 } ; int arr_size = arr . Length ; printRepeating ( arr , arr_size ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { int subArraySum ( int [ ] arr , int n , int sum ) { int curr_sum , i , j ; for ( i = 0 ; i < n ; i ++ ) { curr_sum = arr [ i ] ; for ( j = i + 1 ; j <= n ; j ++ ) { if ( curr_sum == sum ) { int p = j - 1 ; Console . Write ( " Sum ▁ found ▁ between ▁ " + " indexes ▁ " + i + " ▁ and ▁ " + p ) ; return 1 ; } if ( curr_sum > sum j == n ) break ; curr_sum = curr_sum + arr [ j ] ; } } Console . Write ( " No ▁ subarray ▁ found " ) ; return 0 ; } public static void Main ( ) { GFG arraysum = new GFG ( ) ; int [ ] arr = { 15 , 2 , 4 , 8 , 9 , 5 , 10 , 23 } ; int n = arr . Length ; int sum = 23 ; arraysum . subArraySum ( arr , n , sum ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { int subArraySum ( int [ ] arr , int n , int sum ) { int curr_sum = arr [ 0 ] , start = 0 , i ; for ( i = 1 ; i <= n ; i ++ ) { while ( curr_sum > sum && start < i - 1 ) { curr_sum = curr_sum - arr [ start ] ; start ++ ; } if ( curr_sum == sum ) { int p = i - 1 ; Console . WriteLine ( " Sum ▁ found ▁ between ▁ " + " indexes ▁ " + start + " ▁ and ▁ " + p ) ; return 1 ; } if ( i < n ) curr_sum = curr_sum + arr [ i ] ; } Console . WriteLine ( " No ▁ subarray ▁ found " ) ; return 0 ; } public static void Main ( ) { GFG arraysum = new GFG ( ) ; int [ ] arr = new int [ ] { 15 , 2 , 4 , 8 , 9 , 5 , 10 , 23 } ; int n = arr . Length ; int sum = 23 ; arraysum . subArraySum ( arr , n , sum ) ; } }

Index/key variables: i, start
Accumulator variables: i, start
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maximum ( int a , int b , int c ) { return Math . Max ( Math . Max ( a , b ) , c ) ; } static int minimum ( int a , int b , int c ) { return Math . Min ( Math . Min ( a , b ) , c ) ; } static void smallestDifferenceTriplet ( int [ ] arr1 , int [ ] arr2 , int [ ] arr3 , int n ) { Array . Sort ( arr1 ) ; Array . Sort ( arr2 ) ; Array . Sort ( arr3 ) ; int res_min = 0 , res_max = 0 , res_mid = 0 ; int i = 0 , j = 0 , k = 0 ; int diff = 2147483647 ; while ( i < n && j < n && k < n ) { int sum = arr1 [ i ] + arr2 [ j ] + arr3 [ k ] ; int max = maximum ( arr1 [ i ] , arr2 [ j ] , arr3 [ k ] ) ; int min = minimum ( arr1 [ i ] , arr2 [ j ] , arr3 [ k ] ) ; if ( min == arr1 [ i ] ) i ++ ; else if ( min == arr2 [ j ] ) j ++ ; else k ++ ; if ( diff > ( max - min ) ) { diff = max - min ; res_max = max ; res_mid = sum - ( max + min ) ; res_min = min ; } } Console . WriteLine ( res_max + " , ▁ " + res_mid + " , ▁ " + res_min ) ; } static public void Main ( ) { int [ ] arr1 = { 5 , 2 , 8 } ; int [ ] arr2 = { 10 , 7 , 12 } ; int [ ] arr3 = { 9 , 14 , 6 } ; int n = arr1 . Length ; smallestDifferenceTriplet ( arr1 , arr2 , arr3 , n ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static bool find3Numbers ( int [ ] A , int arr_size , int sum ) { for ( int i = 0 ; i < arr_size - 2 ; i ++ ) { for ( int j = i + 1 ; j < arr_size - 1 ; j ++ ) { for ( int k = j + 1 ; k < arr_size ; k ++ ) { if ( A [ i ] + A [ j ] + A [ k ] == sum ) { Console . WriteLine ( " Triplet ▁ is ▁ " + A [ i ] + " , ▁ " + A [ j ] + " , ▁ " + A [ k ] ) ; return true ; } } } } return false ; } static public void Main ( ) { int [ ] A = { 1 , 4 , 45 , 6 , 10 , 8 } ; int sum = 22 ; int arr_size = A . Length ; find3Numbers ( A , arr_size , sum ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { bool find3Numbers ( int [ ] A , int arr_size , int sum ) { int l , r ; quickSort ( A , 0 , arr_size - 1 ) ; for ( int i = 0 ; i < arr_size - 2 ; i ++ ) { l = i + 1 ; r = arr_size - 1 ; while ( l < r ) { if ( A [ i ] + A [ l ] + A [ r ] == sum ) { Console . Write ( " Triplet ▁ is ▁ " + A [ i ] + " , ▁ " + A [ l ] + " , ▁ " + A [ r ] ) ; return true ; } else if ( A [ i ] + A [ l ] + A [ r ] < sum ) l ++ ; else r -- ; } } return false ; } int partition ( int [ ] A , int si , int ei ) { int x = A [ ei ] ; int i = ( si - 1 ) ; int j ; for ( j = si ; j <= ei - 1 ; j ++ ) { if ( A [ j ] <= x ) { i ++ ; int temp = A [ i ] ; A [ i ] = A [ j ] ; A [ j ] = temp ; } } int temp1 = A [ i + 1 ] ; A [ i + 1 ] = A [ ei ] ; A [ ei ] = temp1 ; return ( i + 1 ) ; } if ( si < ei ) { pi = partition ( A , si , ei ) ; quickSort ( A , si , pi - 1 ) ; quickSort ( A , pi + 1 , ei ) ; } } static void ( ) { = new ( ) ; int [ ] = new int [ ] { 1 , 4 , 45 , 6 , 10 , 8 } ; int sum = 22 ; int arr_size = A . Length ; triplet . find3Numbers ( A , arr_size , sum ) ; } }

Index/key variables: ei, i, j, l, r
Accumulator variables: i, j, l, r
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static bool find3Numbers ( int [ ] A , int arr_size , int sum ) { for ( int i = 0 ; i < arr_size - 2 ; i ++ ) { HashSet < int > s = new HashSet < int > ( ) ; int curr_sum = sum - A [ i ] ; for ( int j = i + 1 ; j < arr_size ; j ++ ) { if ( s . Contains ( curr_sum - A [ j ] ) ) { Console . Write ( " Triplet ▁ is ▁ { 0 } , ▁ { 1 } , ▁ { 2 } " , A [ i ] , A [ j ] , curr_sum - A [ j ] ) ; return true ; } s . Add ( A [ j ] ) ; } } return false ; } public static void Main ( ) { int [ ] A = { 1 , 4 , 45 , 6 , 10 , 8 } ; int sum = 22 ; int arr_size = A . Length ; find3Numbers ( A , arr_size , sum ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] arr = new int [ ] { 1 , 2 , 3 , 4 } ; static void subArray ( int n ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { for ( int k = i ; k <= j ; k ++ ) Console . Write ( arr [ k ] + " ▁ " ) ; Console . WriteLine ( " " ) ; } } } public static void Main ( ) { Console . WriteLine ( " All ▁ Non - empty ▁ Subarrays " ) ; subArray ( arr . Length ) ; } }

Index/key variables: k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static void printSubsequences ( int [ ] arr , int n ) { int opsize = ( int ) Math . Pow ( 2 , n ) ; for ( int counter = 1 ; counter < opsize ; counter ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( ( counter & ( 1 << j ) ) != 0 ) Console . Write ( arr [ j ] + " ▁ " ) ; } Console . WriteLine ( ) ; } } static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int n = arr . Length ; Console . WriteLine ( " All ▁ Non - empty ▁ Subsequences " ) ; printSubsequences ( arr , n ) ; } }

Index/key variables: j
Accumulator variables: counter, j
Iterator variables: counter, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void productArray ( int [ ] arr , int n ) { if ( n == 1 ) { Console . Write ( 0 ) ; return ; } int i , temp = 1 ; int [ ] prod = new int [ n ] ; for ( int j = 0 ; j < n ; j ++ ) prod [ j ] = 1 ; for ( i = 0 ; i < n ; i ++ ) { prod [ i ] = temp ; temp *= arr [ i ] ; } temp = 1 ; for ( i = n - 1 ; i >= 0 ; i -- ) { prod [ i ] *= temp ; temp *= arr [ i ] ; } for ( i = 0 ; i < n ; i ++ ) Console . Write ( prod [ i ] + " ▁ " ) ; return ; } public static void Main ( ) { int [ ] arr = { 10 , 3 , 5 , 6 , 2 } ; int n = arr . Length ; Console . WriteLine ( " The ▁ product ▁ array ▁ is ▁ : ▁ " ) ; productArray ( arr , n ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j, temp
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool areConsecutive ( int [ ] arr , int n ) { if ( n < 1 ) return false ; int min = getMin ( arr , n ) ; int max = getMax ( arr , n ) ; if ( max - min + 1 == n ) { bool [ ] visited = new bool [ n ] ; int i ; for ( i = 0 ; i < n ; i ++ ) { if ( visited [ arr [ i ] - min ] != false ) return false ; visited [ arr [ i ] - min ] = true ; } return true ; } return false ; } static int getMin ( int [ ] arr , int n ) { int min = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] < min ) min = arr [ i ] ; } return min ; } static int getMax ( int [ ] arr , int n ) { int max = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] > max ) max = arr [ i ] ; } return max ; } public static void Main ( ) { int [ ] arr = { 5 , 4 , 2 , 3 , 1 , 6 } ; int n = arr . Length ; if ( areConsecutive ( arr , n ) == true ) Console . Write ( " Array ▁ elements ▁ are " + " ▁ consecutive " ) ; else Console . Write ( " Array ▁ elements ▁ are " + " ▁ not ▁ consecutive " ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool areConsecutive ( int [ ] arr , int n ) { if ( n < 1 ) return false ; int min = getMin ( arr , n ) ; int max = getMax ( arr , n ) ; if ( max - min + 1 == n ) { int i ; for ( i = 0 ; i < n ; i ++ ) { int j ; if ( arr [ i ] < 0 ) j = - arr [ i ] - min ; else j = arr [ i ] - min ; if ( arr [ j ] > 0 ) arr [ j ] = - arr [ j ] ; else return false ; } return true ; } return false ; } static int getMin ( int [ ] arr , int n ) { int min = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] < min ) min = arr [ i ] ; } return min ; } static int getMax ( int [ ] arr , int n ) { int max = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] > max ) max = arr [ i ] ; } return max ; } public static void Main ( ) { int [ ] arr = { 5 , 4 , 2 , 3 , 1 , 6 } ; int n = arr . Length ; if ( areConsecutive ( arr , n ) == true ) Console . Write ( " Array ▁ elements ▁ " + " are ▁ consecutive " ) ; else Console . Write ( " Array ▁ elements ▁ " + " are ▁ not ▁ consecutive " ) ; } }

Index/key variables: i, j
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; namespace Complement { public class GFG { static void relativeComplement ( int [ ] arr1 , int [ ] arr2 , int n , int m ) { int i = 0 , j = 0 ; while ( i < n && j < m ) { if ( arr1 [ i ] < arr2 [ j ] ) { Console . Write ( arr1 [ i ] + " ▁ " ) ; i ++ ; } else if ( arr1 [ i ] > arr2 [ j ] ) { j ++ ; } else if ( arr1 [ i ] == arr2 [ j ] ) { i ++ ; j ++ ; } } while ( i < n ) Console . Write ( arr1 [ i ] + " ▁ " ) ; } public static void Main ( ) { int [ ] arr1 = { 3 , 6 , 10 , 12 , 15 } ; int [ ] arr2 = { 1 , 3 , 5 , 10 , 16 } ; int n = arr1 . Length ; int m = arr2 . Length ; relativeComplement ( arr1 , arr2 , n , m ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int minOps ( int [ ] arr , int n , int k ) { Array . Sort ( arr ) ; int max = arr [ arr . Length - 1 ] ; int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( max - arr [ i ] ) % k != 0 ) return - 1 ; else res += ( max - arr [ i ] ) / k ; } return res ; } public static void Main ( ) { int [ ] arr = { 21 , 33 , 9 , 45 , 63 } ; int n = arr . Length ; int k = 6 ; Console . Write ( minOps ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int solve ( int [ ] A , int [ ] B , int [ ] C ) { int i , j , k ; i = A . Length - 1 ; j = B . Length - 1 ; k = C . Length - 1 ; int min_diff , current_diff , max_term ; min_diff = Math . Abs ( Math . Max ( A [ i ] , Math . Max ( B [ j ] , C [ k ] ) ) - Math . Min ( A [ i ] , Math . Min ( B [ j ] , C [ k ] ) ) ) ; while ( i != - 1 && j != - 1 && k != - 1 ) { current_diff = Math . Abs ( Math . Max ( A [ i ] , Math . Max ( B [ j ] , C [ k ] ) ) - Math . Min ( A [ i ] , Math . Min ( B [ j ] , C [ k ] ) ) ) ; if ( current_diff < min_diff ) min_diff = current_diff ; max_term = Math . Max ( A [ i ] , Math . Max ( B [ j ] , C [ k ] ) ) ; if ( A [ i ] == max_term ) i -= 1 ; else if ( B [ j ] == max_term ) j -= 1 ; else k -= 1 ; } return min_diff ; } public static void Main ( ) { int [ ] D = { 5 , 8 , 10 , 15 } ; int [ ] E = { 6 , 9 , 15 , 78 , 89 } ; int [ ] F = { 2 , 3 , 6 , 6 , 8 , 8 , 10 } ; Console . WriteLine ( solve ( D , E , F ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; public class GFG { static int search ( int [ ] arr , int n , int x ) { int i ; for ( i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == x ) { return i ; } } return - 1 ; } public static void Main ( ) { int [ ] arr = { 1 , 10 , 30 , 15 } ; int x = 30 ; int n = arr . Length ; Console . WriteLine ( x + " ▁ is ▁ present ▁ at ▁ index ▁ " + search ( arr , n , x ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int binarySearch ( int [ ] arr , int l , int r , int x ) { if ( r >= l ) { int mid = l + ( r - l ) / 2 ; if ( arr [ mid ] == x ) return mid ; if ( arr [ mid ] > x ) return binarySearch ( arr , l , mid - 1 , x ) ; return binarySearch ( arr , mid + 1 , r , x ) ; } return - 1 ; } public static void Main ( ) { int [ ] arr = { 2 , 3 , 4 , 10 , 40 } ; int n = arr . Length ; int x = 10 ; int result = binarySearch ( arr , 0 , n - 1 , x ) ; if ( result == - 1 ) Console . WriteLine ( " Element ▁ not ▁ present " ) ; else Console . WriteLine ( " Element ▁ found ▁ at ▁ index ▁ " + result ) ; } }

Index/key variables: mid
Class/struct names: GFG
C# program:
using System ; class GFG { static int binarySearch ( int [ ] arr , int x ) { int l = 0 , r = arr . Length - 1 ; while ( l <= r ) { int m = l + ( r - l ) / 2 ; if ( arr [ m ] == x ) return m ; if ( arr [ m ] < x ) l = m + 1 ; else r = m - 1 ; } return - 1 ; } public static void Main ( ) { int [ ] arr = { 2 , 3 , 4 , 10 , 40 } ; int n = arr . Length ; int x = 10 ; int result = binarySearch ( arr , x ) ; if ( result == - 1 ) Console . WriteLine ( " Element ▁ not ▁ present " ) ; else Console . WriteLine ( " Element ▁ found ▁ at ▁ " + " index ▁ " + result ) ; } }

Index/key variables: m
Class/struct names: GFG