dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; class GFG { public static int findMiniFlip ( int [ ] nums ) { int n = nums . length ; String s = " " ; for ( int i = 0 ; i < n ; i ++ ) s += nums [ i ] ; long num = Integer . parseInt ( s , 2 ) ; int minXor = n ; long mask = ( 1 << ( n - 1 ) ) ; while ( n - 1 > 0 ) { long temp = ( num ^ mask ) ; minXor = Math . min ( minXor , countones ( temp ) ) ; n -- ; mask = ( mask | ( 1 << n - 1 ) ) ; } return minXor ; } public static int countones ( long n ) { int c = 0 ; while ( n > 0 ) { n = n & ( n - 1 ) ; c ++ ; } return c ; } public static void main ( String [ ] args ) { int [ ] nums = { 1 , 0 , 1 , 1 , 0 , 0 , 0 } ; int n = findMiniFlip ( nums ) ; System . out . println ( n ) ; } }

Index/key variables: i
Accumulator variables: c, i, n, s
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static int convertStringToInt ( String s ) { int ans = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '1' ) ans += 1 << i ; } return ans ; } public static int getNthNumber ( int n ) { Queue < String > q = new LinkedList < > ( ) ; if ( n == 1 ) return 1 ; n = n - 1 ; q . add ( "11" ) ; while ( n -- > 0 ) { String curr = q . remove ( ) ; if ( n == 0 ) return convertStringToInt ( curr ) ; int len = curr . length ( ) ; if ( len % 2 == 0 ) { q . add ( curr . substring ( 0 , len / 2 ) + "0" + curr . substring ( len / 2 ) ) ; q . add ( curr . substring ( 0 , len / 2 ) + "1" + curr . substring ( len / 2 ) ) ; } else { char midChar = curr . charAt ( len / 2 ) ; q . add ( curr . substring ( 0 , len / 2 ) + midChar + curr . substring ( len / 2 ) ) ; } } return - 1 ; } public static void main ( String [ ] args ) { int n = 9 ; System . out . println ( getNthNumber ( n ) ) ; } }

Accumulator variables: ans, i, n
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static byte longSize = 8 ; static int ULL_SIZE = 8 * longSize ; static boolean bit_anagram_check ( long a ) { return ( Integer . bitCount ( ( int ) a ) == ( ULL_SIZE >> 1 ) ) ; } public static void main ( String [ ] args ) { long a = 4294967295L ; System . out . println ( bit_anagram_check ( a ) ) ; } }

Class/struct names: GFG
Java program:
public class Main { static int findSum ( int n ) { int sum = 0 ; for ( int i = 1 ; 1 << i < n ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { int num = ( 1 << i ) + ( 1 << j ) ; if ( num <= n ) sum += num ; } } return sum ; } public static void main ( String [ ] args ) { int n = 10 ; System . out . println ( findSum ( n ) ) ; } }

Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: Main
Java program:
import java . util . * ; class GFG { static int posOfRightMostDiffBit ( int m , int n ) { return ( int ) Math . floor ( Math . log10 ( Math . pow ( m ^ n , 2 ) ) ) + 2 ; } public static void main ( String [ ] args ) { int m = 52 , n = 4 ; System . out . println ( " Position ▁ = ▁ " + posOfRightMostDiffBit ( m , n ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int setKthBit ( int n , int k ) { return ( ( 1 << k ) n ) ; } public static void main ( String arg [ ] ) { int n = 10 , k = 2 ; System . out . print ( " Kth ▁ bit ▁ set ▁ number ▁ = ▁ " + setKthBit ( n , k ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static void reverseArray ( int arr [ ] , int n ) { int x = ( Integer . MIN_VALUE / Integer . MAX_VALUE ) ; for ( int i = 0 ; i < n / 2 ; i ++ ) swap ( arr , i , n + ( x * i ) + x ) ; } static int [ ] swap ( int [ ] arr , int i , int j ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; return arr ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 3 , 7 , 2 , 1 , 6 } ; int n = arr . length ; reverseArray ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: i, j
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { static void reverseArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n / 2 ; i ++ ) { swap ( arr , i , ( n + ~ i + 1 ) + ~ 1 + 1 ) ; } } static int [ ] swap ( int [ ] arr , int i , int j ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; return arr ; } public static void main ( String args [ ] ) { int arr [ ] = { 5 , 3 , 7 , 2 , 1 , 6 } ; int n = arr . length ; reverseArray ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( arr [ i ] + " ▁ " ) ; } } }

Index/key variables: i, j
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class Xor { static int maxXORInRange ( int L , int R ) { int LXR = L ^ R ; int msbPos = 0 ; while ( LXR > 0 ) { msbPos ++ ; LXR >>= 1 ; } int maxXOR = 0 ; int two = 1 ; while ( msbPos -- > 0 ) { maxXOR += two ; two <<= 1 ; } return maxXOR ; } public static void main ( String [ ] args ) { int L = 8 ; int R = 20 ; System . out . println ( maxXORInRange ( L , R ) ) ; } }

Accumulator variables: maxXOR, msbPos
Class/struct names: Xor
Java program:
class GFG { static int CountZeroBit ( int n ) { int count = 0 ; while ( n > 0 ) { if ( ( n & 1 ) != 0 ) count ++ ; n >>= 1 ; } return count ; } static int CountORandSumEqual ( int N ) { int count = CountZeroBit ( N ) ; return ( 1 << count ) ; } public static void main ( String [ ] args ) { int N = 10 ; System . out . print ( CountORandSumEqual ( N ) ) ; } }

Accumulator variables: count
Class/struct names: GFG
Java program:
import java . lang . * ; class GFG { static int countNumbers ( int n ) { int k = 0 ; int count = 0 ; while ( n > 0 ) { if ( ( n & 1 ) == 0 ) count += ( int ) ( Math . pow ( 2 , k ) ) ; k += 1 ; n >>= 1 ; } return count ; } public static void main ( String [ ] args ) { int n = 11 ; System . out . println ( countNumbers ( n ) ) ; } }

Accumulator variables: count, k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int xorPairCount ( int arr [ ] , int n , int x ) { HashSet < Integer > s = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . contains ( x ^ arr [ i ] ) && ( x ^ arr [ i ] ) == ( int ) s . toArray ( ) [ s . size ( ) - 1 ] ) { result ++ ; } s . add ( arr [ i ] ) ; } return result ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 4 , 10 , 15 , 7 , 6 } ; int n = arr . length ; int x = 5 ; System . out . print ( " Count ▁ of ▁ pairs ▁ with ▁ given ▁ XOR ▁ = ▁ " + xorPairCount ( arr , n , x ) ) ; } }

Index/key variables: i
Accumulator variables: i, result
Iterator variables: i
Class/struct names: GFG
Java program:
class Test { static boolean isMultipleOf4 ( int n ) { if ( n == 1 ) return false ; int XOR = 0 ; for ( int i = 1 ; i <= n ; i ++ ) XOR = XOR ^ i ; return ( XOR == n ) ; } public static void main ( String [ ] args ) { for ( int n = 0 ; n <= 42 ; n ++ ) System . out . print ( isMultipleOf4 ( n ) ? n : " ▁ " ) ; } }

Accumulator variables: i, n
Iterator variables: i, n
Class/struct names: Test
Java program:
class Test { static boolean isMultipleOf4 ( long n ) { if ( n == 0 ) return true ; return ( ( ( n >> 2 ) << 2 ) == n ) ; } public static void main ( String [ ] args ) { for ( int n = 0 ; n <= 42 ; n ++ ) System . out . print ( isMultipleOf4 ( n ) ? n : " ▁ " ) ; } }

Accumulator variables: n
Iterator variables: n
Class/struct names: Test
Java program:
class Node { int key ; Node left , right ; public Node ( int key ) { this . key = key ; left = right = null ; } } class BinaryTree { Node root ; int sum ( Node t ) { if ( t == null ) return 0 ; return t . key + sum ( t . left ) + sum ( t . right ) ; } int uncoveredSumLeft ( Node t ) { if ( t . left == null && t . right == null ) return t . key ; if ( t . left != null ) return t . key + uncoveredSumLeft ( t . left ) ; else return t . key + uncoveredSumLeft ( t . right ) ; } int uncoveredSumRight ( Node t ) { if ( t . left == null && t . right == null ) return t . key ; if ( t . right != null ) return t . key + uncoveredSumRight ( t . right ) ; else return t . key + uncoveredSumRight ( t . left ) ; } int uncoverSum ( Node t ) { int lb = 0 , rb = 0 ; if ( t . left != null ) lb = uncoveredSumLeft ( t . left ) ; if ( t . right != null ) rb = uncoveredSumRight ( t . right ) ; return t . key + lb + rb ; } boolean isSumSame ( Node root ) { int sumUC = uncoverSum ( root ) ; int sumT = sum ( root ) ; return ( sumUC == ( sumT - sumUC ) ) ; } void inorder ( Node root ) { if ( root != null ) { inorder ( root . left ) ; System . out . print ( root . key + " ▁ " ) ; inorder ( root . right ) ; } } public static void main ( String [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 8 ) ; tree . root . left = new Node ( 3 ) ; tree . root . left . left = new Node ( 1 ) ; tree . root . left . right = new Node ( 6 ) ; tree . root . left . right . left = new Node ( 4 ) ; tree . root . left . right . right = new Node ( 7 ) ; tree . root . right = new Node ( 10 ) ; tree . root . right . right = new Node ( 14 ) ; tree . root . right . right . left = new Node ( 13 ) ; if ( tree . isSumSame ( tree . root ) ) System . out . println ( " Sum ▁ of ▁ covered ▁ and ▁ uncovered ▁ is ▁ same " ) ; else System . out . println ( " Sum ▁ of ▁ covered ▁ and ▁ uncovered ▁ is ▁ not ▁ same " ) ; } }

Class/struct names: BinaryTree, Node
Java program:
import java . io . * ; class GFG { static int countSetBits ( int x ) { int count = 0 ; while ( x != 0 ) { x &= ( x - 1 ) ; count ++ ; } return count ; } static int ceilLog2 ( int x ) { int count = 0 ; x -- ; while ( x > 0 ) { x = x >> 1 ; count ++ ; } return count ; } static boolean isBleak ( int n ) { for ( int x = n - ceilLog2 ( n ) ; x < n ; x ++ ) if ( x + countSetBits ( x ) == n ) return false ; return true ; } public static void main ( String [ ] args ) { if ( isBleak ( 3 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; if ( isBleak ( 4 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: count, x
Iterator variables: x
Class/struct names: GFG
Java program:
class GFG { static int countStrings ( int n ) { int a [ ] = new int [ n ] , b [ ] = new int [ n ] ; a [ 0 ] = b [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { a [ i ] = a [ i - 1 ] + b [ i - 1 ] ; b [ i ] = a [ i - 1 ] ; } from 2 ^ n return ( 1 << n ) - a [ n - 1 ] - b [ n - 1 ] ; } public static void main ( String args [ ] ) { System . out . println ( countStrings ( 5 ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class Main { public static int swapBits ( int n , int p1 , int p2 ) { n ^= 1 << p1 ; n ^= 1 << p2 ; return n ; } public static void main ( String [ ] args ) { System . out . print ( " Result ▁ = ▁ " + swapBits ( 28 , 0 , 3 ) ) ; } }

Accumulator variables: n
Class/struct names: Main
Java program:
import java . util . * ; class GFG { static int N = 4 ; static int final_path [ ] = new int [ N + 1 ] ; static boolean visited [ ] = new boolean [ N ] ; static int final_res = Integer . MAX_VALUE ; static void copyToFinal ( int curr_path [ ] ) { for ( int i = 0 ; i < N ; i ++ ) final_path [ i ] = curr_path [ i ] ; final_path [ N ] = curr_path [ 0 ] ; } static int firstMin ( int adj [ ] [ ] , int i ) { int min = Integer . MAX_VALUE ; for ( int k = 0 ; k < N ; k ++ ) if ( adj [ i ] [ k ] < min && i != k ) min = adj [ i ] [ k ] ; return min ; } static int secondMin ( int adj [ ] [ ] , int i ) { int first = Integer . MAX_VALUE , second = Integer . MAX_VALUE ; for ( int j = 0 ; j < N ; j ++ ) { if ( i == j ) continue ; if ( adj [ i ] [ j ] <= first ) { second = first ; first = adj [ i ] [ j ] ; } else if ( adj [ i ] [ j ] <= second && adj [ i ] [ j ] != first ) second = adj [ i ] [ j ] ; } return second ; } static void TSPRec ( int adj [ ] [ ] , int curr_bound , int curr_weight , int level , int curr_path [ ] ) { if ( level == N ) { if ( adj [ curr_path [ level - 1 ] ] [ curr_path [ 0 ] ] != 0 ) { int curr_res = curr_weight + adj [ curr_path [ level - 1 ] ] [ curr_path [ 0 ] ] ; if ( curr_res < final_res ) { copyToFinal ( curr_path ) ; final_res = curr_res ; } } return ; } for ( int i = 0 ; i < N ; i ++ ) { if ( adj [ curr_path [ level - 1 ] ] [ i ] != 0 && visited [ i ] == false ) { int temp = curr_bound ; curr_weight += adj [ curr_path [ level - 1 ] ] [ i ] ; if ( level == 1 ) curr_bound -= ( ( firstMin ( adj , curr_path [ level - 1 ] ) + firstMin ( adj , i ) ) / 2 ) ; else curr_bound -= ( ( secondMin ( adj , curr_path [ level - 1 ] ) + firstMin ( adj , i ) ) / 2 ) ; if ( curr_bound + curr_weight < final_res ) { curr_path [ level ] = i ; visited [ i ] = true ; TSPRec ( adj , curr_bound , curr_weight , level + 1 , curr_path ) ; } curr_weight -= adj [ curr_path [ level - 1 ] ] [ i ] ; curr_bound = temp ; Arrays . fill ( visited , false ) ; for ( int j = 0 ; j <= level - 1 ; j ++ ) visited [ curr_path [ j ] ] = true ; } } } static void TSP ( int adj [ ] [ ] ) { int curr_path [ ] = new int [ N + 1 ] ; int curr_bound = 0 ; Arrays . fill ( curr_path , - 1 ) ; Arrays . fill ( visited , false ) ; for ( int i = 0 ; i < N ; i ++ ) curr_bound += ( firstMin ( adj , i ) + secondMin ( adj , i ) ) ; curr_bound = ( curr_bound == 1 ) ? curr_bound / 2 + 1 : curr_bound / 2 ; visited [ 0 ] = true ; curr_path [ 0 ] = 0 ; TSPRec ( adj , curr_bound , 0 , 1 , curr_path ) ; } public static void main ( String [ ] args ) { int adj [ ] [ ] = { { 0 , 10 , 15 , 20 } , { 10 , 0 , 35 , 25 } , { 15 , 35 , 0 , 30 } , { 20 , 25 , 30 , 0 } } ; TSP ( adj ) ; System . out . printf ( "Minimum cost : %dNEW_LINE", final_res); System . out . printf ( " Path ▁ Taken ▁ : ▁ " ) ; for ( int i = 0 ; i <= N ; i ++ ) { System . out . printf ( " % d ▁ " , final_path [ i ] ) ; } } }

Index/key variables: N, i, j, k, level
Accumulator variables: curr_bound, curr_weight, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
class Node { int data ; Node left , right ; Node ( int item ) { data = item ; left = right = null ; } } class BinaryTree { Node root ; boolean isSibling ( Node node , Node a , Node b ) { if ( node == null ) return false ; return ( ( node . left == a && node . right == b ) || ( node . left == b && node . right == a ) || isSibling ( node . left , a , b ) || isSibling ( node . right , a , b ) ) ; } int level ( Node node , Node ptr , int lev ) { if ( node == null ) return 0 ; if ( node == ptr ) return lev ; int l = level ( node . left , ptr , lev + 1 ) ; if ( l != 0 ) return l ; return level ( node . right , ptr , lev + 1 ) ; } boolean isCousin ( Node node , Node a , Node b ) { return ( ( level ( node , a , 1 ) == level ( node , b , 1 ) ) && ( ! isSibling ( node , a , b ) ) ) ; } public static void main ( String args [ ] ) { BinaryTree tree = new BinaryTree ( ) ; 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 ) ; tree . root . left . right . right = new Node ( 15 ) ; tree . root . right . left = new Node ( 6 ) ; tree . root . right . right = new Node ( 7 ) ; tree . root . right . left . right = new Node ( 8 ) ; Node Node1 , Node2 ; Node1 = tree . root . left . left ; Node2 = tree . root . right . right ; if ( tree . isCousin ( tree . root , Node1 , Node2 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Class/struct names: BinaryTree, Node
Java program:
import java . util . * ; class GFG { static class Node { int data ; Node prev , next ; static Node getnode ( int data ) { Node newNode = new Node ( ) ; newNode . data = data ; newNode . prev = newNode . next = null ; return newNode ; } } ; static class Deque { Node front ; Node rear ; int Size ; Deque ( ) { front = rear = null ; Size = 0 ; } boolean isEmpty ( ) { return ( front == null ) ; } int size ( ) { return Size ; } void insertFront ( int data ) { Node newNode = Node . getnode ( data ) ; if ( newNode == null ) System . out . print ( "OverFlowNEW_LINE"); else { if ( front == null ) rear = front = newNode ; else { newNode . next = front ; front . prev = newNode ; front = newNode ; } Size ++ ; } } void insertRear ( int data ) { Node newNode = Node . getnode ( data ) ; if ( newNode == null ) System . out . print ( "OverFlowNEW_LINE"); else { if ( rear == null ) front = rear = newNode ; else { newNode . prev = rear ; rear . next = newNode ; rear = newNode ; } Size ++ ; } } void deleteFront ( ) { if ( isEmpty ( ) ) System . out . print ( "UnderFlowNEW_LINE"); else { Node temp = front ; front = front . next ; if ( front == null ) rear = null ; else front . prev = null ; Size -- ; } } void deleteRear ( ) { if ( isEmpty ( ) ) System . out . print ( "UnderFlowNEW_LINE"); else { Node temp = rear ; rear = rear . prev ; if ( rear == null ) front = null ; else rear . next = null ; Size -- ; } } int getFront ( ) { if ( isEmpty ( ) ) return - 1 ; return front . data ; } int getRear ( ) { if ( isEmpty ( ) ) return - 1 ; return rear . data ; } void erase ( ) { rear = null ; while ( front != null ) { Node temp = front ; front = front . next ; } Size = 0 ; } } public static void main ( String [ ] args ) { Deque dq = new Deque ( ) ; System . out . print ( "Insert element '5' at rear endNEW_LINE"); dq . insertRear ( 5 ) ; System . out . print ( "Insert element '10' at rear endNEW_LINE"); dq . insertRear ( 10 ) ; System . out . print ( " Rear ▁ end ▁ element : ▁ " + dq . getRear ( ) + "NEW_LINE"); dq . deleteRear ( ) ; System . out . print ( " After ▁ deleting ▁ rear ▁ element ▁ new ▁ rear " + " ▁ is : ▁ " + dq . getRear ( ) + "NEW_LINE"); System . out . print ( "Inserting element '15' at front end NEW_LINE"); dq . insertFront ( 15 ) ; System . out . print ( " Front ▁ end ▁ element : ▁ " + dq . getFront ( ) + "NEW_LINE"); System . out . print ( " Number ▁ of ▁ elements ▁ in ▁ Deque : ▁ " + dq . size ( ) + "NEW_LINE"); dq . deleteFront ( ) ; System . out . print ( " After ▁ deleting ▁ front ▁ element ▁ new ▁ " + " front ▁ is : ▁ " + dq . getFront ( ) + "NEW_LINE"); } }

Accumulator variables: Size
Class/struct names: Deque, GFG, Node
Java program:
class Node { int data ; Node left , right ; Node ( int item ) { data = item ; left = right = null ; } } class Leaf { int leaflevel = 0 ; } class BinaryTree { Node root ; Leaf mylevel = new Leaf ( ) ; boolean checkUtil ( Node node , int level , Leaf leafLevel ) { if ( node == null ) return true ; if ( node . left == null && node . right == null ) { if ( leafLevel . leaflevel == 0 ) { leafLevel . leaflevel = level ; return true ; } return ( level == leafLevel . leaflevel ) ; } return checkUtil ( node . left , level + 1 , leafLevel ) && checkUtil ( node . right , level + 1 , leafLevel ) ; } boolean check ( Node node ) { int level = 0 ; return checkUtil ( node , level , mylevel ) ; } public static void main ( String args [ ] ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 12 ) ; tree . root . left = new Node ( 5 ) ; tree . root . left . left = new Node ( 3 ) ; tree . root . left . right = new Node ( 9 ) ; tree . root . left . left . left = new Node ( 1 ) ; tree . root . left . right . left = new Node ( 1 ) ; if ( tree . check ( tree . root ) ) System . out . println ( " Leaves ▁ are ▁ at ▁ same ▁ level " ) ; else System . out . println ( " Leaves ▁ are ▁ not ▁ at ▁ same ▁ level " ) ; } }

Class/struct names: BinaryTree, Leaf, Node
Java program:
import java . util . * ; class GFG { static class Node { int key ; Vector < Node > child ; Node ( int data ) { key = data ; child = new Vector < Node > ( ) ; } } ; static int numberOfSiblings ( Node root , int x ) { if ( root == null ) return 0 ; Queue < Node > q = new LinkedList < > ( ) ; q . add ( root ) ; while ( q . size ( ) > 0 ) { Node p = q . peek ( ) ; q . remove ( ) ; for ( int i = 0 ; i < p . child . size ( ) ; i ++ ) { if ( p . child . get ( i ) . key == x ) return p . child . size ( ) - 1 ; q . add ( p . child . get ( i ) ) ; } } return - 1 ; } public static void main ( String args [ ] ) { Node root = new Node ( 50 ) ; ( root . child ) . add ( new Node ( 2 ) ) ; ( root . child ) . add ( new Node ( 30 ) ) ; ( root . child ) . add ( new Node ( 14 ) ) ; ( root . child ) . add ( new Node ( 60 ) ) ; ( root . child . get ( 0 ) . child ) . add ( new Node ( 15 ) ) ; ( root . child . get ( 0 ) . child ) . add ( new Node ( 25 ) ) ; ( root . child . get ( 0 ) . child . get ( 1 ) . child ) . add ( new Node ( 70 ) ) ; ( root . child . get ( 0 ) . child . get ( 1 ) . child ) . add ( new Node ( 100 ) ) ; ( root . child . get ( 1 ) . child ) . add ( new Node ( 6 ) ) ; ( root . child . get ( 1 ) . child ) . add ( new Node ( 1 ) ) ; ( root . child . get ( 2 ) . child ) . add ( new Node ( 7 ) ) ; ( root . child . get ( 2 ) . child . get ( 0 ) . child ) . add ( new Node ( 17 ) ) ; ( root . child . get ( 2 ) . child . get ( 0 ) . child ) . add ( new Node ( 99 ) ) ; ( root . child . get ( 2 ) . child . get ( 0 ) . child ) . add ( new Node ( 27 ) ) ; ( root . child . get ( 3 ) . child ) . add ( new Node ( 16 ) ) ; int x = 100 ; System . out . println ( numberOfSiblings ( root , x ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
Java program:
import java . util . * ; class Node { int data ; Node left , right ; Node ( int key ) { int data = key ; left = right = null ; } } class GFG { static boolean checkLevelLeafNode ( Node root ) { if ( root == null ) return true ; Queue < Node > q = new LinkedList < > ( ) ; q . add ( root ) ; int result = Integer . MAX_VALUE ; int level = 0 ; while ( q . size ( ) != 0 ) { int size = q . size ( ) ; level ++ ; while ( size > 0 ) { Node temp = q . remove ( ) ; if ( temp . left != null ) { q . add ( temp . left ) ; if ( temp . left . left == null && temp . left . right == null ) { if ( result == Integer . MAX_VALUE ) result = level ; else if ( result != level ) return false ; } } if ( temp . right != null ) { q . add ( temp . right ) ; if ( temp . right . left == null && temp . right . right == null ) { if ( result == Integer . MAX_VALUE ) result = level ; else if ( result != level ) return false ; } } size -- ; } } return true ; } public static void main ( String args [ ] ) { Node root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 3 ) ; root . left . right = new Node ( 4 ) ; root . right . left = new Node ( 5 ) ; root . right . right = new Node ( 6 ) ; boolean result = checkLevelLeafNode ( root ) ; if ( result == true ) System . out . println ( " All ▁ leaf ▁ nodes ▁ are ▁ at ▁ same ▁ level " ) ; else System . out . println ( " Leaf ▁ nodes ▁ not ▁ at ▁ same ▁ level " ) ; } }

Accumulator variables: level, size
Class/struct names: GFG, Node
Java program:
import java . util . LinkedList ; import java . util . Queue ; public class QueueExample { public static void main ( String [ ] args ) { Queue < Integer > q = new LinkedList < > ( ) ; for ( int i = 0 ; i < 5 ; i ++ ) q . add ( i ) ; System . out . println ( " Elements ▁ of ▁ queue - " + q ) ; int removedele = q . remove ( ) ; System . out . println ( " removed ▁ element - " + removedele ) ; System . out . println ( q ) ; int head = q . peek ( ) ; System . out . println ( " head ▁ of ▁ queue - " + head ) ; int size = q . size ( ) ; System . out . println ( " Size ▁ of ▁ queue - " + size ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: QueueExample