dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function nobleInteger ( arr ) { arr . sort ( function ( a , b ) { return a - b ; } ) ; let n = arr . length ; for ( let i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] == arr [ i + 1 ] ) continue ; if ( arr [ i ] == n - i - 1 ) return arr [ i ] ; } if ( arr [ n - 1 ] == 0 ) return arr [ n - 1 ] ; return - 1 ; } let arr = [ 10 , 3 , 20 , 40 , 2 ] ; let res = nobleInteger ( arr ) ; if ( res != - 1 ) document . write ( " " + res ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function nobleInteger ( arr , n ) { let countArr = new Uint8Array ( n + 1 ) ; for ( let i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < 0 ) { continue ; } else if ( arr [ i ] >= n ) { countArr [ n ] ++ ; } else { countArr [ arr [ i ] ] ++ ; } } let totalGreater = countArr [ n ] ; for ( let i = n - 1 ; i >= 0 ; i -- ) { if ( totalGreater == i && countArr [ i ] > 0 ) { return i ; } else if ( totalGreater > i ) { return - 1 ; } totalGreater += countArr [ i ] ; } return - 1 ; } let arr = [ 10 , 3 , 20 , 40 , 2 ] ; let res = nobleInteger ( arr , 5 ) ; if ( res != - 1 ) document . write ( " " + res ) ; else document . write ( " " ) ;

Index/key variables: i, n
Accumulator variables: i, totalGreater
Iterator variables: i
Javascript program:
function findMinSum ( a , b , n ) { a . sort ( ) ; b . sort ( ) ; let sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) sum = sum + Math . abs ( a [ i ] - b [ i ] ) ; return sum ; } let a = [ 4 , 1 , 8 , 7 ] ; let b = [ 2 , 3 , 6 , 5 ] ; let n = a . length ; document . write ( findMinSum ( a , b , n ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function minProductSubset ( a , n ) { if ( n == 1 ) return a [ 0 ] ; let negmax = Number . MIN_VALUE ; let posmin = Number . MIN_VALUE ; let count_neg = 0 , count_zero = 0 ; let product = 1 ; for ( let i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 0 ) { count_zero ++ ; continue ; } if ( a [ i ] < 0 ) { count_neg ++ ; negmax = Math . max ( negmax , a [ i ] ) ; } if ( a [ i ] > 0 && a [ i ] < posmin ) { posmin = a [ i ] ; } product *= a [ i ] ; } if ( count_zero == n || ( count_neg == 0 && count_zero > 0 ) ) return 0 ; if ( count_neg == 0 ) return posmin ; if ( count_neg % 2 == 0 && count_neg != 0 ) { product = parseInt ( product / negmax , 10 ) ; } return product ; } let a = [ - 1 , - 1 , - 2 , 4 , 3 ] ; let n = 5 ; document . write ( minProductSubset ( a , n ) ) ;

Index/key variables: i
Accumulator variables: count_neg, count_zero, i, product
Iterator variables: i
Javascript program:
function binary_search ( a , x , lo = 0 , hi = null ) { if ( hi == null ) hi = a . length ; while ( lo < hi ) { mid = Math . floor ( ( lo + hi ) / 2 ) ; midval = a [ mid ] ; if ( midval < x ) lo = mid + 1 ; else if ( midval > x ) hi = mid ; else return mid ; } return - 1 ; } function findElement ( a , n , b ) { a . sort ( ( a , b ) => a - b ) ; let max = a [ n - 1 ] ; while ( b < max ) { if ( binary_search ( a , a + n , b ) ) b *= 2 ; else return b ; } return b ; } let a = [ 1 , 2 , 3 ] ; let n = a . length ; let b = 1 ; document . write ( findElement ( a , n , b ) ) ;

Index/key variables: mid
Accumulator variables: b
Javascript program:
let Mod = 1000000007 ; function findSum ( arr , n ) { let sum = 0 ; arr . sort ( ) ; let i = 0 ; while ( i < n && arr [ i ] < 0 ) { if ( i != n - 1 && arr [ i + 1 ] <= 0 ) { sum = ( sum + ( arr [ i ] * arr [ i + 1 ] ) % Mod ) % Mod ; i += 2 ; } else break ; } let j = n - 1 ; while ( j >= 0 && arr [ j ] > 0 ) { if ( j != 0 && arr [ j - 1 ] > 0 ) { sum = ( sum + ( arr [ j ] * arr [ j - 1 ] ) % Mod ) % Mod ; j -= 2 ; } else break ; } if ( j > i ) sum = ( sum + ( arr [ i ] * arr [ j ] ) % Mod ) % Mod ; else if ( i == j ) sum = ( sum + arr [ i ] ) % Mod ; return sum ; } let arr = [ - 1 , 9 , 4 , 5 , - 4 , 7 ] ; let n = arr . length ; document . write ( findSum ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Javascript program:
class Node { constructor ( val ) { this . data = val ; this . next = null ; } } var head ; function push ( new_data ) { var new_node = new Node ( new_data ) ; new_node . next = head ; head = new_node ; } function search ( head , x ) { if ( head == null ) return false ; if ( head . data == x ) return true ; return search ( head . next , x ) ; } push ( 10 ) ; push ( 30 ) ; push ( 11 ) ; push ( 21 ) ; push ( 14 ) ; if ( search ( head , 21 ) ) document . write ( " " ) ; else document . write ( " " ) ;

Class/struct names: Node
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . next = null ; } } var head_ref = null ; function reverse ( ) { var prev = null ; var current = head_ref ; while ( current != null ) { var next = current . next ; current . next = prev ; prev = current ; current = next ; } head_ref = prev ; } function push ( new_data ) { var new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = ( head_ref ) ; ( head_ref ) = new_node ; } function printList ( ) { var temp = head_ref ; while ( temp != null ) { document . write ( temp . data + " " ) ; temp = temp . next ; } } push ( 20 ) ; push ( 4 ) ; push ( 15 ) ; push ( 85 ) ; document . write ( " " ) ; printList ( ) ; reverse ( ) ; document . write ( " " ) ; printList ( ) ;

Class/struct names: Node
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . next = null ; } } var head = null ; function rotate ( k ) { if ( k == 0 ) return ; var current = head ; while ( current . next != null ) current = current . next ; current . next = head ; current = head ; for ( i = 0 ; i < k - 1 ; i ++ ) current = current . next ; head = current . next ; current . next = null ; } function push ( new_data ) { var new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = head ; head = new_node ; } function printList ( node ) { while ( node != null ) { document . write ( node . data + " " ) ; node = node . next ; } } for ( i = 60 ; i > 0 ; i -= 10 ) push ( i ) ; document . write ( " " ) ; printList ( head ) ; rotate ( 4 ) ; document . write ( " " ) ; printList ( head ) ;

Accumulator variables: i
Iterator variables: i
Class/struct names: Node
Javascript program:
var head ; class Node { constructor ( val ) { this . data = val ; this . down = null ; this . next = null ; } } function merge ( a , b ) { if ( a == null ) return b ; if ( b == null ) return a ; var result ; if ( a . data < b . data ) { result = a ; result . down = merge ( a . down , b ) ; } else { result = b ; result . down = merge ( a , b . down ) ; } result . right = null ; return result ; } function flatten ( root ) { if ( root == null root . right == null ) return root ; root . right = flatten ( root . right ) ; root = merge ( root , root . right ) ; return root ; } function push ( head_ref , data ) { var new_node = new Node ( data ) ; new_node . down = head_ref ; head_ref = new_node ; return head_ref ; } function printList ( ) { var temp = head ; while ( temp != null ) { document . write ( temp . data + " " ) ; temp = temp . down ; } document . write ( ) ; } head = push ( head , 30 ) ; head = push ( head , 8 ) ; head = push ( head , 7 ) ; head = push ( head , 5 ) ; head . right = push ( head . right , 20 ) ; head . right = push ( head . right , 10 ) ; head . right . right = push ( head . right . right , 50 ) ; head . right . right = push ( head . right . right , 22 ) ; head . right . right = push ( head . right . right , 19 ) ; head . right . right . right = push ( head . right . right . right , 45 ) ; head . right . right . right = push ( head . right . right . right , 40 ) ; head . right . right . right = push ( head . right . right . right , 35 ) ; head . right . right . right = push ( head . right . right . right , 20 ) ; head = flatten ( head ) ; printList ( ) ;

Class/struct names: Node
Javascript program:
var head ; class Node { constructor ( val ) { this . data = val ; this . next = null ; } } function sortList ( ) { var count = [ 0 , 0 , 0 ] ; var ptr = head ; while ( ptr != null ) { count [ ptr . data ] ++ ; ptr = ptr . next ; } var i = 0 ; ptr = head ; while ( ptr != null ) { if ( count [ i ] == 0 ) i ++ ; else { ptr . data = i ; -- count [ i ] ; ptr = ptr . next ; } } } function push ( new_data ) { var new_node = new Node ( new_data ) ; new_node . next = head ; head = new_node ; } function printList ( ) { var temp = head ; while ( temp != null ) { document . write ( temp . data + " " ) ; temp = temp . next ; } document . write ( " " ) ; } push ( 0 ) ; push ( 1 ) ; push ( 0 ) ; push ( 2 ) ; push ( 1 ) ; push ( 1 ) ; push ( 2 ) ; push ( 1 ) ; push ( 2 ) ; document . write ( " " ) ; printList ( ) ; sortList ( ) ; document . write ( " " ) ; printList ( ) ;

Index/key variables: i
Accumulator variables: i
Class/struct names: Node
Javascript program:
class List { constructor ( ) { this . data = 0 ; this . next = null ; this . child = null ; } }

Class/struct names: List
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . next = null ; } } function newNode ( key ) { var temp = new Node ( ) ; temp . data = key ; temp . next = null ; return temp ; } function rearrangeEvenOdd ( head ) { if ( head == null ) return null ; var odd = head ; var even = head . next ; var evenFirst = even ; while ( 1 == 1 ) { if ( odd == null || even == null || ( even . next ) == null ) { odd . next = evenFirst ; break ; } odd . next = even . next ; odd = even . next ; if ( odd . next == null ) { even . next = null ; odd . next = evenFirst ; break ; } even . next = odd . next ; even = odd . next ; } return head ; } function printlist ( node ) { while ( node != null ) { document . write ( node . data + " " ) ; node = node . next ; } document . write ( " " ) ; } var head = newNode ( 1 ) ; head . next = newNode ( 2 ) ; head . next . next = newNode ( 3 ) ; head . next . next . next = newNode ( 4 ) ; head . next . next . next . next = newNode ( 5 ) ; document . write ( " " ) ; printlist ( head ) ; head = rearrangeEvenOdd ( head ) ; document . write ( " " ) ; printlist ( head ) ;

Class/struct names: Node
Javascript program:
class Node { constructor ( val ) { this . data = val ; this . next = null ; } } var head ; function printLL ( ) { var t = head ; while ( t != null ) { document . write ( t . data + " " ) ; t = t . next ; } document . write ( ) ; } function swap ( a , b ) { if ( a == null b == null ) return ; var temp = a . data ; a . data = b . data ; b . data = temp ; } function zigZag ( node , flag ) { if ( node == null node . next == null ) { return node ; } if ( flag == 0 ) { if ( node . data > node . next . data ) { swap ( node , node . next ) ; } return zigZag ( node . next , 1 ) ; } else { if ( node . data < node . next . data ) { swap ( node , node . next ) ; } return zigZag ( node . next , 0 ) ; } } head = new Node ( 11 ) ; head . next = new Node ( 15 ) ; head . next . next = new Node ( 20 ) ; head . next . next . next = new Node ( 5 ) ; head . next . next . next . next = new Node ( 10 ) ; printLL ( ) ; var flag = 0 ; zigZag ( head , flag ) ; document . write ( " " ) ; printLL ( ) ;

Class/struct names: Node
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . next = null ; } } function newNode ( data ) { var new_node = new Node ( ) ; new_node . data = data ; new_node . next = null ; return new_node ; } function addWithCarry ( head ) { if ( head == null ) return 1 ; var res = head . data + addWithCarry ( head . next ) ; head . data = res % 10 ; return parseInt ( res / 10 ) ; } function addOne ( head ) { var carry = addWithCarry ( head ) ; var newNodes = null ; if ( carry > 0 ) { newNodes = newNode ( carry ) ; newNodes . next = head ; return newNodes ; } return head ; } function printList ( node ) { while ( node != null ) { document . write ( node . data ) ; node = node . next ; } document . write ( " " ) ; } var head = newNode ( 1 ) ; head . next = newNode ( 9 ) ; head . next . next = newNode ( 9 ) ; head . next . next . next = newNode ( 9 ) ; document . write ( " " ) ; printList ( head ) ; head = addOne ( head ) ; document . write ( " " ) ; document . write ( " " ) ; printList ( head ) ;

Class/struct names: Node
Javascript program:
class Node { constructor ( val ) { this . data = val ; this . arbit = null ; this . next = null ; } } function reverse ( head ) { var prev = null , current = head , next = null ; while ( current != null ) { next = current . next ; current . next = prev ; prev = current ; current = next ; } return prev ; } function populateArbit ( head ) { head = reverse ( head ) ; var max = head ; var temp = head . next ; while ( temp != null ) { temp . arbit = max ; if ( max . data < temp . data ) max = temp ; temp = temp . next ; } return reverse ( head ) ; } function printNextArbitPointers ( node ) { document . write ( " " ) ; while ( node != null ) { document . write ( node . data + " " ) ; if ( node . next != null ) document . write ( node . next . data + " " ) ; else document . write ( " " + " " ) ; if ( node . arbit != null ) document . write ( node . arbit . data ) ; else document . write ( " " ) ; document . write ( " " ) ; node = node . next ; } } function newNode ( data ) { var new_node = new Node ( ) ; new_node . data = data ; new_node . next = null ; return new_node ; } var head = newNode ( 5 ) ; head . next = newNode ( 10 ) ; head . next . next = newNode ( 2 ) ; head . next . next . next = newNode ( 3 ) ; head = populateArbit ( head ) ; document . write ( " " ) ; printNextArbitPointers ( head ) ;

Class/struct names: Node
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . arbit = null ; this . next = null ; } } var maxNode ; function populateArbit ( head ) { if ( head == null ) return ; if ( head . next == null ) { maxNode = head ; return ; } populateArbit ( head . next ) ; head . arbit = maxNode ; if ( head . data > maxNode . data ) maxNode = head ; return ; } function printNextArbitPointers ( node ) { document . write ( " " ) ; while ( node != null ) { document . write ( node . data + " " ) ; if ( node . next != null ) document . write ( node . next . data + " " ) ; else document . write ( " " + " " ) ; if ( node . arbit != null ) document . write ( node . arbit . data ) ; else document . write ( " " ) ; document . write ( " " ) ; node = node . next ; } } function newNode ( data ) { var new_node = new Node ( ) ; new_node . data = data ; new_node . next = null ; return new_node ; } var head = newNode ( 5 ) ; head . next = newNode ( 10 ) ; head . next . next = newNode ( 2 ) ; head . next . next . next = newNode ( 3 ) ; populateArbit ( head ) ; document . write ( " " ) ; printNextArbitPointers ( head ) ;

Class/struct names: Node
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . next = null ; } } function deleteLast ( head , x ) { var temp = head , ptr = null ; while ( temp != null ) { if ( temp . data == x ) ptr = temp ; temp = temp . next ; } if ( ptr != null && ptr . next == null ) { temp = head ; while ( temp . next != ptr ) temp = temp . next ; temp . next = null ; } if ( ptr != null && ptr . next != null ) { ptr . data = ptr . next . data ; temp = ptr . next ; ptr . next = ptr . next . next ; } } function newNode ( x ) { var node = new Node ( ) ; node . data = x ; node . next = null ; return node ; } function display ( head ) { var temp = head ; if ( head == null ) { document . write ( " " ) ; return ; } while ( temp != null ) { document . write ( temp . data + " " ) ; temp = temp . next ; } document . write ( " " ) ; } var head = newNode ( 1 ) ; head . next = newNode ( 2 ) ; head . next . next = newNode ( 3 ) ; head . next . next . next = newNode ( 4 ) ; head . next . next . next . next = newNode ( 5 ) ; head . next . next . next . next . next = newNode ( 4 ) ; head . next . next . next . next . next . next = newNode ( 4 ) ; document . write ( " " ) ; display ( head ) ; deleteLast ( head , 4 ) ; document . write ( " " ) ; display ( head ) ;

Class/struct names: Node
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . next = null ; } } function newNode ( data ) { var new_node = new Node ( ) ; new_node . data = data ; new_node . next = null ; return new_node ; } function partition ( head , x ) { var smallerHead = null , smallerLast = null ; var greaterLast = null , greaterHead = null ; var equalHead = null , equalLast = null ; while ( head != null ) { if ( head . data == x ) { if ( equalHead == null ) equalHead = equalLast = head ; else { equalLast . next = head ; equalLast = equalLast . next ; } } else if ( head . data < x ) { if ( smallerHead == null ) smallerLast = smallerHead = head ; else { smallerLast . next = head ; smallerLast = head ; } } else { if ( greaterHead == null ) greaterLast = greaterHead = head ; else { greaterLast . next = head ; greaterLast = head ; } } head = head . next ; } if ( greaterLast != null ) greaterLast . next = null ; if ( smallerHead == null ) { if ( equalHead == null ) return greaterHead ; equalLast . next = greaterHead ; return equalHead ; } if ( equalHead == null ) { smallerLast . next = greaterHead ; return smallerHead ; } smallerLast . next = equalHead ; equalLast . next = greaterHead ; return smallerHead ; } function printList ( head ) { var temp = head ; while ( temp != null ) { document . write ( temp . data + " " ) ; temp = temp . next ; } } var head = newNode ( 10 ) ; head . next = newNode ( 4 ) ; head . next . next = newNode ( 5 ) ; head . next . next . next = newNode ( 30 ) ; head . next . next . next . next = newNode ( 2 ) ; head . next . next . next . next . next = newNode ( 50 ) ; var x = 3 ; head = partition ( head , x ) ; printList ( head ) ;

Class/struct names: Node
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . next = null ; } } function getLoopstart ( loop_node , head ) { var ptr1 = loop_node ; var ptr2 = loop_node ; var k = 1 , i ; while ( ptr1 . next != ptr2 ) { ptr1 = ptr1 . next ; k ++ ; } ptr1 = head ; ptr2 = head ; for ( i = 0 ; i < k ; i ++ ) ptr2 = ptr2 . next ; while ( ptr2 != ptr1 ) { ptr1 = ptr1 . next ; ptr2 = ptr2 . next ; } return ptr1 ; } function detectAndgetLoopstarting ( head ) { var slow_p = head , fast_p = head , loop_start = null ; while ( slow_p != null && fast_p != null && fast_p . next != null ) { slow_p = slow_p . next ; fast_p = fast_p . next . next ; if ( slow_p == fast_p ) { loop_start = getLoopstart ( slow_p , head ) ; break ; } } return loop_start ; } function isPalindromeUtil ( head , loop_start ) { var ptr = head ; var s = [ ] ; var count = 0 ; while ( ptr != loop_start count != 1 ) { s . push ( ptr . data ) ; if ( ptr == loop_start ) count = 1 ; ptr = ptr . next ; } ptr = head ; count = 0 ; while ( ptr != loop_start count != 1 ) { var stk = s . pop ( ) ; if ( ptr . data == stk ) ; else { s . push ( stk ) ; return false ; } if ( ptr == loop_start ) count = 1 ; ptr = ptr . next ; } return true ; } function isPalindrome ( head ) { var loop_start = detectAndgetLoopstarting ( head ) ; return isPalindromeUtil ( head , loop_start ) ; } function newNode ( key ) { var temp = new Node ( ) ; temp . data = key ; temp . next = null ; return temp ; } var head = newNode ( 50 ) ; head . next = newNode ( 20 ) ; head . next . next = newNode ( 15 ) ; head . next . next . next = newNode ( 20 ) ; head . next . next . next . next = newNode ( 50 ) ; head . next . next . next . next . next = head . next . next ; if ( isPalindrome ( head ) == true ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: i, k
Iterator variables: i
Class/struct names: Node
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . next = null ; } } function countCommon ( a , b ) { var count = 0 ; for ( ; a != null && b != null ; a = a . next , b = b . next ) if ( a . data == b . data ) ++ count ; else break ; return count ; } function maxPalindrome ( head ) { var result = 0 ; var prev = null , curr = head ; while ( curr != null ) { var next = curr . next ; curr . next = prev ; result = Math . max ( result , 2 * countCommon ( prev , next ) + 1 ) ; result = Math . max ( result , 2 * countCommon ( curr , next ) ) ; prev = curr ; curr = next ; } return result ; } function newNode ( key ) { var temp = new Node ( ) ; temp . data = key ; temp . next = null ; return temp ; } var head = newNode ( 2 ) ; head . next = newNode ( 4 ) ; head . next . next = newNode ( 3 ) ; head . next . next . next = newNode ( 4 ) ; head . next . next . next . next = newNode ( 2 ) ; head . next . next . next . next . next = newNode ( 15 ) ; document . write ( maxPalindrome ( head ) ) ;

Class/struct names: Node
Javascript program:
var list = [ ] ; list . push ( 1 ) ; list . push ( 2 ) ; list . push ( 3 ) ; for ( var i = 0 ; i < list . length ; i ++ ) { document . write ( list [ i ] + " " ) ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . next = null ; } } function newNode ( x ) { var temp = new Node ( ) ; temp . data = x ; temp . next = null ; return temp ; } function printList ( head ) { var temp = head ; while ( temp != null ) { document . write ( temp . data + " " ) ; temp = temp . next ; } document . write ( " " ) ; } function moveToEnd ( head , key ) { var pKey = head ; var pCrawl = head ; while ( pCrawl != null ) { if ( pCrawl != pKey && pCrawl . data != key ) { pKey . data = pCrawl . data ; pCrawl . data = key ; pKey = pKey . next ; } if ( pKey . data != key ) pKey = pKey . next ; pCrawl = pCrawl . next ; } } var head = newNode ( 10 ) ; head . next = newNode ( 20 ) ; head . next . next = newNode ( 10 ) ; head . next . next . next = newNode ( 30 ) ; head . next . next . next . next = newNode ( 40 ) ; head . next . next . next . next . next = newNode ( 10 ) ; head . next . next . next . next . next . next = newNode ( 60 ) ; document . write ( " " ) ; printList ( head ) ; var key = 10 ; moveToEnd ( head , key ) ; document . write ( " " ) ; printList ( head ) ;

Class/struct names: Node
Javascript program:
class Node { constructor ( val ) { this . data = val ; this . next = null ; } } var root ; function keyToEnd ( head , key ) { var tail = head ; if ( head == null ) { return null ; } while ( tail . next != null ) { tail = tail . next ; } var last = tail ; var current = head ; var prev = null ; var prev2 = null ; while ( current != tail ) { if ( current . data == key && prev2 == null ) { prev = current ; current = current . next ; head = current ; last . next = prev ; last = last . next ; last . next = null ; prev = null ; } else { if ( current . data == key && prev2 != null ) { prev = current ; current = current . next ; prev2 . next = current ; last . next = prev ; last = last . next ; last . next = null ; } else if ( current != tail ) { prev2 = current ; current = current . next ; } } } return head ; } function display ( root ) { while ( root != null ) { document . write ( root . data + " " ) ; root = root . next ; } } root = new Node ( 5 ) ; root . next = new Node ( 2 ) ; root . next . next = new Node ( 2 ) ; root . next . next . next = new Node ( 7 ) ; root . next . next . next . next = new Node ( 2 ) ; root . next . next . next . next . next = new Node ( 2 ) ; root . next . next . next . next . next . next = new Node ( 2 ) ; var key = 2 ; document . write ( " " ) ; display ( root ) ; document . write ( " " ) ; root = keyToEnd ( root , key ) ; display ( root ) ;

Class/struct names: Node