dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
SIZE = 26
def isVowel ( ch ) :
    if ( ch == ' a ' or ch == ' e ' or ch == ' i ' or ch == ' o ' or ch == ' u ' ) :
        return True
    return False
def createAltStr ( str1 , str2 , start , l ) :
    finalStr = " "
    i = 0
    j = start
    while j < l :
        finalStr += str1 [ i ] + str2 [ j ]
        i += 1
        j += 1
    return finalStr
def findAltStr ( string ) :
    nv = 0
    nc = 0
    vstr = " "
    cstr = " "
    l = len ( string )
    for i in range ( l ) :
        ch = string [ i ]
        if isVowel ( ch ) :
            nv += 1
        else :
            nc += 1
        char_freq [ ord ( ch ) - 97 ] += 1
    if abs ( nv - nc ) >= 2 :
        return " no ▁ such ▁ string "
    for i in range ( SIZE ) :
        ch = chr ( i + 97 )
        for j in range ( 1 , char_freq [ i ] + 1 ) :
            if isVowel ( ch ) :
                vstr += ch
            else :
                cstr += ch
    if nv > nc :
        return vstr [ 0 ] + createAltStr ( cstr , vstr , 1 , nv )
    if nc > nv :
        return cstr [ 0 ] + createAltStr ( vstr , cstr , 1 , nc )
    if cstr [ 0 ] < vstr [ 0 ] :
        return createAltStr ( cstr , vstr , 0 , nv )
    return createAltStr ( vstr , cstr , 0 , nc )
if __name__ == " _ _ main _ _ " :
    string = " aeroplane "
    print ( findAltStr ( string ) )

Index/key variables: i, j
Accumulator variables: cstr, finalStr, nc, nv, vstr
Iterator variables: i, j
Python program:
MAX_CHAR = 26
MAX_FACT = 20
fact = [ None ] * ( MAX_FACT )
def precomputeFactorials ( ) :
    fact [ 0 ] = 1
    for i in range ( 1 , MAX_FACT ) :
        fact [ i ] = fact [ i - 1 ] * i
def nPermute ( string , n ) :
    precomputeFactorials ( )
    length = len ( string )
    freq = [ 0 ] * ( MAX_CHAR )
    for i in range ( 0 , length ) :
        freq [ ord ( string [ i ] ) - ord ( ' a ' ) ] += 1
    out = [ None ] * ( MAX_CHAR )
    Sum , k = 0 , 0
    while Sum != n :
        Sum = 0
        for i in range ( 0 , MAX_CHAR ) :
            if freq [ i ] == 0 :
                continue
            freq [ i ] -= 1
            xsum = fact [ length - 1 - k ]
            for j in range ( 0 , MAX_CHAR ) :
                xsum = xsum // fact [ freq [ j ] ]
            Sum += xsum
            if Sum >= n :
                out [ k ] = chr ( i + ord ( ' a ' ) )
                n -= Sum - xsum
                k += 1
                break
            if Sum < n :
                freq [ i ] += 1
    i = MAX_CHAR - 1
    while k < length and i >= 0 :
        if freq [ i ] :
            out [ k ] = chr ( i + ord ( ' a ' ) )
            freq [ i ] -= 1
            i += 1
            k += 1
        i -= 1
    print ( ' ' . join ( out [ : k ] ) )
if __name__ == " _ _ main _ _ " :
    n = 2
    string = " geeksquiz "
    nPermute ( string , n )

Index/key variables: i, j, k
Accumulator variables: Sum, n
Iterator variables: i, j
Python program:
def countWords ( stri , n ) :
    m = dict ( )
    for i in range ( n ) :
        m [ stri [ i ] ] = m . get ( stri [ i ] , 0 ) + 1
    res = 0
    for i in m . values ( ) :
        if i == 2 :
            res += 1
    return res
s = [ " hate " , " love " , " peace " , " love " , " peace " , " hate " , " love " , " peace " , " love " , " peace " ]
n = len ( s )
print ( countWords ( s , n ) )

Index/key variables: i
Accumulator variables: res
Iterator variables: i
Python program:
V = 4
def colorGraph ( G , color , pos , c ) :
    if color [ pos ] != - 1 and color [ pos ] != c :
        return False
    color [ pos ] = c
    ans = True
    for i in range ( 0 , V ) :
        if G [ pos ] [ i ] :
            if color [ i ] == - 1 :
                ans &= colorGraph ( G , color , i , 1 - c )
            if color [ i ] != - 1 and color [ i ] != 1 - c :
                return False
        if not ans :
            return False
    return True
def isBipartite ( G ) :
    color = [ - 1 ] * V
    pos = 0
    return colorGraph ( G , color , pos , 1 )
if __name__ == " _ _ main _ _ " :
    G = [ [ 0 , 1 , 0 , 1 ] , [ 1 , 0 , 1 , 0 ] , [ 0 , 1 , 0 , 1 ] , [ 1 , 0 , 1 , 0 ] ]
    if isBipartite ( G ) : print ( " Yes " )
    else : print ( " No " )

Index/key variables: i, pos
Accumulator variables: ans
Iterator variables: i
Boolean variables: ans
Python program:
import math as mt
def evenlength ( n ) :
    res = n
    for j in range ( len ( n ) - 1 , - 1 , - 1 ) :
        res += n [ j ]
    return res
n = "10"
print ( evenlength ( n ) )

Index/key variables: j
Accumulator variables: res
Iterator variables: j
Python program:
def uniqueCharacters ( str ) :
    for i in range ( len ( str ) ) :
        for j in range ( i + 1 , len ( str ) ) :
            if ( str [ i ] == str [ j ] ) :
                return False ;
    return True ;
str = " GeeksforGeeks " ;
if ( uniqueCharacters ( str ) ) :
    print ( " The ▁ String ▁ " , str , " ▁ has ▁ all ▁ unique ▁ characters " ) ;
else :
    print ( " The ▁ String ▁ " , str , " ▁ has ▁ duplicate ▁ characters " ) ;

Index/key variables: i, j
Iterator variables: i, j
Python program:
def check ( s ) :
    if ( len ( s ) >= 10 ) :
        return True
    for i in range ( 1 , len ( s ) ) :
        for j in range ( i + 1 , len ( s ) ) :
            for k in range ( j + 1 , len ( s ) ) :
                s1 = s [ 0 : i ]
                s2 = s [ i : j - i ]
                s3 = s [ j : k - j ]
                s4 = s [ k : len ( s ) - k ]
                if ( s1 != s2 and s1 != s3 and s1 != s4 and s2 != s3 and s2 != s4 and s3 != s4 ) :
                    return True
    return False
if __name__ == ' _ _ main _ _ ' :
    str = " aaabb "
    print ( " Yes " ) if ( check ( str ) ) else print ( " NO " )

Iterator variables: i, j, k
Python program:
def findIndex ( str ) :
    l = len ( str )
    open = [ 0 ] * ( l + 1 )
    close = [ 0 ] * ( l + 1 )
    index = - 1
    open [ 0 ] = 0
    close [ l ] = 0
    if ( str [ 0 ] == ' ( ' ) :
        open [ 1 ] = 1
    if ( str [ l - 1 ] == ' ) ' ) :
        close [ l - 1 ] = 1
    for i in range ( 1 , l ) :
        if ( str [ i ] == ' ( ' ) :
            open [ i + 1 ] = open [ i ] + 1
        else :
            open [ i + 1 ] = open [ i ]
    for i in range ( l - 2 , - 1 , - 1 ) :
        if ( str [ i ] == ' ) ' ) :
            close [ i ] = close [ i + 1 ] + 1
        else :
            close [ i ] = close [ i + 1 ]
    if ( open [ l ] == 0 ) :
        return len
    if ( close [ 0 ] == 0 ) :
        return 0
    for i in range ( l + 1 ) :
        if ( open [ i ] == close [ i ] ) :
            index = i
    return index
str = " ( ( ) ) ) ( ( ) ( ) ( ) ) ) ) "
print ( findIndex ( str ) )

Index/key variables: i, l
Iterator variables: i
Python program:
def decimalToBinary ( num , k_prec ) :
    binary = " "
    Integral = int ( num )
    fractional = num - Integral
    while ( Integral ) :
        rem = Integral % 2
        binary += str ( rem ) ;
        Integral //= 2
    binary = binary [ : : - 1 ]
    binary += ' . '
    while ( k_prec ) :
        fractional *= 2
        fract_bit = int ( fractional )
        if ( fract_bit == 1 ) :
            fractional -= fract_bit
            binary += '1'
        else :
            binary += '0'
        k_prec -= 1
    return binary
if __name__ == " _ _ main _ _ " :
    n = 4.47
    k = 3
    print ( decimalToBinary ( n , k ) )
    n = 6.986
    k = 5
    print ( decimalToBinary ( n , k ) )

Accumulator variables: Integral, binary, fractional, k_prec
Python program:
def isSmaller ( str1 , str2 ) :
    n1 = len ( str1 )
    n2 = len ( str2 )
    if ( n1 < n2 ) :
        return True
    if ( n2 < n1 ) :
        return False
    for i in range ( n1 ) :
        if ( str1 [ i ] < str2 [ i ] ) :
            return True
        elif ( str1 [ i ] > str2 [ i ] ) :
            return False
    return False
def findDiff ( str1 , str2 ) :
    if ( isSmaller ( str1 , str2 ) ) :
        str1 , str2 = str2 , str1
    Str = " "
    n1 = len ( str1 )
    n2 = len ( str2 )
    diff = n1 - n2
    carry = 0
    for i in range ( n2 - 1 , - 1 , - 1 ) :
        sub = ( ( ord ( str1 [ i + diff ] ) - ord ( '0' ) ) - ( ord ( str2 [ i ] ) - ord ( '0' ) ) - carry )
        if ( sub < 0 ) :
            sub += 10
            carry = 1
        else :
            carry = 0
        Str += chr ( sub + ord ( '0' ) )
    for i in range ( n1 - n2 - 1 , - 1 , - 1 ) :
        if ( str1 [ i ] == '0' and carry ) :
            Str += '9'
            continue
        sub = ( ord ( str1 [ i ] ) - ord ( '0' ) ) - carry
        if ( i > 0 or sub > 0 ) :
            Str += chr ( sub + ord ( '0' ) )
        carry = 0
    Str = Str [ : : - 1 ]
    return Str
str1 = "88"
str2 = "1079"
print ( findDiff ( str1 , str2 ) )

Index/key variables: i
Accumulator variables: Str, sub
Iterator variables: i
Python program:
def unique ( s ) :
    s = list ( s )
    s . sort ( )
    for i in range ( len ( s ) - 1 ) :
        if ( s [ i ] == s [ i + 1 ] ) :
            return False
            break
    return True
if ( unique ( " abcdd " ) == True ) :
    print ( " String ▁ is ▁ Unique " )
else :
    print ( " String ▁ is ▁ not ▁ Unique " )

Index/key variables: i
Iterator variables: i
Python program:
MAX_CHAR = 26 ;
def areKAnagrams ( str1 , str2 , k ) :
    n = len ( str1 ) ;
    if ( len ( str2 ) != n ) :
        return False ;
    hash_str1 = [ 0 ] * ( MAX_CHAR ) ;
    for i in range ( n ) :
        hash_str1 [ ord ( str1 [ i ] ) - ord ( ' a ' ) ] += 1 ;
    count = 0 ;
    for i in range ( n ) :
        if ( hash_str1 [ ord ( str2 [ i ] ) - ord ( ' a ' ) ] > 0 ) :
            hash_str1 [ ord ( str2 [ i ] ) - ord ( ' a ' ) ] -= 1 ;
        else :
            count += 1 ;
        if ( count > k ) :
            return False ;
    return True ;
str1 = " fodr " ;
str2 = " gork " ;
k = 2 ;
if ( areKAnagrams ( str1 , str2 , k ) == True ) :
    print ( " Yes " ) ;
else :
    print ( " No " ) ;

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
def ispalindrome ( s ) :
    l = len ( s )
    i = 0
    j = l - 1
    while i <= j :
        if ( s [ i ] != s [ j ] ) :
            return False
        i += 1
        j -= 1
    return True
if __name__ == " _ _ main _ _ " :
    s = " BABABAA "
    cnt = 0
    flag = 0
    while ( len ( s ) > 0 ) :
        if ( ispalindrome ( s ) ) :
            flag = 1
            break
        else :
            cnt += 1
            s = s [ : - 1 ]
            s . erase ( s . begin ( ) + s . length ( ) - 1 ) ;
    if ( flag ) :
        print ( cnt )

Index/key variables: i, j
Accumulator variables: cnt
Python program:
def findCount ( str ) :
    result = 0
    for i in range ( len ( str ) ) :
        if ( ( i == ord ( str [ i ] ) - ord ( ' a ' ) ) or ( i == ord ( str [ i ] ) - ord ( ' A ' ) ) ) :
            result += 1
    return result
str = ' AbgdeF '
print ( findCount ( str ) )

Index/key variables: i
Accumulator variables: result
Iterator variables: i
Python program:
def isPalindrome ( string : str , low : int , high : int ) -> bool :
    while low < high :
        if string [ low ] != string [ high ] :
            return False
        low += 1
        high -= 1
    return True
def possiblepalinByRemovingOneChar ( string : str ) -> int :
    low = 0
    high = len ( string ) - 1
    while low < high :
        if string [ low ] == string [ high ] :
            low += 1
            high -= 1
        else :
            if isPalindrome ( string , low + 1 , high ) :
                return low
            if isPalindrome ( string , low , high - 1 ) :
                return high
            return - 1
    return - 2
if __name__ == " _ _ main _ _ " :
    string = " abecbea "
    idx = possiblepalinByRemovingOneChar ( string )
    if idx == - 1 :
        print ( " Not ▁ possible " )
    elif idx == - 2 :
        print ( " Possible ▁ without ▁ removing ▁ any ▁ character " )
    else :
        print ( " Possible ▁ by ▁ removing ▁ character ▁ at ▁ index " , idx )

Index/key variables: high, low
Python program:
def _print ( string , index ) :
    if index == len ( string ) :
        print ( ' ' . join ( string ) )
        return
    if string [ index ] == " ? " :
        string [ index ] = '0'
        _print ( string , index + 1 )
        string [ index ] = '1'
        _print ( string , index + 1 )
        string [ index ] = ' ? '
    else :
        _print ( string , index + 1 )
if __name__ == " _ _ main _ _ " :
    string = "1 ? ? 0?101"
    string = list ( string )
    _print ( string , 0 )

Index/key variables: index
Python program:
def countOccurrences ( x , d ) :
    while ( x ) :
        if ( x % 10 == d ) :
            count += 1 ;
        x = int ( x / 10 ) ;
    return count ;
def maxOccurring ( x ) :
    if ( x < 0 ) :
        x = - x ;
    for d in range ( 10 ) :
        count = countOccurrences ( x , d ) ;
        if ( count >= max_count ) :
            max_count = count ;
            result = d ;
    return result ;
x = 1223355 ;
print ( " Max ▁ occurring ▁ digit ▁ is " , maxOccurring ( x ) ) ;

Accumulator variables: count
Iterator variables: d
Python program:
def removeRecurringDigits ( num ) :
    l = len ( num )
    ( i , j ) = ( 0 , 0 )
    str = ' '
    while i < l :
        str += num [ i ]
        j += 1
        while ( i + 1 < l and num [ i ] == num [ i + 1 ] ) :
            i += 1
        i += 1
    return str
if __name__ == ' _ _ main _ _ ' :
    num = '1299888833'
    print ( ' Modified ▁ number ▁ is ▁ { } ' . format ( removeRecurringDigits ( num ) ) )

Index/key variables: i
Accumulator variables: j, str
Python program:
def maxSubarrayXOR ( arr , n ) :
    ans = - 2147483648
    for i in range ( n ) :
        curr_xor = 0
        for j in range ( i , n ) :
            curr_xor = curr_xor ^ arr [ j ]
            ans = max ( ans , curr_xor )
    return ans
arr = [ 8 , 1 , 2 , 12 ]
n = len ( arr )
print ( " Max ▁ subarray ▁ XOR ▁ is ▁ " , maxSubarrayXOR ( arr , n ) )

Index/key variables: j
Iterator variables: i, j
Python program:
def printPattern ( Str , Len ) :
    for i in range ( Len ) :
        for j in range ( Len ) :
            if ( ( i == j ) or ( i + j == Len - 1 ) ) :
                print ( Str [ j ] , end = " " )
            else :
                print ( " ▁ " , end = " " )
        print ( )
Str = " geeksforgeeks "
Len = len ( Str )
printPattern ( Str , Len )

Index/key variables: j
Iterator variables: i, j
Python program:
MAX_CHARS = 26
def isValid ( count , k ) :
    val = 0
    for i in range ( MAX_CHARS ) :
        if count [ i ] > 0 :
            val += 1
    return ( k >= val )
def kUniques ( s , k ) :
    count = [ 0 ] * MAX_CHARS
    for i in range ( n ) :
        if count [ ord ( s [ i ] ) - ord ( ' a ' ) ] == 0 :
            u += 1
        count [ ord ( s [ i ] ) - ord ( ' a ' ) ] += 1
    if u < k :
        print ( " Not ▁ enough ▁ unique ▁ characters " )
        return
    curr_start = 0
    curr_end = 0
    max_window_size = 1
    max_window_start = 0
    count = [ 0 ] * len ( count )
    count [ ord ( s [ 0 ] ) - ord ( ' a ' ) ] += 1
    for i in range ( 1 , n ) :
        count [ ord ( s [ i ] ) - ord ( ' a ' ) ] += 1
        curr_end += 1
        while not isValid ( count , k ) :
            count [ ord ( s [ curr_start ] ) - ord ( ' a ' ) ] -= 1
            curr_start += 1
        if curr_end - curr_start + 1 > max_window_size :
            max_window_size = curr_end - curr_start + 1
            max_window_start = curr_start
    print ( " Max ▁ substring ▁ is ▁ : ▁ " + s [ max_window_start : max_window_start + max_window_size ] + " ▁ with ▁ length ▁ " + str ( max_window_size ) )
s = " aabacbebebe "
k = 3
kUniques ( s , k )

Index/key variables: curr_start, i
Accumulator variables: curr_end, u, val
Iterator variables: i
Python program:
def canFormPalindrome ( s ) :
    bitvector = 0
    for str in s :
        bitvector ^= 1 << ord ( str )
    return bitvector == 0 or bitvector & ( bitvector - 1 ) == 0
if canFormPalindrome ( " geeksforgeeks " ) :
    print ( ' Yes ' )
else :
    print ( ' No ' )

Accumulator variables: bitvector
Iterator variables: str
Python program:
NO_OF_CHARS = 256
def areAnagram ( str1 : str , str2 : str ) -> bool :
    count = [ 0 ] * NO_OF_CHARS
    i = 0
    while i < len ( str1 ) and i < len ( str2 ) :
        count [ ord ( str1 [ i ] ) ] += 1
        count [ ord ( str2 [ i ] ) ] -= 1
        i += 1
    if len ( str1 ) != len ( str2 ) :
        return False
    for i in range ( NO_OF_CHARS ) :
        if count [ i ] :
            return False
        return True
def findAllAnagrams ( arr : list , n : int ) :
    for i in range ( n ) :
        for j in range ( i + 1 , n ) :
            if areAnagram ( arr [ i ] , arr [ j ] ) :
                print ( arr [ i ] , " is ▁ anagram ▁ of " , arr [ j ] )
if __name__ == " _ _ main _ _ " :
    arr = [ " geeksquiz " , " geeksforgeeks " , " abcd " , " forgeeksgeeks " , " zuiqkeegs " ]
    n = len ( arr )
    findAllAnagrams ( arr , n )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def isPalindrome ( n : int ) -> bool :
    rev = 0
    i = n
    while i > 0 :
        rev = rev * 10 + i % 10
        i //= 10
    return ( n == rev )
def countPal ( minn : int , maxx : int ) -> None :
    for i in range ( minn , maxx + 1 ) :
        if isPalindrome ( i ) :
            print ( i , end = " ▁ " )
if __name__ == " _ _ main _ _ " :
    countPal ( 100 , 2000 )

Iterator variables: i
Python program:
def smallestWindow ( s , p ) :
    n = len ( s )
    if n < len ( p ) :
        return - 1
    mp = [ 0 ] * 256
    start = 0
    ans = n + 1
    cnt = 0
    for i in p :
        mp [ ord ( i ) ] += 1
        if mp [ ord ( i ) ] == 1 :
            cnt += 1
    j = 0
    i = 0
    while ( j < n ) :
        mp [ ord ( s [ j ] ) ] -= 1
        if mp [ ord ( s [ j ] ) ] == 0 :
            cnt -= 1
            while cnt == 0 :
                if ans > j - i + 1 :
                    ans = j - i + 1
                    start = i
                mp [ ord ( s [ i ] ) ] += 1
                if mp [ ord ( s [ i ] ) ] > 0 :
                    cnt += 1
                i += 1
        j += 1
    if ans > n :
        return " - 1"
    return s [ start : start + ans ]
if __name__ == " _ _ main _ _ " :
    s = " ADOBECODEBANC "
    p = " ABC "
    result = smallestWindow ( s , p )
    print ( " - - > Smallest ▁ window ▁ that ▁ contain ▁ all ▁ character ▁ : " , result )

Index/key variables: i, j
Accumulator variables: cnt
Iterator variables: i
Python program:
def printRLE ( st ) :
    n = len ( st )
    i = 0
    while i < n - 1 :
        count = 1
        while ( i < n - 1 and st [ i ] == st [ i + 1 ] ) :
            count += 1
            i += 1
        i += 1
        print ( st [ i - 1 ] + str ( count ) , end = " " )
if __name__ == " _ _ main _ _ " :
    st = " wwwwaaadexxxxxxywww "
    printRLE ( st )

Index/key variables: i
Accumulator variables: count
Python program:
def isCorner ( i , j , M , N ) :
    if ( ( i == 0 and j == 0 ) or ( i == 0 and j == N - 1 ) or ( i == M - 1 and j == N - 1 ) or ( i == M - 1 and j == 0 ) ) :
        return True
    return False
def isValid ( i , j , M , N ) :
    if ( i < 0 or i >= M or j < 0 or j >= N ) :
        return False
    return True
def solve ( i , j , M , N , Dir , maze , t , ans ) :
    if ( isCorner ( i , j , M , N ) ) :
        ans . append ( t )
        return
    for k in range ( 4 ) :
        x = i + Dir [ k ] [ 0 ]
        y = j + Dir [ k ] [ 1 ]
        c = Dir [ k ] [ 2 ]
        if ( isValid ( x , y , M , N ) and maze [ x ] [ y ] == 1 ) :
            maze [ x ] [ y ] = 0
            t += c
            solve ( x , y , M , N , Dir , maze , t , ans )
            t = t [ : len ( t ) - 1 ]
            maze [ x ] [ y ] = 1
    return
def possiblePaths ( src , maze ) :
    Dir = [ [ - 1 , 0 , ' U ' ] , [ 0 , 1 , ' R ' ] , [ 1 , 0 , ' D ' ] , [ 0 , - 1 , ' L ' ] ]
    temp = " "
    ans = [ ]
    solve ( src [ 0 ] , src [ 1 ] , len ( maze ) , len ( maze [ 0 ] ) , Dir , maze , temp , ans )
    return ans
maze = [ [ 1 , 0 , 0 , 1 , 0 , 0 , 1 , 1 ] , [ 1 , 1 , 1 , 0 , 0 , 0 , 1 , 0 ] , [ 1 , 0 , 1 , 1 , 1 , 1 , 1 , 0 ] , [ 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 ] , [ 1 , 0 , 1 , 0 , 1 , 0 , 0 , 1 ] , [ 0 , 1 , 1 , 1 , 1 , 0 , 0 , 1 ] , [ 0 , 1 , 0 , 0 , 1 , 1 , 1 , 1 ] , [ 1 , 1 , 0 , 0 , 0 , 0 , 0 , 1 ] ]
src = [ 4 , 2 ]
paths = possiblePaths ( src , maze )
if ( len ( paths ) == 0 ) :
    print ( " No ▁ Possible ▁ Paths " )
else :
    for i in paths :
        print ( i )

Index/key variables: k, x, y
Accumulator variables: t
Iterator variables: i, k
Python program:
class node :
    def __init__ ( self , data ) :
        self . data = data
        self . left = None
        self . right = None
def printLevelOrder ( root ) :
    if ( root == None ) :
        return
    q = [ ]
    q . append ( root )
    while ( len ( q ) > 0 ) :
        temp = q [ 0 ]
        print ( temp . data , end = " ▁ " )
        q = q [ 1 : ]
        if ( temp . left != None ) :
            q . append ( temp . left )
        elif ( temp . right != None ) :
            print ( " NULL " , end = " ▁ " )
        if ( temp . right != None ) :
            q . append ( temp . right )
        elif ( temp . left != None ) :
            print ( " NULL " , end = " ▁ " )
def pruneTree ( root ) :
    if ( root == None ) :
        return None
    root . left = pruneTree ( root . left )
    root . right = pruneTree ( root . right )
    if ( root . data % 2 == 0 and root . right == None and root . left == None ) :
        return None
    return root
if __name__ == ' _ _ main _ _ ' :
    root = node ( 1 )
    root . left = node ( 2 )
    root . left . left = node ( 8 )
    root . left . right = node ( 10 )
    root . right = node ( 7 )
    root . right . left = node ( 12 )
    root . right . right = node ( 5 )
    newRoot = pruneTree ( root )
    printLevelOrder ( newRoot )

Accumulator variables: q
Class/struct names: node
Python program:
def countWays ( mtrx , vrtx , i , dest , visited ) :
    if ( i == dest ) :
        return 1
    total = 0
    for j in range ( vrtx ) :
        if ( mtrx [ i ] [ j ] == 1 and not visited [ j ] ) :
            visited [ j ] = True ;
            total += countWays ( mtrx , vrtx , j , dest , visited ) ;
            visited [ j ] = False ;
    return total
def totalWays ( mtrx , vrtx , src , dest ) :
    visited = [ False ] * vrtx
    for i in range ( vrtx ) :
        visited [ i ] = False
    visited [ src ] = True ;
    return countWays ( mtrx , vrtx , src , dest , visited )
print ( totalWays ( mtrx , vrtx , src - 1 , dest - 1 ) )

Index/key variables: i, j, src
Accumulator variables: total
Iterator variables: i, j
Python program:
class Node :
    def __init__ ( self , x ) :
        self . key = x
        self . left = None
        self . right = None
def evenPaths ( node , count ) :
    if ( node == None or ( node . key % 2 != 0 ) ) :
        return count
    if ( not node . left and not node . right ) :
        count += 1
    count = evenPaths ( node . left , count )
    return evenPaths ( node . right , count )
def countEvenPaths ( node ) :
    return evenPaths ( node , 0 )
if __name__ == ' _ _ main _ _ ' :
    root = Node ( 12 )
    root . left = Node ( 13 )
    root . right = Node ( 12 )
    root . right . left = Node ( 14 )
    root . right . right = Node ( 16 )
    root . right . left . left = Node ( 21 )
    root . right . left . right = Node ( 22 )
    root . right . right . left = Node ( 22 )
    root . right . right . right = Node ( 24 )
    root . right . right . right . left = Node ( 8 )
    print ( countEvenPaths ( root ) )

Class/struct names: Node