dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static boolean CompareAlphanumeric ( char [ ] str1 , char [ ] str2 ) { int i , j ; i = 0 ; j = 0 ; int len1 = str1 . length ; int len2 = str2 . length ; while ( i <= len1 && j <= len2 ) { while ( i < len1 && ( ! ( ( str1 [ i ] >= ' a ' && str1 [ i ] <= ' z ' ) || ( str1 [ i ] >= ' A ' && str1 [ i ] <= ' Z ' ) || ( str1 [ i ] >= '0' && str1 [ i ] <= '9' ) ) ) ) { i ++ ; } while ( j < len2 && ( ! ( ( str2 [ j ] >= ' a ' && str2 [ j ] <= ' z ' ) || ( str2 [ j ] >= ' A ' && str2 [ j ] <= ' Z ' ) || ( str2 [ j ] >= '0' && str2 [ j ] <= '9' ) ) ) ) { j ++ ; } if ( i == len1 && j == len2 ) { return true ; } else if ( str1 [ i ] != str2 [ j ] ) { return false ; } else { i ++ ; j ++ ; } } return false ; } static void CompareAlphanumericUtil ( String str1 , String str2 ) { boolean res ; res = CompareAlphanumeric ( str1 . toCharArray ( ) , str2 . toCharArray ( ) ) ; if ( res == true ) { System . out . println ( " Equal " ) ; } else { System . out . println ( " Unequal " ) ; } } public static void main ( String [ ] args ) { String str1 , str2 ; str1 = " Ram , ▁ Shyam " ; str2 = " ▁ Ram ▁ - ▁ Shyam . " ; CompareAlphanumericUtil ( str1 , str2 ) ; str1 = " abc123" ; str2 = "123abc " ; CompareAlphanumericUtil ( str1 , str2 ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static void solveQueries ( String str , int [ ] [ ] query ) { int len = str . length ( ) ; int Q = query . length ; int [ ] [ ] pre = new int [ len ] [ 26 ] ; for ( int i = 0 ; i < len ; i ++ ) { pre [ i ] [ str . charAt ( i ) - ' a ' ] ++ ; if ( i > 0 ) { for ( int j = 0 ; j < 26 ; j ++ ) pre [ i ] [ j ] += pre [ i - 1 ] [ j ] ; } } for ( int i = 0 ; i < Q ; i ++ ) { int l = query [ i ] [ 0 ] ; int r = query [ i ] [ 1 ] ; int maxi = 0 ; char c = ' a ' ; for ( int j = 0 ; j < 26 ; j ++ ) { int times = pre [ r ] [ j ] ; if ( l > 0 ) times -= pre [ l - 1 ] [ j ] ; if ( times > maxi ) { maxi = times ; c = ( char ) ( ' a ' + j ) ; } } System . out . println ( " Query " + ( i + 1 ) + " : ▁ " + c ) ; } } public static void main ( String [ ] args ) { String str = " striver " ; int [ ] [ ] query = { { 0 , 1 } , { 1 , 6 } , { 5 , 6 } } ; solveQueries ( str , query ) ; } }

Index/key variables: i, j, len, r
Accumulator variables: i, j, times
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean startsWith ( String str , String pre ) { int strLen = str . length ( ) ; int preLen = pre . length ( ) ; int i = 0 , j = 0 ; while ( i < strLen && j < preLen ) { if ( str . charAt ( i ) != pre . charAt ( j ) ) return false ; i ++ ; j ++ ; } return true ; } static boolean endsWith ( String str , String suff ) { int i = str . length ( ) - 1 ; int j = suff . length ( ) - 1 ; while ( i >= 0 && j >= 0 ) { if ( str . charAt ( i ) != suff . charAt ( j ) ) return false ; i -- ; j -- ; } return true ; } static boolean checkString ( String str , String a , String b ) { if ( str . length ( ) != a . length ( ) + b . length ( ) ) return false ; if ( startsWith ( str , a ) ) { if ( endsWith ( str , b ) ) return true ; } if ( startsWith ( str , b ) ) { if ( endsWith ( str , a ) ) return true ; } return false ; } public static void main ( String args [ ] ) { String str = " GeeksforGeeks " ; String a = " Geeksfo " ; String b = " rGeeks " ; if ( checkString ( str , a , b ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: i, j
Class/struct names: GFG
Java program:
class GFG { public static void printChar ( String str , int n ) { int [ ] freq = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) freq [ str . charAt ( i ) - ' a ' ] ++ ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq [ str . charAt ( i ) - ' a ' ] % 2 == 1 ) { System . out . print ( str . charAt ( i ) ) ; } } } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; int n = str . length ( ) ; printChar ( str , n ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int minOperations ( String str , int n ) { int i , lastUpper = - 1 , firstLower = - 1 ; for ( i = n - 1 ; i >= 0 ; i -- ) { if ( Character . isUpperCase ( str . charAt ( i ) ) ) { lastUpper = i ; break ; } } for ( i = 0 ; i < n ; i ++ ) { if ( Character . isLowerCase ( str . charAt ( i ) ) ) { firstLower = i ; break ; } } if ( lastUpper == - 1 firstLower == - 1 ) return 0 ; int countUpper = 0 ; for ( i = firstLower ; i < n ; i ++ ) { if ( Character . isUpperCase ( str . charAt ( i ) ) ) { countUpper ++ ; } } int countLower = 0 ; for ( i = 0 ; i < lastUpper ; i ++ ) { if ( Character . isLowerCase ( str . charAt ( i ) ) ) { countLower ++ ; } } return Math . min ( countLower , countUpper ) ; } public static void main ( String args [ ] ) { String str = " geEksFOrGEekS " ; int n = str . length ( ) ; System . out . println ( minOperations ( str , n ) ) ; } }

Accumulator variables: countLower, countUpper, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static int Betrothed_Sum ( int n ) { Vector < Integer > Set = new Vector < Integer > ( ) ; for ( int number_1 = 1 ; number_1 < n ; number_1 ++ ) { int sum_divisor_1 = 1 ; int i = 2 ; while ( i * i <= number_1 ) { if ( number_1 % i == 0 ) { sum_divisor_1 = sum_divisor_1 + i ; if ( i * i != number_1 ) sum_divisor_1 += number_1 / i ; } i ++ ; } if ( sum_divisor_1 > number_1 ) { int number_2 = sum_divisor_1 - 1 ; int sum_divisor_2 = 1 ; int j = 2 ; while ( j * j <= number_2 ) { if ( number_2 % j == 0 ) { sum_divisor_2 += j ; if ( j * j != number_2 ) sum_divisor_2 += number_2 / j ; } j = j + 1 ; } if ( sum_divisor_2 == number_1 + 1 && number_1 <= n && number_2 <= n ) { Set . add ( number_1 ) ; Set . add ( number_2 ) ; } } } int Summ = 0 ; for ( int i = 0 ; i < Set . size ( ) ; i ++ ) { if ( Set . get ( i ) <= n ) Summ += Set . get ( i ) ; } return Summ ; } public static void main ( String [ ] args ) { int n = 78 ; System . out . println ( Betrothed_Sum ( n ) ) ; } }

Accumulator variables: Summ, i, number_1, sum_divisor_1, sum_divisor_2
Iterator variables: i, number_1
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static float rainDayProbability ( int a [ ] , int n ) { float count = 0 , m ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 1 ) count ++ ; } m = count / n ; return m ; } public static void main ( String args [ ] ) { int a [ ] = { 1 , 0 , 1 , 0 , 1 , 1 , 1 , 1 } ; int n = a . length ; System . out . print ( rainDayProbability ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class Maths { static double Series ( int n ) { int i ; double sums = 0.0 , ser ; for ( i = 1 ; i <= n ; ++ i ) { ser = 1 / Math . pow ( i , i ) ; sums += ser ; } return sums ; } public static void main ( String [ ] args ) { int n = 3 ; double res = Series ( n ) ; res = Math . round ( res * 100000.0 ) / 100000.0 ; System . out . println ( res ) ; } }

Accumulator variables: sums
Iterator variables: i
Class/struct names: Maths
Java program:
import java . util . * ; public class Main { static String lexicographicallyMaximum ( String S , int N ) { HashMap < Character , Integer > M = new HashMap < > ( ) ; for ( int i = 0 ; i < N ; ++ i ) { if ( M . containsKey ( S . charAt ( i ) ) ) M . put ( S . charAt ( i ) , M . get ( S . charAt ( i ) ) + 1 ) ; else M . put ( S . charAt ( i ) , 1 ) ; } Vector < Character > V = new Vector < Character > ( ) ; for ( char i = ' a ' ; i < ( char ) ( ' a ' + Math . min ( N , 25 ) ) ; ++ i ) { if ( M . containsKey ( i ) == false ) { V . add ( i ) ; } } int j = V . size ( ) - 1 ; for ( int i = 0 ; i < N ; ++ i ) { if ( S . charAt ( i ) >= ( ' a ' + Math . min ( N , 25 ) ) || ( M . containsKey ( S . charAt ( i ) ) && M . get ( S . charAt ( i ) ) > 1 ) ) { if ( V . get ( j ) < S . charAt ( i ) ) continue ; M . put ( S . charAt ( i ) , M . get ( S . charAt ( i ) ) - 1 ) ; S = S . substring ( 0 , i ) + V . get ( j ) + S . substring ( i + 1 ) ; j -- ; } if ( j < 0 ) break ; } int l = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( l > j ) break ; if ( S . charAt ( i ) >= ( ' a ' + Math . min ( N , 25 ) ) || M . containsKey ( S . charAt ( i ) ) && M . get ( S . charAt ( i ) ) > 1 ) { M . put ( S . charAt ( i ) , M . get ( S . charAt ( i ) ) - 1 ) ; S = S . substring ( 0 , i ) + V . get ( l ) + S . substring ( i + 1 ) ; l ++ ; } } return S ; } public static void main ( String [ ] args ) { String S = " abccefghh " ; int N = S . length ( ) ; System . out . println ( lexicographicallyMaximum ( S , N ) ) ; } }

Accumulator variables: i, j, l
Iterator variables: i
Class/struct names: Main
Java program:
import java . util . * ; class GFG { static boolean isConsistingSubarrayUtil ( int arr [ ] , int n ) { TreeMap < Integer , Integer > mp = new TreeMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; ++ i ) { mp . put ( arr [ i ] , mp . getOrDefault ( arr [ i ] , 0 ) + 1 ) ; } for ( Map . Entry < Integer , Integer > it : mp . entrySet ( ) ) { if ( it . getValue ( ) > 1 ) { return true ; } } return false ; } static void isConsistingSubarray ( int arr [ ] , int N ) { if ( isConsistingSubarrayUtil ( arr , N ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 1 } ; int N = arr . length ; isConsistingSubarray ( arr , N ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean [ ] isPrime ; static HashSet < Integer > createhashmap ( int Max ) { HashSet < Integer > hashmap = new HashSet < > ( ) ; int curr = 1 ; int prev = 0 ; hashmap . add ( prev ) ; while ( curr < Max ) { hashmap . add ( curr ) ; int temp = curr ; curr = curr + prev ; prev = temp ; } return hashmap ; } static void SieveOfEratosthenes ( int Max ) { isPrime = new boolean [ Max ] ; Arrays . fill ( isPrime , true ) ; isPrime [ 0 ] = false ; isPrime [ 1 ] = false ; for ( int p = 2 ; p * p <= Max ; p ++ ) { if ( isPrime [ p ] ) { for ( int i = p * p ; i <= Max ; i += p ) { isPrime [ i ] = false ; } } } } static void cntFibonacciPrime ( int arr [ ] , int N ) { int Max = arr [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { Max = Math . max ( Max , arr [ i ] ) ; } SieveOfEratosthenes ( Max ) ; HashSet < Integer > hashmap = createhashmap ( Max ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 1 ) continue ; if ( ( hashmap . contains ( arr [ i ] ) ) && ! isPrime [ arr [ i ] ] ) { System . out . print ( arr [ i ] + " ▁ " ) ; } } } public static void main ( String [ ] args ) { int arr [ ] = { 13 , 55 , 7 , 3 , 5 , 21 , 233 , 144 , 89 } ; int N = arr . length ; cntFibonacciPrime ( arr , N ) ; } }

Index/key variables: Max, i, p
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; import java . lang . * ; public class Main { static int key ( int N ) { String num = " " + N ; int ans = 0 ; int j = 0 ; for ( j = 0 ; j < num . length ( ) ; j ++ ) { if ( ( num . charAt ( j ) - 48 ) % 2 == 0 ) { int add = 0 ; int i ; for ( i = j ; j < num . length ( ) ; j ++ ) { add += num . charAt ( j ) - 48 ; if ( add % 2 == 1 ) break ; } if ( add == 0 ) { ans *= 10 ; } else { int digit = ( int ) Math . floor ( Math . log10 ( add ) + 1 ) ; ans *= ( Math . pow ( 10 , digit ) ) ; ans += add ; } i = j ; } else { int add = 0 ; int i ; for ( i = j ; j < num . length ( ) ; j ++ ) { add += num . charAt ( j ) - 48 ; if ( add % 2 == 0 ) { break ; } } if ( add == 0 ) { ans *= 10 ; } else { int digit = ( int ) Math . floor ( Math . log10 ( add ) + 1 ) ; ans *= ( Math . pow ( 10 , digit ) ) ; ans += add ; } i = j ; } } if ( j + 1 >= num . length ( ) ) { return ans ; } else { return ans += num . charAt ( num . length ( ) - 1 ) - 48 ; } } public static void main ( String [ ] args ) { int N = 1667848271 ; System . out . print ( key ( N ) ) ; } }

Accumulator variables: add, ans, j
Iterator variables: i, j
Class/struct names: Main
Java program:
class GFG { static void sentinelSearch ( int arr [ ] , int n , int key ) { int last = arr [ n - 1 ] ; arr [ n - 1 ] = key ; int i = 0 ; while ( arr [ i ] != key ) i ++ ; arr [ n - 1 ] = last ; if ( ( i < n - 1 ) || ( arr [ n - 1 ] == key ) ) System . out . println ( key + " ▁ is ▁ present ▁ at ▁ index ▁ " + i ) ; else System . out . println ( " Element ▁ Not ▁ found " ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 10 , 20 , 180 , 30 , 60 , 50 , 110 , 100 , 70 } ; int n = arr . length ; int key = 180 ; sentinelSearch ( arr , n , key ) ; } }

Index/key variables: i
Accumulator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maximum_middle_value ( int n , int k , int arr [ ] ) { int ans = - 1 ; int low = ( n + 1 - k ) / 2 ; int high = ( n + 1 - k ) / 2 + k ; for ( int i = low ; i <= high ; i ++ ) { ans = Math . max ( ans , arr [ i - 1 ] ) ; } return ans ; } public static void main ( String args [ ] ) { int n = 5 , k = 2 ; int arr [ ] = { 9 , 5 , 3 , 7 , 10 } ; System . out . println ( maximum_middle_value ( n , k , arr ) ) ; n = 9 ; k = 3 ; int arr1 [ ] = { 2 , 4 , 3 , 9 , 5 , 8 , 7 , 6 , 10 } ; System . out . println ( maximum_middle_value ( n , k , arr1 ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int ternarySearch ( int l , int r , int key , int ar [ ] ) { if ( r >= l ) { int mid1 = l + ( r - l ) / 3 ; int mid2 = r - ( r - l ) / 3 ; if ( ar [ mid1 ] == key ) { return mid1 ; } if ( ar [ mid2 ] == key ) { return mid2 ; } if ( key < ar [ mid1 ] ) { return ternarySearch ( l , mid1 - 1 , key , ar ) ; } else if ( key > ar [ mid2 ] ) { return ternarySearch ( mid2 + 1 , r , key , ar ) ; } else { return ternarySearch ( mid1 + 1 , mid2 - 1 , key , ar ) ; } } return - 1 ; } public static void main ( String args [ ] ) { int l , r , p , key ; int ar [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } ; l = 0 ; r = 9 ; key = 5 ; p = ternarySearch ( l , r , key , ar ) ; System . out . println ( " Index ▁ of ▁ " + key + " ▁ is ▁ " + p ) ; key = 50 ; p = ternarySearch ( l , r , key , ar ) ; System . out . println ( " Index ▁ of ▁ " + key + " ▁ is ▁ " + p ) ; } }

Index/key variables: mid1, mid2
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class Point { int x , y ; public Point ( int x , int y ) { this . x = x ; this . y = y ; } } ; static int findmin ( Point p [ ] , int n ) { int a = 0 , b = 0 , c = 0 , d = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( p [ i ] . x <= 0 ) a ++ ; else if ( p [ i ] . x >= 0 ) b ++ ; if ( p [ i ] . y >= 0 ) c ++ ; else if ( p [ i ] . y <= 0 ) d ++ ; } return Math . min ( Math . min ( a , b ) , Math . min ( c , d ) ) ; } public static void main ( String [ ] args ) { Point p [ ] = { new Point ( 1 , 1 ) , new Point ( 2 , 2 ) , new Point ( - 1 , - 1 ) , new Point ( - 2 , 2 ) } ; int n = p . length ; System . out . println ( findmin ( p , n ) ) ; } }

Index/key variables: i
Accumulator variables: a, b, c, d, i
Iterator variables: i
Class/struct names: GFG, Point
Java program:
import java . util . * ; class GFG { static void maxOps ( int a , int b , int c ) { int arr [ ] = { a , b , c } ; int count = 0 ; while ( 1 != 0 ) { Arrays . sort ( arr ) ; if ( arr [ 0 ] == 0 && arr [ 1 ] == 0 ) break ; arr [ 1 ] -= 1 ; arr [ 2 ] -= 1 ; count += 1 ; } System . out . print ( count ) ; } public static void main ( String [ ] args ) { int a = 4 , b = 3 , c = 2 ; maxOps ( a , b , c ) ; } }

Accumulator variables: count
Class/struct names: GFG
Java program:
import java . lang . Character ; class GFG { static int MAX = 26 ; public static String getSortedString ( StringBuilder s , int n ) { int [ ] lower = new int [ MAX ] ; int [ ] upper = new int [ MAX ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( Character . isLowerCase ( s . charAt ( i ) ) ) lower [ s . charAt ( i ) - ' a ' ] ++ ; else if ( Character . isUpperCase ( s . charAt ( i ) ) ) upper [ s . charAt ( i ) - ' A ' ] ++ ; } int i = 0 , j = 0 ; while ( i < MAX && lower [ i ] == 0 ) i ++ ; while ( j < MAX && upper [ j ] == 0 ) j ++ ; for ( int k = 0 ; k < n ; k ++ ) { if ( Character . isLowerCase ( s . charAt ( k ) ) ) { while ( lower [ i ] == 0 ) i ++ ; s . setCharAt ( k , ( char ) ( i + ' a ' ) ) ; lower [ i ] -- ; } else if ( Character . isUpperCase ( s . charAt ( k ) ) ) { while ( upper [ j ] == 0 ) j ++ ; s . setCharAt ( k , ( char ) ( j + ' A ' ) ) ; upper [ j ] -- ; } } return s . toString ( ) ; } public static void main ( String [ ] args ) { StringBuilder s = new StringBuilder ( " gEeksfOrgEEkS " ) ; int n = s . length ( ) ; System . out . println ( getSortedString ( s , n ) ) ; } }

Index/key variables: MAX, i, j
Accumulator variables: i, j, k
Iterator variables: i, k
Class/struct names: GFG
Java program:
public class Char_frequency { static final int SIZE = 26 ; static void printCharWithFreq ( String str ) { int n = str . length ( ) ; int [ ] freq = new int [ SIZE ] ; for ( int i = 0 ; i < n ; i ++ ) freq [ str . charAt ( i ) - ' a ' ] ++ ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq [ str . charAt ( i ) - ' a ' ] != 0 ) { System . out . print ( str . charAt ( i ) ) ; System . out . print ( freq [ str . charAt ( i ) - ' a ' ] + " ▁ " ) ; freq [ str . charAt ( i ) - ' a ' ] = 0 ; } } } public static void main ( String args [ ] ) { String str = " geeksforgeeks " ; printCharWithFreq ( str ) ; } }

Index/key variables: SIZE
Accumulator variables: i
Iterator variables: i
Class/struct names: Char_frequency
Java program:
public class ReverseWords { public static void main ( String [ ] args ) { String s [ ] = " i ▁ like ▁ this ▁ program ▁ very ▁ much " . split ( " ▁ " ) ; String ans = " " ; for ( int i = s . length - 1 ; i >= 0 ; i -- ) { ans += s [ i ] + " ▁ " ; } System . out . println ( " Reversed ▁ String : " ) ; System . out . println ( ans . substring ( 0 , ans . length ( ) - 1 ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: ReverseWords
Java program:
import java . util . * ; class GFG { public static void SieveOfEratosthenes ( boolean [ ] prime , 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 ; } } } public static void segregatePrimeNonPrime ( boolean [ ] prime , int arr [ ] , int N ) { SieveOfEratosthenes ( prime , 10000000 ) ; int left = 0 , right = N - 1 ; while ( left < right ) { while ( prime [ arr [ left ] ] ) left ++ ; while ( ! prime [ arr [ right ] ] ) right -- ; if ( left < right ) { int temp = arr [ left ] ; arr [ left ] = arr [ right ] ; arr [ right ] = temp ; left ++ ; right -- ; } } for ( int i = 0 ; i < N ; i ++ ) System . out . printf ( arr [ i ] + " ▁ " ) ; } public static void main ( String [ ] args ) { boolean [ ] prime = new boolean [ 10000001 ] ; Arrays . fill ( prime , true ) ; int arr [ ] = { 2 , 3 , 4 , 6 , 7 , 8 , 9 , 10 } ; int N = arr . length ; segregatePrimeNonPrime ( prime , arr , N ) ; } }

Index/key variables: i, left, p, right
Accumulator variables: i, left, p, right
Iterator variables: i, p
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int findDepthRec ( String tree , int n , int index ) { if ( index >= n || tree . charAt ( index ) == ' l ' ) return 0 ; index ++ ; int left = findDepthRec ( tree , n , index ) ; index ++ ; int right = findDepthRec ( tree , n , index ) ; return Math . max ( left , right ) + 1 ; } static int findDepth ( String tree , int n ) { int index = 0 ; return ( findDepthRec ( tree , n , index ) ) ; } static public void main ( String [ ] args ) { String tree = " nlnnlll " ; int n = tree . length ( ) ; System . out . println ( findDepth ( tree , n ) ) ; } }

Accumulator variables: index
Class/struct names: GFG
Java program:
class GfG { static class Node { int key ; Node left , right ; } static Node newNode ( int item ) { Node temp = new Node ( ) ; temp . key = item ; temp . left = null ; temp . right = null ; return temp ; } static Node insert ( Node node , int key ) { if ( node == null ) return newNode ( key ) ; if ( key < node . key ) node . left = insert ( node . left , key ) ; else if ( key > node . key ) node . right = insert ( node . right , key ) ; return node ; } static int findMaxforN ( Node root , int N ) { if ( root == null ) return - 1 ; if ( root . key == N ) return N ; else if ( root . key < N ) { int k = findMaxforN ( root . right , N ) ; if ( k == - 1 ) return root . key ; else return k ; } else if ( root . key > N ) return findMaxforN ( root . left , N ) ; return - 1 ; } public static void main ( String [ ] args ) { int N = 4 ; Node root = null ; root = insert ( root , 25 ) ; insert ( root , 2 ) ; insert ( root , 1 ) ; insert ( root , 3 ) ; insert ( root , 12 ) ; insert ( root , 9 ) ; insert ( root , 21 ) ; insert ( root , 19 ) ; insert ( root , 25 ) ; System . out . println ( findMaxforN ( root , N ) ) ; } }

Class/struct names: GfG, Node
Java program:
class Solution { static class Node { Node left , right ; int data ; } static Node createNode ( int x ) { Node p = new Node ( ) ; p . data = x ; p . left = p . right = null ; return p ; } static void insertNode ( Node root , int x ) { Node p = root , q = null ; while ( p != null ) { q = p ; if ( p . data < x ) p = p . right ; else p = p . left ; } if ( q == null ) p = createNode ( x ) ; else { if ( q . data < x ) q . right = createNode ( x ) ; else q . left = createNode ( x ) ; } } static int maxelpath ( Node q , int x ) { Node p = q ; int mx = - 1 ; while ( p . data != x ) { if ( p . data > x ) { mx = Math . max ( mx , p . data ) ; p = p . left ; } else { mx = Math . max ( mx , p . data ) ; p = p . right ; } } return Math . max ( mx , x ) ; } static int maximumElement ( Node root , int x , int y ) { Node p = root ; while ( ( x < p . data && y < p . data ) || ( x > p . data && y > p . data ) ) { if ( x < p . data && y < p . data ) p = p . left ; else if ( x > p . data && y > p . data ) p = p . right ; } return Math . max ( maxelpath ( p , x ) , maxelpath ( p , y ) ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 18 , 36 , 9 , 6 , 12 , 10 , 1 , 8 } ; int a = 1 , b = 10 ; int n = arr . length ; Node root = createNode ( arr [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) insertNode ( root , arr [ i ] ) ; System . out . println ( maximumElement ( root , a , b ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: Node, Solution