dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int minDistance ( int [ ] arr , int n ) { int maximum_element = arr [ 0 ] ; int min_dis = n ; int index = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( maximum_element == arr [ i ] ) { min_dis = Math . Min ( min_dis , ( i - index ) ) ; index = i ; } else if ( maximum_element < arr [ i ] ) { maximum_element = arr [ i ] ; min_dis = n ; index = i ; } else continue ; } return min_dis ; } public static void Main ( ) { int [ ] arr = { 6 , 3 , 1 , 3 , 6 , 4 , 6 } ; int n = arr . Length ; Console . WriteLine ( " Minimum ▁ distance ▁ = ▁ " + minDistance ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findValue ( int [ ] arr , int n , int k ) { for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] == k ) k *= 2 ; return k ; } public static void Main ( ) { int [ ] arr = { 2 , 3 , 4 , 10 , 8 , 1 } ; int k = 2 ; int n = arr . Length ; Console . WriteLine ( findValue ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i, k
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void dupLastIndex ( int [ ] arr , int n ) { if ( arr == null n <= 0 ) return ; for ( int i = n - 1 ; i > 0 ; i -- ) { if ( arr [ i ] == arr [ i - 1 ] ) { Console . WriteLine ( " Last ▁ index : " + i ) ; Console . WriteLine ( " Last ▁ duplicate ▁ item : ▁ " + arr [ i ] ) ; return ; } } Console . WriteLine ( " no ▁ duplicate ▁ found " ) ; } public static void Main ( ) { int [ ] arr = { 1 , 5 , 5 , 6 , 6 , 7 , 9 } ; int n = arr . Length ; dupLastIndex ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findSmallest ( int [ ] a , int n ) { for ( int i = 0 ; i < n ; i ++ ) { int j ; for ( j = 0 ; j < n ; j ++ ) if ( a [ j ] % a [ i ] >= 1 ) break ; if ( j == n ) return a [ i ] ; } return - 1 ; } public static void Main ( ) { int [ ] a = { 25 , 20 , 5 , 10 , 100 } ; int n = a . Length ; Console . WriteLine ( findSmallest ( a , n ) ) ; } }

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 min_element ( int [ ] a ) { int min = int . MaxValue ; int i ; for ( i = 0 ; i < a . Length ; i ++ ) { if ( a [ i ] < min ) min = a [ i ] ; } return min ; } static int findSmallest ( int [ ] a , int n ) { int smallest = min_element ( a ) ; for ( int i = 1 ; i < n ; i ++ ) if ( a [ i ] % smallest >= 1 ) return - 1 ; return smallest ; } public static void Main ( ) { int [ ] a = { 25 , 20 , 5 , 10 , 100 } ; int n = a . Length ; Console . WriteLine ( findSmallest ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GfG { public static int findIndex ( int [ ] arr ) { int maxIndex = 0 ; for ( int i = 0 ; i < arr . Length ; ++ i ) if ( arr [ i ] > arr [ maxIndex ] ) maxIndex = i ; for ( int i = 0 ; i < arr . Length ; ++ i ) if ( maxIndex != i && arr [ maxIndex ] < 2 * arr [ i ] ) return - 1 ; return maxIndex ; } public static void Main ( ) { int [ ] arr = new int [ ] { 3 , 6 , 1 , 0 } ; Console . WriteLine ( findIndex ( arr ) ) ; } }

Index/key variables: i, maxIndex
Iterator variables: i
Class/struct names: GfG
C# program:
using System ; class GFG { static int find_consecutive_steps ( int [ ] arr , int len ) { int count = 0 ; int maximum = 0 ; for ( int index = 1 ; index < len ; index ++ ) { if ( arr [ index ] > arr [ index - 1 ] ) count ++ ; else { maximum = Math . Max ( maximum , count ) ; count = 0 ; } } return Math . Max ( maximum , count ) ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int len = arr . Length ; Console . WriteLine ( find_consecutive_steps ( arr , len ) ) ; } }

Index/key variables: index
Accumulator variables: count, index
Iterator variables: index
Class/struct names: GFG
C# program:
using System ; public class GFG { static int CalculateMax ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int min_sum = arr [ 0 ] + arr [ 1 ] ; int max_sum = arr [ n - 1 ] + arr [ n - 2 ] ; return ( Math . Abs ( max_sum - min_sum ) ) ; } static public void Main ( ) { int [ ] arr = { 6 , 7 , 1 , 11 } ; int n = arr . Length ; Console . WriteLine ( CalculateMax ( arr , n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Linq ; using System . Collections . Generic ; class GFG { static long calculate ( long [ ] a , int n ) { Array . Sort ( a ) ; int i , j ; List < long > s = new List < long > ( ) ; for ( i = 0 , j = n - 1 ; i < j ; i ++ , j -- ) s . Add ( ( a [ i ] + a [ j ] ) ) ; long mini = s . Min ( ) ; long maxi = s . Max ( ) ; return Math . Abs ( maxi - mini ) ; } public static void Main ( ) { long [ ] a = { 2 , 6 , 4 , 3 } ; int n = a . Length ; Console . WriteLine ( calculate ( a , n ) ) ; } }

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

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class MaximumAbsoluteDifference { private static int calculateDiff ( int i , int j , int [ ] array ) { return Math . Abs ( array [ i ] - array [ j ] ) + Math . Abs ( i - j ) ; } private static int maxDistance ( int [ ] array ) { int result = 0 ; for ( int i = 0 ; i < array . Length ; i ++ ) { for ( int j = i ; j < array . Length ; j ++ ) { result = Math . Max ( result , calculateDiff ( i , j , array ) ) ; } } return result ; } public static void Main ( ) { int [ ] array = { - 70 , - 64 , - 6 , - 56 , 64 , 61 , - 57 , 16 , 48 , - 98 } ; Console . WriteLine ( maxDistance ( array ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: MaximumAbsoluteDifference
C# program:
using System ; public class MaximumAbsoluteDifference { private static int maxDistance ( int [ ] array ) { int max1 = int . MinValue ; int min1 = int . MaxValue ; int max2 = int . MinValue ; int min2 = int . MaxValue ; for ( int i = 0 ; i < array . Length ; i ++ ) { max1 = Math . Max ( max1 , array [ i ] + i ) ; min1 = Math . Min ( min1 , array [ i ] + i ) ; max2 = Math . Max ( max2 , array [ i ] - i ) ; min2 = Math . Min ( min2 , array [ i ] - i ) ; } return Math . Max ( max1 - min1 , max2 - min2 ) ; } public static void Main ( ) { int [ ] array = { - 70 , - 64 , - 6 , - 56 , 64 , 61 , - 57 , 16 , 48 , - 98 } ; Console . WriteLine ( maxDistance ( array ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: MaximumAbsoluteDifference
C# program:
using System ; class GFG { static int extrema ( int [ ] a , int n ) { int count = 0 ; for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( a [ i ] > a [ i - 1 ] && a [ i ] > a [ i + 1 ] ) count += 1 ; if ( a [ i ] < a [ i - 1 ] && a [ i ] < a [ i + 1 ] ) count += 1 ; } return count ; } public static void Main ( ) { int [ ] a = { 1 , 0 , 2 , 1 } ; int n = a . Length ; Console . WriteLine ( extrema ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int findClosest ( int [ ] arr , int target ) { int n = arr . Length ; if ( target <= arr [ 0 ] ) return arr [ 0 ] ; if ( target >= arr [ n - 1 ] ) return arr [ n - 1 ] ; int i = 0 , j = n , mid = 0 ; while ( i < j ) { mid = ( i + j ) / 2 ; if ( arr [ mid ] == target ) return arr [ mid ] ; if ( target < arr [ mid ] ) { if ( mid > 0 && target > arr [ mid - 1 ] ) return getClosest ( arr [ mid - 1 ] , arr [ mid ] , target ) ; j = mid ; } else { if ( mid < n - 1 && target < arr [ mid + 1 ] ) return getClosest ( arr [ mid ] , arr [ mid + 1 ] , target ) ; i = mid + 1 ; } } return arr [ mid ] ; } public static int getClosest ( int val1 , int val2 , int target ) { if ( target - val1 >= val2 - target ) return val2 ; else return val1 ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 4 , 5 , 6 , 6 , 8 , 9 } ; int target = 11 ; Console . WriteLine ( findClosest ( arr , target ) ) ; } }

Index/key variables: mid
Class/struct names: GFG
C# program:
using System ; class GFG { static int sum ( int [ ] a , int n ) { int maxSum = int . MinValue ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) maxSum = Math . Max ( maxSum , a [ i ] + a [ j ] ) ; int c = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( a [ i ] + a [ j ] == maxSum ) c ++ ; return c ; } public static void Main ( ) { int [ ] array = { 1 , 1 , 1 , 2 , 2 , 2 } ; int n = array . Length ; Console . WriteLine ( sum ( array , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: c, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int sum ( int [ ] a , int n ) { int maxVal = a [ 0 ] , maxCount = 1 ; int secondMax = int . MinValue ; int secondMaxCount = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i ] == maxVal ) maxCount ++ ; else if ( a [ i ] > maxVal ) { secondMax = maxVal ; secondMaxCount = maxCount ; maxVal = a [ i ] ; maxCount = 1 ; } else if ( a [ i ] == secondMax ) { secondMax = a [ i ] ; secondMaxCount ++ ; } else if ( a [ i ] > secondMax ) { secondMax = a [ i ] ; secondMaxCount = 1 ; } } if ( maxCount > 1 ) return maxCount * ( maxCount - 1 ) / 2 ; return secondMaxCount ; } public static void Main ( ) { int [ ] array = { 1 , 1 , 1 , 2 , 2 , 2 , 3 } ; int n = array . Length ; Console . WriteLine ( sum ( array , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, maxCount, secondMaxCount
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printKMissing ( int [ ] arr , int n , int k ) { Array . Sort ( arr ) ; int i = 0 ; while ( i < n && arr [ i ] <= 0 ) i ++ ; int count = 0 , curr = 1 ; while ( count < k && i < n ) { if ( arr [ i ] != curr ) { Console . Write ( curr + " ▁ " ) ; count ++ ; } else i ++ ; curr ++ ; } while ( count < k ) { Console . Write ( curr + " ▁ " ) ; curr ++ ; count ++ ; } } public static void Main ( ) { int [ ] arr = { 2 , 3 , 4 } ; int n = arr . Length ; int k = 3 ; printKMissing ( arr , n , k ) ; } }

Index/key variables: i
Accumulator variables: count, curr, i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static void printmissingk ( int [ ] arr , int n , int k ) { Dictionary < int , int > d = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { d . Add ( arr [ i ] , arr [ i ] ) ; } int cnt = 1 ; int fl = 0 ; for ( int i = 0 ; i < ( n + k ) ; i ++ ) { if ( ! d . ContainsKey ( cnt ) ) { fl += 1 ; Console . Write ( cnt + " ▁ " ) ; if ( fl == k ) break ; } cnt += 1 ; } } static public void Main ( ) { int [ ] arr = { 1 , 4 , 3 } ; int n = arr . Length ; int k = 3 ; printmissingk ( arr , n , k ) ; } }

Index/key variables: i
Accumulator variables: cnt, fl, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int nobleInteger ( int [ ] arr ) { int size = arr . Length ; for ( int i = 0 ; i < size ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < size ; j ++ ) if ( arr [ i ] < arr [ j ] ) count ++ ; if ( count == arr [ i ] ) return arr [ i ] ; } return - 1 ; } public static void Main ( ) { int [ ] arr = { 10 , 3 , 20 , 40 , 2 } ; int res = nobleInteger ( arr ) ; if ( res != - 1 ) Console . Write ( " The ▁ noble ▁ integer " + " ▁ is ▁ " + res ) ; else Console . Write ( " No ▁ Noble ▁ Integer " + " ▁ Found " ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { public static int nobleInteger ( int [ ] arr ) { Array . Sort ( arr ) ; int n = arr . Length ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] == arr [ i + 1 ] ) continue ; if ( arr [ i ] == n - i - 1 ) return arr [ i ] ; } if ( arr [ n - 1 ] == 0 ) return arr [ n - 1 ] ; return - 1 ; } static public void Main ( ) { int [ ] arr = { 10 , 3 , 20 , 40 , 2 } ; int res = nobleInteger ( arr ) ; if ( res != - 1 ) Console . Write ( " The ▁ noble ▁ integer ▁ is ▁ " + res ) ; else Console . Write ( " No ▁ Noble ▁ Integer ▁ " + " Found " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class MinSum { static long findMinSum ( long [ ] a , long [ ] b , long n ) { Array . Sort ( a ) ; Array . Sort ( b ) ; long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum = sum + Math . Abs ( a [ i ] - b [ i ] ) ; return sum ; } public static void Main ( String [ ] args ) { long [ ] a = { 4 , 1 , 8 , 7 } ; long [ ] b = { 2 , 3 , 6 , 5 } ; int n = a . Length ; Console . Write ( findMinSum ( a , b , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: MinSum
C# program:
using System ; public class GFG { static int minProductSubset ( int [ ] a , int n ) { if ( n == 1 ) return a [ 0 ] ; int negmax = int . MinValue ; int posmin = int . MinValue ; int count_neg = 0 , count_zero = 0 ; int product = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 0 ) { count_zero ++ ; continue ; } if ( a [ i ] < 0 ) { count_neg ++ ; negmax = Math . Max ( negmax , a [ i ] ) ; } if ( a [ i ] > 0 && a [ i ] < posmin ) { posmin = a [ i ] ; } product *= a [ i ] ; } if ( count_zero == n || ( count_neg == 0 && count_zero > 0 ) ) return 0 ; if ( count_neg == 0 ) return posmin ; if ( count_neg % 2 == 0 && count_neg != 0 ) { product = product / negmax ; } return product ; } public static void Main ( ) { int [ ] a = new int [ ] { - 1 , - 1 , - 2 , 4 , 3 } ; int n = 5 ; Console . WriteLine ( minProductSubset ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: count_neg, count_zero, i, product
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int findElement ( int [ ] a , int n , int b ) { Array . Sort ( a ) ; int max = a [ n - 1 ] ; while ( b < max ) { if ( Array . BinarySearch ( a , b ) > - 1 ) b *= 2 ; else return b ; } return b ; } public static void Main ( ) { int [ ] a = { 1 , 2 , 3 } ; int n = a . Length ; int b = 1 ; Console . WriteLine ( findElement ( a , n , b ) ) ; } }

Accumulator variables: b
Class/struct names: GFG
C# program:
using System ; class GFG { static int Mod = 1000000007 ; static long findSum ( int [ ] arr , int n ) { long sum = 0 ; Array . Sort ( arr ) ; int i = 0 ; while ( i < n && arr [ i ] < 0 ) { if ( i != n - 1 && arr [ i + 1 ] <= 0 ) { sum = ( sum + ( arr [ i ] * arr [ i + 1 ] ) % Mod ) % Mod ; i += 2 ; } else break ; } int j = n - 1 ; while ( j >= 0 && arr [ j ] > 0 ) { if ( j != 0 && arr [ j - 1 ] > 0 ) { sum = ( sum + ( arr [ j ] * arr [ j - 1 ] ) % Mod ) % Mod ; j -= 2 ; } else break ; } if ( j > i ) sum = ( sum + ( arr [ i ] * arr [ j ] ) % Mod ) % Mod ; else if ( i == j ) sum = ( sum + arr [ i ] ) % Mod ; return sum ; } public static void Main ( ) { int [ ] arr = { - 1 , 9 , 4 , 5 , - 4 , 7 } ; int n = arr . Length ; Console . WriteLine ( findSum ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class Node { public int data ; public Node next ; public Node ( int d ) { data = d ; next = null ; } } public class LinkedList { Node head ; public void push ( int new_data ) { Node new_node = new Node ( new_data ) ; new_node . next = head ; head = new_node ; } public bool search ( Node head , int x ) { if ( head == null ) return false ; if ( head . data == x ) return true ; return search ( head . next , x ) ; } public static void Main ( ) { LinkedList llist = new LinkedList ( ) ; llist . push ( 10 ) ; llist . push ( 30 ) ; llist . push ( 11 ) ; llist . push ( 21 ) ; llist . push ( 14 ) ; if ( llist . search ( llist . head , 21 ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Class/struct names: LinkedList, Node
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { class Node { public int data ; public Node next ; } ; static Node head_ref = null ; static void reverse ( ) { Node prev = null ; Node current = head_ref ; while ( current != null ) { Node next = current . next ; current . next = prev ; prev = current ; current = next ; } head_ref = prev ; } static void push ( int new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = ( head_ref ) ; ( head_ref ) = new_node ; } static void printList ( ) { Node temp = head_ref ; while ( temp != null ) { Console . Write ( temp . data + " ▁ " ) ; temp = temp . next ; } } public static void Main ( string [ ] args ) { push ( 20 ) ; push ( 4 ) ; push ( 15 ) ; push ( 85 ) ; Console . Write ( " Given ▁ linked ▁ list STRNEWLINE " ) ; printList ( ) ; reverse ( ) ; Console . Write ( " STRNEWLINE Reversed ▁ Linked ▁ list ▁ STRNEWLINE " ) ; printList ( ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; public class Node { public int data ; public Node next ; public Node ( int d ) { data = d ; next = null ; } } public class LinkedList { Node head ; bool areIdentical ( LinkedList listb ) { Node a = this . head , b = listb . head ; while ( a != null && b != null ) { if ( a . data != b . data ) return false ; a = a . next ; b = b . next ; } return ( a == null && b == null ) ; } void push ( int new_data ) { Node new_node = new Node ( new_data ) ; new_node . next = head ; head = new_node ; } public static void Main ( String [ ] args ) { LinkedList llist1 = new LinkedList ( ) ; LinkedList llist2 = new LinkedList ( ) ; llist1 . push ( 1 ) ; llist1 . push ( 2 ) ; llist1 . push ( 3 ) ; llist2 . push ( 1 ) ; llist2 . push ( 2 ) ; llist2 . push ( 3 ) ; if ( llist1 . areIdentical ( llist2 ) == true ) Console . WriteLine ( " Identical ▁ " ) ; else Console . WriteLine ( " Not ▁ identical ▁ " ) ; } }

Class/struct names: LinkedList, Node
C# program:
using System ; class GFG { public class Node { public int data ; public Node next ; } ; static Node head = null ; static void rotate ( int k ) { if ( k == 0 ) return ; Node current = head ; while ( current . next != null ) current = current . next ; current . next = head ; current = head ; for ( int i = 0 ; i < k - 1 ; i ++ ) current = current . next ; head = current . next ; current . next = null ; } static void push ( int new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = head ; head = new_node ; } static void printList ( Node node ) { while ( node != null ) { Console . Write ( node . data + " ▁ " ) ; node = node . next ; } } public static void Main ( String [ ] args ) { for ( int i = 60 ; i > 0 ; i -= 10 ) push ( i ) ; Console . Write ( " Given ▁ linked ▁ list ▁ STRNEWLINE " ) ; printList ( head ) ; rotate ( 4 ) ; Console . Write ( " STRNEWLINE Rotated ▁ Linked ▁ list ▁ STRNEWLINE " ) ; printList ( head ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; public class List { Node head ; public class Node { public int data ; public Node right , down ; public Node ( int data ) { this . data = data ; right = null ; down = null ; } } Node merge ( Node a , Node b ) { if ( a == null ) return b ; if ( b == null ) return a ; Node result ; if ( a . data < b . data ) { result = a ; result . down = merge ( a . down , b ) ; } else { result = b ; result . down = merge ( a , b . down ) ; } result . right = null ; return result ; } Node flatten ( Node root ) { if ( root == null root . right == null ) return root ; root . right = flatten ( root . right ) ; root = merge ( root , root . right ) ; return root ; } Node Push ( Node head_ref , int data ) { Node new_node = new Node ( data ) ; new_node . down = head_ref ; head_ref = new_node ; return head_ref ; } void printList ( ) { Node temp = head ; while ( temp != null ) { Console . Write ( temp . data + " ▁ " ) ; temp = temp . down ; } Console . WriteLine ( ) ; } public static void Main ( String [ ] args ) { List L = new List ( ) ; L . head = L . Push ( L . head , 30 ) ; L . head = L . Push ( L . head , 8 ) ; L . head = L . Push ( L . head , 7 ) ; L . head = L . Push ( L . head , 5 ) ; L . head . right = L . Push ( L . head . right , 20 ) ; L . head . right = L . Push ( L . head . right , 10 ) ; L . head . right . right = L . Push ( L . head . right . right , 50 ) ; L . head . right . right = L . Push ( L . head . right . right , 22 ) ; L . head . right . right = L . Push ( L . head . right . right , 19 ) ; L . head . right . right . right = L . Push ( L . head . right . right . right , 45 ) ; L . head . right . right . right = L . Push ( L . head . right . right . right , 40 ) ; L . head . right . right . right = L . Push ( L . head . right . right . right , 35 ) ; L . head . right . right . right = L . Push ( L . head . right . right . right , 20 ) ; L . head = L . flatten ( L . head ) ; L . printList ( ) ; } }

Class/struct names: List, Node
C# program:
using System ; public class LinkedList { Node head ; class Node { public int data ; public Node next ; public Node ( int d ) { data = d ; next = null ; } } void sortList ( ) { int [ ] count = { 0 , 0 , 0 } ; Node ptr = head ; while ( ptr != null ) { count [ ptr . data ] ++ ; ptr = ptr . next ; } int i = 0 ; ptr = head ; while ( ptr != null ) { if ( count [ i ] == 0 ) i ++ ; else { ptr . data = i ; -- count [ i ] ; ptr = ptr . next ; } } } public void push ( int new_data ) { Node new_node = new Node ( new_data ) ; new_node . next = head ; head = new_node ; } void printList ( ) { Node temp = head ; while ( temp != null ) { Console . Write ( temp . data + " ▁ " ) ; temp = temp . next ; } Console . WriteLine ( ) ; } public static void Main ( String [ ] args ) { LinkedList llist = new LinkedList ( ) ; llist . push ( 0 ) ; llist . push ( 1 ) ; llist . push ( 0 ) ; llist . push ( 2 ) ; llist . push ( 1 ) ; llist . push ( 1 ) ; llist . push ( 2 ) ; llist . push ( 1 ) ; llist . push ( 2 ) ; Console . WriteLine ( " Linked ▁ List ▁ before ▁ sorting " ) ; llist . printList ( ) ; llist . sortList ( ) ; Console . WriteLine ( " Linked ▁ List ▁ after ▁ sorting " ) ; llist . printList ( ) ; } }

Index/key variables: i
Accumulator variables: i
Class/struct names: LinkedList, Node
C# program:
static class List { public int data ; public List next ; public List child ; } ;

Class/struct names: List
C# program:
using System ; class GfG { class Node { public int data ; public Node next ; } static Node newNode ( int key ) { Node temp = new Node ( ) ; temp . data = key ; temp . next = null ; return temp ; } static Node rearrangeEvenOdd ( Node head ) { if ( head == null ) return null ; Node odd = head ; Node even = head . next ; Node evenFirst = even ; while ( 1 == 1 ) { if ( odd == null || even == null || ( even . next ) == null ) { odd . next = evenFirst ; break ; } odd . next = even . next ; odd = even . next ; if ( odd . next == null ) { even . next = null ; odd . next = evenFirst ; break ; } even . next = odd . next ; even = odd . next ; } return head ; } static void printlist ( Node node ) { while ( node != null ) { Console . Write ( node . data + " - > " ) ; node = node . next ; } Console . WriteLine ( " NULL " ) ; } public static void Main ( ) { Node head = newNode ( 1 ) ; head . next = newNode ( 2 ) ; head . next . next = newNode ( 3 ) ; head . next . next . next = newNode ( 4 ) ; head . next . next . next . next = newNode ( 5 ) ; Console . WriteLine ( " Given ▁ Linked ▁ List " ) ; printlist ( head ) ; head = rearrangeEvenOdd ( head ) ; Console . WriteLine ( " Modified ▁ Linked ▁ List " ) ; printlist ( head ) ; } }

Class/struct names: GfG, Node