dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; class GFG { public static void kthDigitFromLast ( int n , int k ) { if ( k <= 0 ) { System . out . println ( - 1 ) ; return ; } String temp = Integer . toString ( n ) ; if ( k > temp . length ( ) ) { System . out . println ( - 1 ) ; } else { int index = temp . length ( ) - k ; int res = temp . charAt ( index ) - '0' ; System . out . println ( res ) ; } } public static void main ( String [ ] args ) { int n = 2354 ; int k = 2 ; kthDigitFromLast ( n , k ) ; } }

Class/struct names: GFG
Java program:
import java . lang . * ; import java . util . * ; class GFG { static int countWays ( int arr [ ] , int N ) { int arr_xor = 0 ; for ( int i = 0 ; i < N ; i ++ ) arr_xor ^= arr [ i ] ; int pref_xor = 0 , suff_xor = 0 ; ArrayList < Integer > pref_ind = new ArrayList < > ( ) ; int [ ] suff_inds = new int [ N + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { pref_xor ^= arr [ i ] ; if ( pref_xor == arr_xor ) pref_ind . add ( i ) ; } for ( int i = N - 1 ; i >= 0 ; i -- ) { suff_xor ^= arr [ i ] ; suff_inds [ i ] += suff_inds [ i + 1 ] ; if ( suff_xor == arr_xor ) suff_inds [ i ] ++ ; } int tot_ways = 0 ; for ( Integer idx : pref_ind ) { if ( idx < N - 1 ) tot_ways += suff_inds [ idx + 2 ] ; } return tot_ways ; } public static void main ( String [ ] args ) { int arr [ ] = { 7 , 0 , 5 , 2 , 7 } ; int N = arr . length ; System . out . println ( countWays ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: arr_xor, i, pref_xor, suff_xor, tot_ways
Iterator variables: i, idx
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int [ ] [ ] dp = new int [ 1000 ] [ 2 ] ; static int IsSumEqualsXor ( int i , int n , int bound , char [ ] s ) { if ( i == n ) return 1 ; if ( dp [ i ] [ bound ] != - 1 ) return dp [ i ] [ bound ] ; int ans = 0 ; if ( bound != 0 && s [ i ] == '0' ) { ans = IsSumEqualsXor ( i + 1 , n , 1 , s ) ; } else { ans = 2 * IsSumEqualsXor ( i + 1 , n , bound != 0 & ( s [ i ] == '1' ) ? 1 : 0 , s ) ; ans += IsSumEqualsXor ( i + 1 , n , 0 , s ) ; } return dp [ i ] [ bound ] = ans ; } static String reverse ( String input ) { char [ ] a = input . toCharArray ( ) ; int l , r = a . length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . valueOf ( a ) ; } static String convertToBinary ( int n ) { String ans = " " ; while ( n > 0 ) { char rem = ( char ) ( n % 2 + '0' ) ; ans += ( rem ) ; n /= 2 ; } ans = reverse ( ans ) ; return ans ; } static void IsSumEqualsXorUtil ( int N ) { String s = convertToBinary ( N ) ; for ( int i = 0 ; i < dp . length ; i ++ ) { for ( int j = 0 ; j < dp [ 0 ] . length ; j ++ ) { dp [ i ] [ j ] = - 1 ; } } System . out . print ( IsSumEqualsXor ( 0 , s . length ( ) , 1 , s . toCharArray ( ) ) + "NEW_LINE"); } public static void main ( String [ ] args ) { int N = 10 ; IsSumEqualsXorUtil ( N ) ; } }

Index/key variables: bound, i, j, l, r
Accumulator variables: ans, i, j, l, n, r
Iterator variables: i, j, l
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printMat ( int degseq [ ] , int n ) { int [ ] [ ] mat = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( degseq [ i ] > 0 && degseq [ j ] > 0 ) { degseq [ i ] -- ; degseq [ j ] -- ; mat [ i ] [ j ] = 1 ; mat [ j ] [ i ] = 1 ; } } } System . out . print ( " " ▁ + ▁ setw ( 3 ) ▁ + ▁ " "); for ( int i = 0 ; i < n ; i ++ ) System . out . print ( setw ( 3 ) + " ( " + i + " ) " ) ; System . out . print ( "NEW_LINE"); for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( setw ( 4 ) + " ( " + i + " ) " ) ; for ( int j = 0 ; j < n ; j ++ ) System . out . print ( setw ( 5 ) + mat [ i ] [ j ] ) ; System . out . print ( "NEW_LINE"); } } static String setw ( int n ) { String space = " " ; while ( n -- > 0 ) space += " ▁ " ; return space ; } public static void main ( String [ ] args ) { int degseq [ ] = { 2 , 2 , 1 , 1 , 1 } ; int n = degseq . length ; printMat ( degseq , n ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j, n, space
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void findDecimal ( double arr [ ] , int N ) { int bit , power = 0 , result = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { bit = Math . abs ( ( int ) Math . floor ( arr [ i ] ) - ( int ) Math . round ( arr [ i ] ) ) ; if ( bit != 0 ) result += Math . pow ( 2 , power ) ; power ++ ; } System . out . print ( result ) ; } public static void main ( String [ ] args ) { double arr [ ] = { 1.2 , 2.6 , 4.2 , 6.9 , 3.1 , 21.6 , 91.2 } ; int N = arr . length ; findDecimal ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, power, result
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int totalMoney ( int N ) { int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { ans += i / 7 ; ans += ( i % 7 + 1 ) ; } return ans ; } public static void main ( String [ ] args ) { int N = 15 ; System . out . println ( totalMoney ( N ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void totalMoney ( int N ) { int CompWeeks = N / 7 ; int RemDays = N % 7 ; int X = 28 * CompWeeks + 7 * ( CompWeeks * ( CompWeeks - 1 ) / 2 ) ; int Y = RemDays * ( RemDays + 1 ) / 2 + CompWeeks * RemDays ; int cost = X + Y ; System . out . print ( cost ) ; } public static void main ( String [ ] args ) { int N = 15 ; totalMoney ( N ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class pair { int count , prevIndex ; pair ( int count , int prevIndex ) { this . count = count ; this . prevIndex = prevIndex ; } } static void findSum ( int [ ] arr , int n ) { Map < Integer , pair > map = new HashMap < > ( ) ; int [ ] left = new int [ n ] ; int [ ] right = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! map . containsKey ( arr [ i ] ) ) { left [ i ] = 0 ; map . put ( arr [ i ] , new pair ( 1 , i ) ) ; } else { pair tmp = map . get ( arr [ i ] ) ; left [ i ] = ( tmp . count ) * ( i - tmp . prevIndex ) + left [ tmp . prevIndex ] ; map . put ( arr [ i ] , new pair ( tmp . count + 1 , i ) ) ; } } map . clear ( ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( ! map . containsKey ( arr [ i ] ) ) { right [ i ] = 0 ; map . put ( arr [ i ] , new pair ( 1 , i ) ) ; } else { pair tmp = map . get ( arr [ i ] ) ; right [ i ] = ( tmp . count ) * ( Math . abs ( i - tmp . prevIndex ) ) + right [ tmp . prevIndex ] ; map . put ( arr [ i ] , new pair ( tmp . count + 1 , i ) ) ; } } for ( int i = 0 ; i < n ; i ++ ) System . out . print ( left [ i ] + right [ i ] + " ▁ " ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 3 , 1 , 1 , 2 } ; int N = arr . length ; findSum ( arr , N ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, pair
Java program:
import java . util . * ; class GFG { static int isPresent ( int n , int x ) { String num = String . valueOf ( n ) ; for ( int i = 0 ; i < num . length ( ) ; i ++ ) { if ( ( num . charAt ( i ) - '0' ) == x ) return i ; } return - 1 ; } static int removeDigit ( int n , int index ) { String num = String . valueOf ( n ) ; String ans = " " ; for ( int i = 0 ; i < num . length ( ) ; i ++ ) { if ( i != index ) ans += num . charAt ( i ) ; } if ( ans == " " || ( ans . length ( ) == 1 && ans . charAt ( 0 ) == '0' ) ) return - 1 ; int x = Integer . valueOf ( ans ) ; return x ; } static boolean reduceNtoX ( int a , int b , int d [ ] , int n ) { Queue < Integer > q = new LinkedList < > ( ) ; q . add ( a ) ; Map < Integer , Boolean > visited = new HashMap < > ( ) ; visited . put ( a , true ) ; while ( ! q . isEmpty ( ) ) { int top = q . peek ( ) ; q . poll ( ) ; if ( top < 0 ) continue ; if ( top == b ) return true ; for ( int i = 0 ; i < n ; i ++ ) { if ( d [ i ] != 0 && top % d [ i ] == 0 && ! visited . getOrDefault ( top / d [ i ] , false ) ) { q . add ( top / d [ i ] ) ; visited . put ( top / d [ i ] , true ) ; } int index = isPresent ( top , d [ i ] ) ; if ( index != - 1 ) { int newElement = removeDigit ( top , index ) ; if ( newElement != - 1 && ( ! visited . getOrDefault ( newElement , false ) ) ) { q . add ( newElement ) ; visited . put ( newElement , true ) ; } } } } return false ; } public static void main ( String [ ] args ) { int A = 5643 , B = 81 ; int D [ ] = { 3 , 8 , 1 } ; int N = D . length ; if ( reduceNtoX ( A , B , D , N ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean [ ] prime = new boolean [ 100000 ] ; static void initialize ( ) { for ( int i = 0 ; i < 100000 ; i ++ ) prime [ i ] = true ; } static void SieveOfEratosthenes ( int n ) { for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) { prime [ i ] = false ; } } } } static void findTriplets ( int N ) { SieveOfEratosthenes ( N ) ; ArrayList < ArrayList < Integer > > V = new ArrayList < ArrayList < Integer > > ( ) ; for ( int i = 3 ; i <= N ; i ++ ) { if ( 2 + i <= N && prime [ i ] && prime [ 2 + i ] ) { ArrayList < Integer > a1 = new ArrayList < Integer > ( ) ; a1 . add ( 2 ) ; a1 . add ( i ) ; a1 . add ( i + 2 ) ; V . add ( a1 ) ; } } for ( int i = 0 ; i < V . size ( ) ; i ++ ) { System . out . println ( V . get ( i ) . get ( 0 ) + " ▁ " + V . get ( i ) . get ( 1 ) + " ▁ " + V . get ( i ) . get ( 2 ) ) ; } } public static void main ( String args [ ] ) { initialize ( ) ; int N = 8 ; findTriplets ( N ) ; } }

Index/key variables: i, p
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static final int MAX = 100000 ; @ SuppressWarnings ( " unchecked " ) static List < List < Integer > > adj = new ArrayList ( ) ; @ SuppressWarnings ( " unchecked " ) static List < List < Integer > > adjInv = new ArrayList ( ) ; static boolean [ ] visited = new boolean [ MAX ] ; static boolean [ ] visitedInv = new boolean [ MAX ] ; static Stack < Integer > s = new Stack < Integer > ( ) ; static int [ ] scc = new int [ MAX ] ; static int counter = 1 ; static void addEdges ( int a , int b ) { adj . get ( a ) . add ( b ) ; } static void addEdgesInverse ( int a , int b ) { adjInv . get ( b ) . add ( a ) ; } static void dfsFirst ( int u ) { if ( visited [ u ] ) return ; visited [ u ] = true ; for ( int i = 0 ; i < adj . get ( u ) . size ( ) ; i ++ ) dfsFirst ( adj . get ( u ) . get ( i ) ) ; s . push ( u ) ; } static void dfsSecond ( int u ) { if ( visitedInv [ u ] ) return ; visitedInv [ u ] = true ; for ( int i = 0 ; i < adjInv . get ( u ) . size ( ) ; i ++ ) dfsSecond ( adjInv . get ( u ) . get ( i ) ) ; scc [ u ] = counter ; } static void is2Satisfiable ( int n , int m , int a [ ] , int b [ ] ) { for ( int i = 0 ; i < m ; i ++ ) { if ( a [ i ] > 0 && b [ i ] > 0 ) { addEdges ( a [ i ] + n , b [ i ] ) ; addEdgesInverse ( a [ i ] + n , b [ i ] ) ; addEdges ( b [ i ] + n , a [ i ] ) ; addEdgesInverse ( b [ i ] + n , a [ i ] ) ; } else if ( a [ i ] > 0 && b [ i ] < 0 ) { addEdges ( a [ i ] + n , n - b [ i ] ) ; addEdgesInverse ( a [ i ] + n , n - b [ i ] ) ; addEdges ( - b [ i ] , a [ i ] ) ; addEdgesInverse ( - b [ i ] , a [ i ] ) ; } else if ( a [ i ] < 0 && b [ i ] > 0 ) { addEdges ( - a [ i ] , b [ i ] ) ; addEdgesInverse ( - a [ i ] , b [ i ] ) ; addEdges ( b [ i ] + n , n - a [ i ] ) ; addEdgesInverse ( b [ i ] + n , n - a [ i ] ) ; } else { addEdges ( - a [ i ] , n - b [ i ] ) ; addEdgesInverse ( - a [ i ] , n - b [ i ] ) ; addEdges ( - b [ i ] , n - a [ i ] ) ; addEdgesInverse ( - b [ i ] , n - a [ i ] ) ; } } for ( int i = 1 ; i <= 2 * n ; i ++ ) if ( ! visited [ i ] ) dfsFirst ( i ) ; while ( ! s . isEmpty ( ) ) { int top = s . peek ( ) ; s . pop ( ) ; if ( ! visitedInv [ top ] ) { dfsSecond ( top ) ; counter ++ ; } } for ( int i = 1 ; i <= n ; i ++ ) { if ( scc [ i ] == scc [ i + n ] ) { System . out . println ( " The ▁ given ▁ expression " + " is ▁ unsatisfiable . " ) ; return ; } } System . out . println ( " The ▁ given ▁ expression ▁ " + " is ▁ satisfiable . " ) ; } public static void main ( String [ ] args ) { int n = 5 , m = 7 ; for ( int i = 0 ; i < MAX ; i ++ ) { adj . add ( new ArrayList < Integer > ( ) ) ; adjInv . add ( new ArrayList < Integer > ( ) ) ; } int a [ ] = { 1 , - 2 , - 1 , 3 , - 3 , - 4 , - 3 } ; int b [ ] = { 2 , 3 , - 2 , 4 , 5 , - 5 , 4 } ; is2Satisfiable ( n , m , a , b ) ; } }

Index/key variables: MAX, i, top, u
Accumulator variables: counter, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static long MAX = 50 ; static boolean isPrime ( long n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( long i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } static void findPrime ( ArrayList < Long > primes ) { for ( long i = 2 ; i <= MAX ; i ++ ) { if ( isPrime ( i ) ) primes . add ( i ) ; } } static long gcd ( long a , long b ) { if ( b == 0 ) return a ; else return gcd ( b , a % b ) ; } static void findMinimumNumber ( long [ ] arr , long N ) { ArrayList < Long > primes = new ArrayList < Long > ( ) ; findPrime ( primes ) ; long ans = 2147483647 ; int n = primes . size ( ) ; for ( int i = 1 ; i < ( 1 << n ) ; i ++ ) { long temp = 1 ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( i & ( 1 << j ) ) > 0 ) { temp *= primes . get ( j ) ; } } boolean check = true ; for ( long k = 0 ; k < N ; k ++ ) { if ( gcd ( temp , arr [ ( int ) k ] ) == 1l ) { check = false ; break ; } } if ( check == true ) ans = Math . min ( ans , temp ) ; } System . out . print ( ans ) ; } public static void main ( String [ ] args ) { long [ ] arr = { 3 , 4 , 6 , 7 , 8 , 9 , 10 } ; long N = arr . length ; findMinimumNumber ( arr , N ) ; } }

Accumulator variables: i, j, k, temp
Iterator variables: i, j, k
Boolean variables: check
Class/struct names: GFG
Java program:
import java . util . * ; import java . io . * ; class GFG { static int R = 100005 ; static int [ ] arr = new int [ R ] ; public static boolean canExpress ( int N ) { int temp = N ; int n = 0 ; while ( N != 0 ) { N /= 10 ; n ++ ; } N = temp ; int sum = 0 ; while ( N != 0 ) { sum += ( ( int ) Math . pow ( N % 10 , n ) ) ; N /= 10 ; } if ( sum == temp ) return true ; return false ; } public static void precompute ( ) { for ( int i = 1 ; i < R ; i ++ ) { if ( canExpress ( i ) ) { arr [ i ] = 1 ; } } for ( int i = 1 ; i < R ; i ++ ) { arr [ i ] += arr [ i - 1 ] ; } } public static void countNumbers ( int [ ] [ ] queries , int N ) { precompute ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int L1 = queries [ i ] [ 0 ] ; int R1 = queries [ i ] [ 1 ] ; System . out . print ( ( arr [ R1 ] - arr [ L1 - 1 ] ) + " ▁ " ) ; } } public static void main ( String args [ ] ) { int [ ] [ ] queries = { { 1 , 400 } , { 1 , 9 } } ; int N = queries . length ; countNumbers ( queries , N ) ; } }

Index/key variables: R, R1, i
Accumulator variables: N, i, n, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . ArrayList ; class GFG { public static void sumOfNodeInAPath ( int node_value ) { int sum_of_node = 0 ; while ( node_value > 0 ) { sum_of_node += node_value ; node_value /= 2 ; } System . out . print ( sum_of_node ) ; } public static void findSum ( ArrayList < Integer > Q ) { for ( int i = 0 ; i < Q . size ( ) ; i ++ ) { int node_value = Q . get ( i ) ; sumOfNodeInAPath ( node_value ) ; System . out . print ( " ▁ " ) ; } } public static void main ( String [ ] args ) { ArrayList < Integer > arr = new ArrayList < > ( ) ; arr . add ( 1 ) ; arr . add ( 5 ) ; arr . add ( 20 ) ; arr . add ( 100 ) ; findSum ( arr ) ; } }

Accumulator variables: i, node_value, sum_of_node
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . HashMap ; import java . util . Map ; import java . util . ArrayList ; import java . util . Collections ; class GFG { public static void minDeletions ( int arr [ ] , int N ) { HashMap < Integer , Integer > map = new HashMap < > ( ) ; ; for ( int i = 0 ; i < N ; i ++ ) { Integer k = map . get ( arr [ i ] ) ; map . put ( arr [ i ] , ( k == null ) ? 1 : k + 1 ) ; } ArrayList < Integer > v = new ArrayList < > ( ) ; for ( Map . Entry < Integer , Integer > e : map . entrySet ( ) ) { v . add ( e . getValue ( ) ) ; } Collections . sort ( v ) ; int size = v . size ( ) ; int ans = N - ( v . get ( 0 ) * size ) ; for ( int i = 1 ; i < v . size ( ) ; i ++ ) { if ( v . get ( i ) != v . get ( i - 1 ) ) { int safe = v . get ( i ) * ( size - i ) ; ans = Math . min ( ans , N - safe ) ; } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 4 , 3 , 2 , 5 , 3 } ; int N = 6 ; minDeletions ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class Graph { int vertices ; int [ ] [ ] adjacency_matrix ; public graph ( int vertices ) { this . vertices = vertices ; adjacency_matrix = new int [ vertices ] [ vertices ] ; } public void insert ( int source , int destination ) { adjacency_matrix [ destination - 1 ] = 1 ; } public boolean issink ( int i ) { for ( int j = 0 ; j < vertices ; j ++ ) { if ( adjacency_matrix [ i ] [ j ] == 1 ) return false ; if ( adjacency_matrix [ j ] [ i ] == 0 && j != i ) return false ; } return true ; } public int eliminate ( ) { int i = 0 , j = 0 ; while ( i < vertices && j < vertices ) { if ( adjacency_matrix [ i ] [ j ] == 1 ) i = i + 1 ; else j = j + 1 ; } if ( i > vertices ) return - 1 ; else if ( ! issink ( i ) ) return - 1 ; else return i ; } } public class Sink { public static void main ( String [ ] args ) throws IOException { int number_of_vertices = 6 ; int number_of_edges = 5 ; graph g = new graph ( number_of_vertices ) ; g . insert ( 1 , 6 ) ; g . insert ( 2 , 3 ) ; g . insert ( 2 , 4 ) ; g . insert ( 4 , 3 ) ; g . insert ( 5 , 3 ) ; int vertex = g . eliminate ( ) ; if ( vertex >= 0 ) System . out . println ( " Sink ▁ found ▁ at ▁ vertex ▁ " + ( vertex + 1 ) ) ; else System . out . println ( " No ▁ Sink " ) ; } }

Index/key variables: i, j, vertices
Accumulator variables: j
Iterator variables: j
Class/struct names: Graph, Sink
Java program:
class Sol { static class Node { char key ; Node left , right ; } ; static void preorder ( Node root1 , Node root2 , int lvl ) { if ( root1 == null root2 == null ) return ; if ( lvl % 2 == 0 ) { char t = root1 . key ; root1 . key = root2 . key ; root2 . key = t ; } preorder ( root1 . left , root2 . right , lvl + 1 ) ; preorder ( root1 . right , root2 . left , lvl + 1 ) ; } static void reverseAlternate ( Node root ) { preorder ( root . left , root . right , 0 ) ; } static void printInorder ( Node root ) { if ( root == null ) return ; printInorder ( root . left ) ; System . out . print ( root . key + " ▁ " ) ; printInorder ( root . right ) ; } static Node newNode ( int key ) { Node temp = new Node ( ) ; temp . left = temp . right = null ; temp . key = ( char ) key ; return temp ; } public static void main ( String args [ ] ) { Node root = newNode ( ' a ' ) ; root . left = newNode ( ' b ' ) ; root . right = newNode ( ' c ' ) ; root . left . left = newNode ( ' d ' ) ; root . left . right = newNode ( ' e ' ) ; root . right . left = newNode ( ' f ' ) ; root . right . right = newNode ( ' g ' ) ; root . left . left . left = newNode ( ' h ' ) ; root . left . left . right = newNode ( ' i ' ) ; root . left . right . left = newNode ( ' j ' ) ; root . left . right . right = newNode ( ' k ' ) ; root . right . left . left = newNode ( ' l ' ) ; root . right . left . right = newNode ( ' m ' ) ; root . right . right . left = newNode ( ' n ' ) ; root . right . right . right = newNode ( ' o ' ) ; System . out . print ( "Inorder Traversal of given treeNEW_LINE"); printInorder ( root ) ; reverseAlternate ( root ) ; System . out . print ( " Inorder Traversal of modified tree "); printInorder ( root ) ; } }

Class/struct names: Node, Sol
Java program:
import java . util . LinkedList ; import java . util . Queue ; class GFG { static class Node { int key ; Node left , right ; Node ( int key ) { this . key = key ; left = null ; right = null ; } } static Node root ; static Node temp = root ; static void inorder ( Node temp ) { if ( temp == null ) return ; inorder ( temp . left ) ; System . out . print ( temp . key + " ▁ " ) ; inorder ( temp . right ) ; } static void deleteDeepest ( Node root , Node delNode ) { Queue < Node > q = new LinkedList < Node > ( ) ; q . add ( root ) ; Node temp = null ; while ( ! q . isEmpty ( ) ) { temp = q . peek ( ) ; q . remove ( ) ; if ( temp == delNode ) { temp = null ; return ; } if ( temp . right != null ) { if ( temp . right == delNode ) { temp . right = null ; return ; } else q . add ( temp . right ) ; } if ( temp . left != null ) { if ( temp . left == delNode ) { temp . left = null ; return ; } else q . add ( temp . left ) ; } } } static void delete ( Node root , int key ) { if ( root == null ) return ; if ( root . left == null && root . right == null ) { if ( root . key == key ) { root = null ; return ; } else return ; } Queue < Node > q = new LinkedList < Node > ( ) ; q . add ( root ) ; Node temp = null , keyNode = null ; while ( ! q . isEmpty ( ) ) { temp = q . peek ( ) ; q . remove ( ) ; if ( temp . key == key ) keyNode = temp ; if ( temp . left != null ) q . add ( temp . left ) ; if ( temp . right != null ) q . add ( temp . right ) ; } if ( keyNode != null ) { int x = temp . key ; deleteDeepest ( root , temp ) ; keyNode . key = x ; } } public static void main ( String args [ ] ) { root = new Node ( 10 ) ; root . left = new Node ( 11 ) ; root . left . left = new Node ( 7 ) ; root . left . right = new Node ( 12 ) ; root . right = new Node ( 9 ) ; root . right . left = new Node ( 15 ) ; root . right . right = new Node ( 8 ) ; System . out . print ( " Inorder ▁ traversal ▁ " + " before ▁ deletion : " ) ; inorder ( root ) ; int key = 11 ; delete ( root , key ) ; System . out . print ( " Inorder traversal " ▁ + ▁ " after deletion : "); inorder ( root ) ; } }

Class/struct names: GFG, Node
Java program:
import java . util . * ; class GFG { static int countSink ( int n , int m , int edgeFrom [ ] , int edgeTo [ ] ) { int [ ] mark = new int [ n + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) mark [ edgeFrom [ i ] ] = 1 ; int count = 0 ; for ( int i = 1 ; i <= n ; i ++ ) if ( mark [ i ] == 0 ) count ++ ; return count ; } public static void main ( String [ ] args ) { int n = 4 , m = 2 ; int edgeFrom [ ] = { 2 , 4 } ; int edgeTo [ ] = { 3 , 3 } ; System . out . println ( countSink ( n , m , edgeFrom , edgeTo ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int N = 6 ; static int subsetGraph ( int C [ ] [ ] ) { HashSet < Integer > vertices = new HashSet < > ( ) ; for ( int i = 0 ; i < N ; ++ i ) { vertices . add ( i ) ; } while ( ! vertices . isEmpty ( ) ) { if ( vertices . size ( ) == 1 ) { return 1 ; } boolean someone_removed = false ; for ( int x : vertices ) { HashSet < Integer > values = new HashSet < > ( ) ; for ( int y : vertices ) { if ( y != x ) { values . add ( C [ x ] [ y ] ) ; } } if ( values . size ( ) == 1 ) { vertices . remove ( x ) ; someone_removed = true ; break ; } } if ( ! someone_removed ) { break ; } } return ( vertices . size ( ) ) ; } public static void main ( String [ ] args ) { int C [ ] [ ] = { { 0 , 9 , 2 , 4 , 7 , 8 } , { 9 , 0 , 9 , 9 , 7 , 9 } , { 2 , 9 , 0 , 3 , 7 , 6 } , { 4 , 9 , 3 , 0 , 7 , 1 } , { 7 , 7 , 7 , 7 , 0 , 7 } , { 8 , 9 , 6 , 1 , 7 , 0 } } ; System . out . println ( subsetGraph ( C ) ) ; } }

Index/key variables: x, y
Iterator variables: i, x, y
Boolean variables: someone_removed
Class/struct names: GFG