dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
class Node { constructor ( key ) { this . left = null ; this . right = null ; this . key = key ; } } let interNodes = [ ] ; function newNode ( key ) { let temp = new Node ( key ) ; return temp ; } function insertNode ( node , key ) { if ( node == null ) return newNode ( key ) ; if ( key < node . key ) node . left = insertNode ( node . left , key ) ; else if ( key > node . key ) node . right = insertNode ( node . right , key ) ; return node ; } function getIntermediateNodes ( root , node1 , node2 ) { if ( root == null ) return ; getIntermediateNodes ( root . left , node1 , node2 ) ; if ( root . key <= node2 && root . key >= node1 ) { interNodes . push ( root . key ) ; } getIntermediateNodes ( root . right , node1 , node2 ) ; } function findMedian ( root , node1 , node2 ) { getIntermediateNodes ( root , node1 , node2 ) ; let nSize = interNodes . length ; return ( nSize % 2 == 1 ) ? interNodes [ parseInt ( nSize / 2 , 10 ) ] : ( interNodes [ parseInt ( ( nSize - 1 ) / 2 , 10 ) ] + interNodes [ nSize / 2 ] ) / 2 ; } let root = null ; root = insertNode ( root , 8 ) ; insertNode ( root , 3 ) ; insertNode ( root , 1 ) ; insertNode ( root , 6 ) ; insertNode ( root , 4 ) ; insertNode ( root , 11 ) ; insertNode ( root , 15 ) ; document . write ( findMedian ( root , 3 , 11 ) ) ;

Class/struct names: Node
Javascript program:
function computeTotient ( N , phi ) { for ( let p = 2 ; p <= N ; p ++ ) { if ( phi [ p ] == p ) { phi [ p ] = p - 1 ; for ( let i = 2 * p ; i <= N ; i += p ) { phi [ i ] = ( phi [ i ] / p ) * ( p - 1 ) ; } } } } function countPairs ( N ) { let cnt_type1 = 0 , cnt_type2 = 0 ; let half_N = N / 2 ; cnt_type1 = ( half_N * ( half_N - 1 ) ) / 2 ; let phi = Array . from ( { length : N + 1 } , ( _ , i ) => 0 ) ; for ( let i = 1 ; i <= N ; i ++ ) { phi [ i ] = i ; } computeTotient ( N , phi ) ; for ( let i = ( N / 2 ) + 1 ; i <= N ; i ++ ) cnt_type2 += ( i - phi [ i ] - 1 ) ; document . write ( cnt_type1 + cnt_type2 ) ; } let N = 6 ; countPairs ( N ) ;

Index/key variables: i, p
Accumulator variables: cnt_type2, i, p
Iterator variables: i, p
Javascript program:
let ans = Number . MAX_SAFE_INTEGER let mini = Number . MAX_SAFE_INTEGER function findClosestTarget ( i , curr , B , M , K ) { if ( Math . abs ( curr - K ) < mini ) { mini = Math . abs ( curr - K ) ; ans = curr ; } if ( Math . abs ( curr - K ) == mini ) { ans = Math . min ( ans , curr ) ; } if ( i >= M ) return ; findClosestTarget ( i + 1 , curr + B [ i ] , B , M , K ) ; findClosestTarget ( i + 1 , curr + 2 * B [ i ] , B , M , K ) ; findClosestTarget ( i + 1 , curr , B , M , K ) ; } function findClosest ( A , B , N , M , K ) { for ( let i = 0 ; i < N ; i ++ ) { findClosestTarget ( 0 , A [ i ] , B , M , K ) ; } return ans ; } let A = [ 2 , 3 ] ; let B = [ 4 , 5 , 30 ] ; let N = A . length ; let M = B . length ; let K = 18 ; document . write ( findClosest ( A , B , N , M , K ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function findNode ( mp , n ) { var a = new Array ( n ) ; var i ; for ( i = 0 ; i < n ; i ++ ) { a [ i ] = mp [ i + 1 ] ; } var count0 = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 0 ) { count0 ++ ; } } count0 -= 1 ; if ( count0 <= parseInt ( n / 2 ) ) { document . write ( " " ) ; } else document . write ( " " ) ; } var N = 3 ; var mp = new Map ( ) ; mp . set ( 1 , 0 ) ; mp . set ( 2 , 2 ) ; mp . set ( 3 , 0 ) ; mp [ 1 ] = 0 ; mp [ 2 ] = 2 ; mp [ 3 ] = 0 ; findNode ( mp , N ) ;

Index/key variables: i
Accumulator variables: count0, i
Iterator variables: i
Javascript program:
function convert ( p ) { let ans = 0 ; for ( let i of p ) { ans = ( ans << 1 ) | i ; } return ans ; } function count ( num ) { let ans = 0 ; while ( num > 0 ) { ans += num & 1 ; num >>= 1 ; } return ans ; } function checkGoodMatrix ( mat ) { let P = [ ] , S = [ ] , MR = [ ] , MC = [ ] ; for ( let i = 0 ; i < mat . length ; i ++ ) { for ( let j = 0 ; j < mat [ 0 ] . length ; j ++ ) { if ( i == j ) P . push ( mat [ i ] [ j ] ) ; if ( i + j == mat . length - 1 ) S . push ( mat [ i ] [ j ] ) ; if ( i == Math . floor ( ( mat . length - 1 ) / 2 ) ) MR . push ( mat [ i ] [ j ] ) ; if ( j == Math . floor ( ( mat . length - 1 ) / 2 ) ) MC . push ( mat [ i ] [ j ] ) ; } } S . reverse ( ) ; let P0 = convert ( P ) ; let S0 = convert ( S ) ; let MR0 = convert ( MR ) ; let MC0 = convert ( MC ) ; let setBitsPS = count ( ( P0 & S0 ) ) ; let setBitsMM = count ( ( MR0 & MC0 ) ) ; if ( setBitsPS > setBitsMM ) document . write ( " " ) ; else document . write ( " " ) ; } let mat = [ [ 1 , 0 , 1 ] , [ 0 , 0 , 1 ] , [ 0 , 1 , 1 ] ] ; checkGoodMatrix ( mat ) ;

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Javascript program:
function assignValues ( Edges , n ) { var tree = Array . from ( Array ( n + 1 ) , ( ) => Array ( ) ) ; for ( var i = 0 ; i < n - 1 ; i ++ ) { var u = Edges [ i ] [ 0 ] ; var v = Edges [ i ] [ 1 ] ; tree [ u ] . push ( v ) ; tree [ v ] . push ( u ) ; } var visited = Array ( n + 1 ) . fill ( false ) ; var answer = Array ( n + 1 ) ; var K = 1 ; var q = [ ] ; q . push ( 1 ) ; answer [ 1 ] = K ; while ( q . length != 0 ) { var node = q [ 0 ] ; q . shift ( ) ; visited [ node ] = true ; K = ( ( answer [ node ] == 1 ) ? 2 : 1 ) ; tree [ node ] . forEach ( child => { if ( ! visited [ child ] ) { q . push ( child ) ; answer [ child ] = K ; } } ) ; } for ( var i = 1 ; i <= n ; i ++ ) { document . write ( answer [ i ] + " " ) ; } } var N = 11 ; var Edges = [ [ 1 , 2 ] , [ 1 , 3 ] , [ 1 , 4 ] , [ 1 , 5 ] , [ 2 , 6 ] , [ 2 , 10 ] , [ 10 , 11 ] , [ 3 , 7 ] , [ 4 , 8 ] , [ 5 , 9 ] ] ; assignValues ( Edges , N ) ;

Index/key variables: child, i, node, u, v
Accumulator variables: i
Iterator variables: i
Javascript program:
var limit = 100000 ; var prime = Array ( limit + 1 ) . fill ( true ) ; function sieve ( ) { for ( p = 2 ; p * p <= limit ; p ++ ) { if ( prime [ p ] == true ) { for ( i = p * p ; i <= limit ; i += p ) prime [ i ] = false ; } } } function findOperations ( arr , n ) { sieve ( ) ; var minm = Number . MAX_VALUE ; for ( i = 0 ; i < n ; i ++ ) { minm = Math . min ( minm , arr [ i ] ) ; } var val = minm ; for ( i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == minm + 1 ) { val = minm - 2 ; break ; } } var cnt = 0 ; for ( i = 0 ; i < n ; i ++ ) { var D = arr [ i ] - val ; if ( D == 0 ) { continue ; } else if ( prime [ D ] == true ) { cnt += 1 ; } else if ( D % 2 == 0 ) { cnt += 2 ; } else { if ( prime [ D - 2 ] == true ) { cnt += 2 ; } else { cnt += 3 ; } } } return cnt ; } var arr = [ 7 , 10 , 4 , 5 ] ; var N = 4 ; document . write ( findOperations ( arr , N ) ) ;

Index/key variables: D, i, p
Accumulator variables: cnt, i, p
Iterator variables: i, p
Javascript program:
function printUnique ( lis ) { lis . reverse ( ) ; for ( var i = 0 ; i < lis . length ; i ++ ) { document . write ( lis [ i ] + " " ) } } function checkUnique ( st ) { var lis = [ ] ; var res = 0 ; var N = parseInt ( st ) ; var cnt = Array ( 10 ) . fill ( 0 ) ; var cnt1 = Array ( 10 ) . fill ( 0 ) ; while ( N > 0 ) { var rem = N % 10 ; cnt [ rem ] += 1 ; N = parseInt ( N / 10 ) ; } N = parseInt ( st ) ; while ( N > 0 ) { var rem = N % 10 ; if ( cnt1 [ rem ] == 0 ) { if ( cnt [ rem ] == 1 ) lis . push ( rem ) ; } cnt1 [ rem ] = 1 ; N = parseInt ( N / 10 ) ; } printUnique ( lis ) ; } function combineArray ( lis ) { var st = " " ; for ( var i = 0 ; i < lis . length ; i ++ ) { var ee = ( lis [ i ] . toString ( ) ) ; st = st + ee ; } checkUnique ( st ) ; } var arr = [ 122 , 474 , 612 , 932 ] ; combineArray ( arr ) ;

Index/key variables: i, rem
Accumulator variables: i
Iterator variables: i
Javascript program:
function calcScore ( p , arr , N ) { var ans = 0 ; for ( var i = 0 ; i < N ; i ++ ) { ans += ( p [ i ] & arr [ i ] ) ; } return ans ; } function getMaxUtil ( p , arr , ans , chosen , N ) { if ( p . length == N ) { ans = Math . max ( ans , calcScore ( p , arr , N ) ) ; return ans ; } for ( var i = 0 ; i < N ; i ++ ) { if ( chosen [ i ] ) { continue ; } chosen [ i ] = true ; p . push ( i ) ; ans = getMaxUtil ( p , arr , ans , chosen , N ) ; chosen [ i ] = false ; p . pop ( ) ; } return ans ; } function getMax ( arr , N ) { var ans = 0 ; var chosen = Array ( N ) . fill ( false ) ; var p = [ ] ; var res = getMaxUtil ( p , arr , ans , chosen , N ) ; document . write ( res ) ; } var arr = [ 4 , 2 , 3 , 6 ] ; var N = arr . length ; getMax ( arr , N ) ;

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function setBitCount ( n ) { let ans = 0 ; while ( n != 0 ) { ans += n & 1 ; n >>= 1 ; } return ans ; } function getSum ( arr , n ) { let mp = new Map ( ) ; let ans = 0 ; for ( let i = 0 ; i < n ; i ++ ) { let key = setBitCount ( arr [ i ] ) ; if ( mp . has ( key ) ) mp . set ( key , mp . get ( key ) + 1 ) ; else mp . set ( key , 1 ) ; } for ( let i = 0 ; i < n ; i ++ ) { let key = setBitCount ( arr [ i ] ) ; if ( mp . has ( key ) && mp . get ( key ) == 1 ) ans += arr [ i ] ; } document . write ( ans ) ; } let arr = [ 8 , 3 , 7 , 5 , 3 ] ; let n = arr . length ; getSum ( arr , n ) ;

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function findSplit ( arr , N ) { let sum = new Array ( N ) ; for ( let i = 0 ; i < N ; i ++ ) { sum [ i ] = arr [ i ] ; } for ( let i = 1 ; i < N ; i ++ ) { sum [ i ] += sum [ i - 1 ] ; } for ( let l = 1 ; l <= N - 4 ; l ++ ) { for ( let r = l + 2 ; r <= N - 2 ; r ++ ) { let lsum = 0 , rsum = 0 , msum = 0 ; lsum = sum [ l - 1 ] ; msum = sum [ r - 1 ] - sum [ l ] ; rsum = sum [ N - 1 ] - sum [ r ] ; if ( lsum == rsum && rsum == msum ) { document . write ( l + " " + r + " " ) ; return ; } } } document . write ( - 1 + " " ) ; } let arr = [ 2 , 5 , 12 , 7 , 19 , 4 , 3 ] ; let N = arr . length ; findSplit ( arr , N ) ;

Index/key variables: i, l, r
Accumulator variables: i, l, r
Iterator variables: i, l, r
Javascript program:
function findSplit ( arr , N ) { let l = 1 , r = N - 2 ; let lsum , msum , rsum ; let sum = new Array ( N ) ; sum [ 0 ] = arr [ 0 ] ; for ( let i = 1 ; i < N ; i ++ ) { sum [ i ] = sum [ i - 1 ] + arr [ i ] ; } while ( l < r ) { lsum = sum [ l - 1 ] ; msum = sum [ r - 1 ] - sum [ l ] ; rsum = sum [ N - 1 ] - sum [ r ] ; if ( lsum == msum && msum == rsum ) { document . write ( l + " " + r ) ; return ; } if ( lsum < rsum ) l ++ ; else if ( lsum > rsum ) r -- ; else { l ++ ; r -- ; } } document . write ( - 1 ) ; } let arr = [ 2 , 5 , 12 , 7 , 19 , 4 , 3 ] ; let N = arr . length ; findSplit ( arr , N ) ;

Index/key variables: i, l, r
Accumulator variables: i, l, r
Iterator variables: i
Javascript program:
class Node { constructor ( val ) { this . data = val ; this . left = null ; this . right = null ; } } var root ; var head ; var prev ; function extractLeafList ( root ) { if ( root == null ) return null ; if ( root . left == null && root . right == null ) { if ( head == null ) { head = root ; prev = root ; } else { prev . right = root ; root . left = prev ; prev = root ; } return null ; } root . left = extractLeafList ( root . left ) ; root . right = extractLeafList ( root . right ) ; return root ; } function inorder ( node ) { if ( node == null ) return ; inorder ( node . left ) ; document . write ( node . data + " " ) ; inorder ( node . right ) ; } function printDLL ( head ) { var last = null ; while ( head != null ) { document . write ( head . data + " " ) ; last = head ; head = head . right ; } } root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 3 ) ; root . left . left = new Node ( 4 ) ; root . left . right = new Node ( 5 ) ; root . right . right = new Node ( 6 ) ; root . left . left . left = new Node ( 7 ) ; root . left . left . right = new Node ( 8 ) ; root . right . right . left = new Node ( 9 ) ; root . right . right . right = new Node ( 10 ) ; document . write ( " " ) ; inorder ( root ) ; extractLeafList ( root ) ; document . write ( " " ) ; document . write ( " " ) ; printDLL ( head ) ; document . write ( " " ) ; document . write ( " " ) ; inorder ( root ) ;

Class/struct names: Node
Javascript program:
var MAX = 100 ; function dfs ( n , m , visit , adj , N , M ) { visit [ n ] [ m ] = 1 ; if ( n + 1 < N && adj [ n ] [ m ] >= adj [ n + 1 ] [ m ] && ! visit [ n + 1 ] [ m ] ) dfs ( n + 1 , m , visit , adj , N , M ) ; if ( m + 1 < M && adj [ n ] [ m ] >= adj [ n ] [ m + 1 ] && ! visit [ n ] [ m + 1 ] ) dfs ( n , m + 1 , visit , adj , N , M ) ; if ( n - 1 >= 0 && adj [ n ] [ m ] >= adj [ n - 1 ] [ m ] && ! visit [ n - 1 ] [ m ] ) dfs ( n - 1 , m , visit , adj , N , M ) ; if ( m - 1 >= 0 && adj [ n ] [ m ] >= adj [ n ] [ m - 1 ] && ! visit [ n ] [ m - 1 ] ) dfs ( n , m - 1 , visit , adj , N , M ) ; } function printMinSources ( adj , N , M ) { var x = [ ] ; for ( var i = 0 ; i < N ; i ++ ) for ( var j = 0 ; j < M ; j ++ ) x . push ( [ adj [ i ] [ j ] , [ i , j ] ] ) ; x = x . sort ( ) ; var visit = new Array ( N ) ; for ( var i = 0 ; i < N ; i ++ ) { visit [ i ] = [ ] ; for ( var j = 0 ; j < MAX ; j ++ ) { visit [ i ] . push ( false ) ; } } for ( var i = x . length - 1 ; i >= 0 ; i -- ) { if ( ! visit [ x [ i ] [ 1 ] [ 0 ] ] [ x [ i ] [ 1 ] [ 1 ] ] ) { document . write ( x [ i ] [ 1 ] [ 0 ] + " " + x [ i ] [ 1 ] [ 1 ] + " " ) ; dfs ( x [ i ] [ 1 ] [ 0 ] , x [ i ] [ 1 ] [ 1 ] , visit , adj , N , M ) ; } } } var N = 2 var M = 2 var adj = [ [ 3 , 3 ] , [ 1 , 1 ] ] printMinSources ( adj , N , M )

Index/key variables: i, j, m, n
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function countMinSteps ( arr , target , n ) { arr = arr . sort ( function ( a , b ) { return a - b ; } ) ; var minimumSteps = 0 ; var i = 0 , j = n - 1 ; while ( i <= j ) { if ( arr [ i ] + arr [ j ] <= target ) { i ++ ; j -- ; } else { j -- ; } minimumSteps ++ ; } return minimumSteps ; } var arr = [ 4 , 6 , 2 , 9 , 6 , 5 , 8 , 10 ] ; var target = 11 ; var size = arr . length ; document . write ( countMinSteps ( arr , target , size ) ) ;

Index/key variables: i, j
Accumulator variables: i, j, minimumSteps
Javascript program:
var sticks = [ 6 , 7 , 4 , 6 , 5 , 4 , 6 , 5 , 2 , 4 , 4 , 3 , 6 , 6 , 6 , 5 , 7 , 6 , 5 , 3 , 5 , 4 , 6 , 4 , 3 , 4 ] ; var number = [ 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ] ; function countSticks ( str ) { var cnt = 0 ; var n = str . length ; for ( var i = 0 ; i < n ; i ++ ) { var ch = str [ i ] ; if ( ch >= ' ' && ch <= ' ' ) { cnt += sticks [ ch . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ; } else { cnt += number [ ch . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ; } } return cnt ; } function sortArr ( arr , int ) { var vp = new Array ( n ) ; for ( var i = 0 ; i < n ; i ++ ) { vp [ i ] = [ countSticks ( arr [ i ] ) , arr [ i ] ] ; } vp . sort ( ) ; for ( var i = 0 ; i < n ; i ++ ) document . write ( vp [ i ] [ 1 ] + " " ) ; } var arr = [ " " , " " , " " ] ; var n = arr . length ; sortArr ( arr , n ) ;

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
let MAX = 100001 ; class interval { constructor ( ) { this . l = this . r = this . v = 0 ; } } function isPossible ( range , N ) { let test = new Array ( N ) ; for ( let i = 0 ; i < N ; i ++ ) { test [ i ] = new interval ( ) ; test [ i ] . l = range [ i ] [ 0 ] ; test [ i ] . r = range [ i ] [ 1 ] ; test [ i ] . v = range [ i ] [ 2 ] ; } test . sort ( function ( a , b ) { return ( a . v < b . v ? 1 : 0 ) ; } ) ; for ( let i = 0 ; i < N ; i ++ ) { let count = new Array ( MAX ) ; for ( let i = 0 ; i < MAX ; i ++ ) count [ i ] = 0 ; let current_velocity = test [ i ] . v ; let j = i ; while ( j < N && test [ j ] . v == current_velocity ) { for ( let k = test [ j ] . l ; k <= test [ j ] . r ; k ++ ) { count [ k ] ++ ; if ( count [ k ] >= 3 ) return false ; } j ++ ; } i = j - 1 ; } return true ; } let range = [ [ 1 , 2 , 3 ] , [ 2 , 5 , 1 ] , [ 3 , 10 , 1 ] , [ 4 , 4 , 1 ] , [ 5 , 7 , 10 ] ] let n = range . length ; if ( isPossible ( range , n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, k
Class/struct names: interval
Javascript program:
let N = 2005 ; let ans = new Set ( ) ; function dfs ( num , left , ct ) { if ( ct >= 15 ) return ; if ( left == 0 ) ans . add ( num ) ; for ( let i = 0 ; i <= Math . min ( left , 9 ) ; i ++ ) dfs ( num * 10 + i , left - i , ct + 1 ) ; } function getKthNum ( m , k ) { dfs ( 0 , m , 0 ) ; let ct = 0 ; for ( let it of ans . values ( ) ) { ct ++ ; if ( ct == k ) { return it ; } } return - 1 ; } let m = 5 , k = 3 ; document . write ( getKthNum ( m , k ) ) ;

Accumulator variables: ct, i
Iterator variables: i, it
Javascript program:
function upperBound ( array , value ) { var low = 0 ; var high = array . length ; while ( low < high ) { var mid = parseInt ( ( low + high ) / 2 ) ; if ( value >= array [ mid ] ) { low = mid + 1 ; } else { high = mid ; } } return low ; } function Removal ( v , n ) { v . sort ( ( a , b ) => a - b ) ; var ans = 2147483648 ; var k = 0 ; for ( const i of v ) { var j = upperBound ( v , 2 * i ) ; ans = Math . min ( ans , n - ( j - k ) ) ; k ++ ; } return ans ; } var a = [ 4 , 5 , 100 , 9 , 10 , 11 , 12 , 15 , 200 ] ; var n = a . length ; document . write ( Removal ( a , n ) ) ;

Index/key variables: mid
Accumulator variables: k
Iterator variables: i
Javascript program:
function partition ( arr , low , high , mod ) { var pivot = arr [ high ] ; var i = ( low - 1 ) ; var piv = pivot % mod ; for ( var j = low ; j <= high - 1 ; j ++ ) { var a = arr [ j ] % mod ; if ( a <= piv ) { i ++ ; var t = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = t ; } } var t = arr [ i + 1 ] ; arr [ i + 1 ] = arr [ high ] ; arr [ high ] = t ; return ( i + 1 ) ; } function quickSort ( arr , low , high , mod ) { if ( low < high ) { var pi = partition ( arr , low , high , mod ) ; quickSort ( arr , low , pi - 1 , mod ) ; quickSort ( arr , pi + 1 , high , mod ) ; } } function printArray ( arr , size ) { for ( var i = 0 ; i < size ; i ++ ) document . write ( arr [ i ] + " " ) ; } var arr = [ ' ' , ' ' , ' ' , ' ' , ' ' ] ; var n = arr . length ; var mod = 8 ; quickSort ( arr , 0 , n - 1 , mod ) ; printArray ( arr , n ) ;

Index/key variables: high, i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . next = null ; } } function newNode ( val ) { var temp = new Node ( ) ; temp . data = val ; temp . next = null ; return temp ; } function selectionSort ( head ) { var a , b , c , d , r ; a = b = head ; while ( b . next != null ) { c = d = b . next ; while ( d != null ) { if ( b . data > d . data ) { if ( b . next == d ) { if ( b == head ) { b . next = d . next ; d . next = b ; r = b ; b = d ; d = r ; c = d ; head = b ; d = d . next ; } else { b . next = d . next ; d . next = b ; a . next = d ; r = b ; b = d ; d = r ; c = d ; d = d . next ; } } else { if ( b == head ) { r = b . next ; b . next = d . next ; d . next = r ; c . next = b ; r = b ; b = d ; d = r ; c = d ; d = d . next ; head = b ; } else { r = b . next ; b . next = d . next ; d . next = r ; c . next = b ; a . next = d ; r = b ; b = d ; d = r ; c = d ; d = d . next ; } } } else { c = d ; d = d . next ; } } a = b ; b = b . next ; } return head ; } function printList ( head ) { while ( head != null ) { document . write ( head . data + " " ) ; head = head . next ; } } var head = newNode ( 5 ) ; head . next = newNode ( 4 ) ; head . next . next = newNode ( 3 ) ; head = selectionSort ( head ) ; printList ( head ) ;

Class/struct names: Node
Javascript program:
function printArr ( arr , n ) { for ( let i = 0 ; i < n ; i ++ ) { document . write ( arr [ i ] + " " ) ; } } function findNumbers ( arr , n ) { arr . sort ( function ( a , b ) { return a - b } ) ; reverse ( arr ) ; let freq = new Array ( arr [ 0 ] + 1 ) ; freq . fill ( 0 ) ; for ( let i = 0 ; i < n ; i ++ ) { freq [ arr [ i ] ] ++ ; } let size = parseInt ( Math . sqrt ( n ) , 10 ) ; let brr = new Array ( size ) ; brr . fill ( 0 ) ; let x , l = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( freq [ arr [ i ] ] > 0 && l < size ) { brr [ l ] = arr [ i ] ; freq [ brr [ l ] ] -- ; l ++ ; for ( let j = 0 ; j < l ; j ++ ) { if ( i != j ) { x = __gcd ( arr [ i ] , brr [ j ] ) ; freq [ x ] -= 2 ; } } } } printArr ( brr , size ) ; } function reverse ( input ) { let last = input . length - 1 ; let middle = parseInt ( input . length / 2 , 10 ) ; for ( let i = 0 ; i <= middle ; i ++ ) { let temp = input [ i ] ; input [ i ] = input [ last - i ] ; input [ last - i ] = temp ; } } function __gcd ( a , b ) { if ( b == 0 ) { return a ; } return __gcd ( b , a % b ) ; } let arr = [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 5 , 5 , 5 , 7 , 10 , 12 , 2 , 2 ] ; let n = arr . length ; findNumbers ( arr , n ) ;

Index/key variables: i, j, l, x
Accumulator variables: i, j, l
Iterator variables: i, j
Javascript program:
function strBitwiseAND ( arr , n ) { let res = " " ; let smallest_size = Number . MAX_VALUE ; let largest_size = Number . MIN_VALUE ; let temp = " " ; for ( let i = 0 ; i < n ; i ++ ) { temp += arr [ i ] ; arr [ i ] = reverse ( temp ) ; smallest_size = Math . min ( smallest_size , arr [ i ] . length ) ; largest_size = Math . max ( largest_size , arr [ i ] . length ) ; } for ( let i = 0 ; i < smallest_size ; i ++ ) { let all_ones = true ; for ( let j = 0 ; j < n ; j ++ ) { if ( arr [ j ] [ i ] == ' ' ) { all_ones = false ; break ; } } res += ( all_ones ? ' ' : ' ' ) ; } for ( let i = 0 ; i < largest_size - smallest_size ; i ++ ) res += ' ' ; let temp1 = " " ; temp1 += res ; res = reverse ( temp1 ) ; let temparray1 = res ; let Temparray = " " ; for ( let i = 6 ; i < temparray1 . length ; i ++ ) { Temparray = Temparray + temparray1 [ i ] ; } return Temparray ; } function reverse ( input ) { let temparray = input . split ( ' ' ) ; let left , right = 0 ; right = temparray . length - 1 ; for ( left = 0 ; left < right ; left ++ , right -- ) { let temp = temparray [ left ] ; temparray [ left ] = temparray [ right ] ; temparray [ right ] = temp ; } return temparray . join ( " " ) ; } let arr = [ " " , " " , " " ] ; let n = arr . length ; document . write ( strBitwiseAND ( arr , n ) ) ;

Index/key variables: i, j, left, right
Accumulator variables: i, j, left, res, right, temp, temp1
Iterator variables: i, j, left
Boolean variables: all_ones
Javascript program:
function AlternateRearrange ( arr , n ) { arr . sort ( ( a , b ) => a - b ) ; for ( var i = 0 ; i < n ; i ++ ) if ( arr [ i ] % 2 == 0 ) v1 . push ( arr [ i ] ) ; else v2 . push ( arr [ i ] ) ; var index = 0 , i = 0 , j = 0 ; var flag = false ; if ( arr [ 0 ] % 2 == 0 ) flag = true ; while ( index < n ) { if ( flag == true ) { arr [ index ++ ] = v1 [ i ++ ] ; flag = ! flag ; } else { arr [ index ++ ] = v2 [ j ++ ] ; flag = ! flag ; } } for ( i = 0 ; i < n ; i ++ ) document . write ( arr [ i ] + " " ) ; } var arr = [ 9 , 8 , 13 , 2 , 19 , 14 ] ; var n = arr . length ; AlternateRearrange ( arr , n ) ;

Index/key variables: i
Accumulator variables: i, index, j
Iterator variables: i
Boolean variables: flag
Javascript program:
function getNumToAdd ( arr , n ) { arr . sort ( function ( a , b ) { return a - b } ) ; var d = arr [ 1 ] - arr [ 0 ] ; var numToAdd = - 1 ; var numAdded = false ; for ( var i = 2 ; i < n ; i ++ ) { var diff = arr [ i ] - arr [ i - 1 ] ; if ( diff != d ) { if ( numAdded ) return - 1 ; if ( diff == 2 * d ) { numToAdd = arr [ i ] - d ; numAdded = true ; } else return - 1 ; } } if ( numToAdd == - 1 ) return ( arr [ n - 1 ] + d ) ; return numToAdd ; } var arr = [ 1 , 3 , 5 , 7 , 11 , 13 , 15 ] ; var n = arr . length ; document . write ( getNumToAdd ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: numAdded