dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
class Node { constructor ( ) { this . info = 0 ; this . prev = null ; this . next = null ; } } var head , tail ; function nodeInsetail ( key ) { p = new Node ( ) ; p . info = key ; p . next = null ; if ( head == null ) { head = p ; tail = p ; head . prev = null ; return ; } if ( p . info < head . info ) { p . prev = null ; head . prev = p ; p . next = head ; head = p ; return ; } if ( p . info > tail . info ) { p . prev = tail ; tail . next = p ; tail = p ; return ; } temp = head . next ; while ( temp . info < p . info ) temp = temp . next ; ( temp . prev ) . next = p ; p . prev = temp . prev ; temp . prev = p ; p . next = temp ; } function printList ( temp ) { while ( temp != null ) { document . write ( temp . info + " " ) ; temp = temp . next ; } } head = tail = null ; nodeInsetail ( 30 ) ; nodeInsetail ( 50 ) ; nodeInsetail ( 90 ) ; nodeInsetail ( 10 ) ; nodeInsetail ( 40 ) ; nodeInsetail ( 110 ) ; nodeInsetail ( 60 ) ; nodeInsetail ( 95 ) ; nodeInsetail ( 23 ) ; document . write ( " " ) ; printList ( head ) ;

Class/struct names: Node
Javascript program:
class Node { constructor ( item ) { this . data = item ; this . next = null ; } }

Class/struct names: Node
Javascript program:
class Node { constructor ( x ) { this . data = x ; this . left = null ; this . right = null ; } } let count = 0 ; function insert ( root , x ) { if ( root == null ) return new Node ( x ) ; if ( x < root . data ) root . left = insert ( root . left , x ) ; else if ( x > root . data ) root . right = insert ( root . right , x ) ; return root ; } function kthSmallest ( root , k ) { if ( root == null ) return null ; let left = kthSmallest ( root . left , k ) ; if ( left != null ) return left ; count ++ ; if ( count == k ) return root ; return kthSmallest ( root . right , k ) ; } function printKthSmallest ( root , k ) { count = 0 ; let res = kthSmallest ( root , k ) ; if ( res == null ) document . write ( " " + " " ) ; else document . write ( " " + " " + res . data ) ; } let root = null ; let key = [ 20 , 8 , 22 , 4 , 12 , 10 , 14 ] ; for ( let i = 0 ; i < key . length ; i ++ ) { root = insert ( root , key [ i ] ) ; } let k = 3 ; printKthSmallest ( root , k ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: Node
Javascript program:
class Node { constructor ( ) { this . key = 0 ; this . left = null ; this . right = null ; } } function KSmallestUsingMorris ( root , k ) { var count = 0 ; var ksmall = Number . MIN_VALUE ; var curr = root ; while ( curr != null ) { if ( curr . left == null ) { count ++ ; if ( count == k ) ksmall = curr . key ; curr = curr . right ; } else { var pre = curr . left ; while ( pre . right != null && pre . right != curr ) pre = pre . right ; if ( pre . right == null ) { pre . right = curr ; curr = curr . left ; } else { pre . right = null ; count ++ ; if ( count == k ) ksmall = curr . key ; curr = curr . right ; } } } return ksmall ; } function newNode ( item ) { var temp = new Node ( ) ; temp . key = item ; temp . left = null ; temp . right = null ; return temp ; } function insert ( node , 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 ; } var root = null ; root = insert ( root , 50 ) ; insert ( root , 30 ) ; insert ( root , 20 ) ; insert ( root , 40 ) ; insert ( root , 70 ) ; insert ( root , 60 ) ; insert ( root , 80 ) ; for ( k = 1 ; k <= 7 ; k ++ ) document . write ( KSmallestUsingMorris ( root , k ) + " " ) ;

Accumulator variables: count, k
Iterator variables: k
Class/struct names: Node
Javascript program:
function isInorder ( arr , n ) { if ( n == 0 n == 1 ) { return true ; } for ( i = 1 ; i < n ; i ++ ) { if ( arr [ i - 1 ] > arr [ i ] ) { return false ; } } return true ; } var arr = [ 19 , 23 , 25 , 30 , 45 ] ; var n = arr . length ; if ( isInorder ( arr , n ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
class TreeNode { constructor ( x ) { this . val = x ; this . left = null ; this . right = null ; } } let set = new Set ( ) ; let stack = [ ] ; function buildTree ( preorder , inorder ) { let root = null ; for ( let pre = 0 , In = 0 ; pre < preorder . length ; ) { let node = null ; do { node = new TreeNode ( preorder [ pre ] ) ; if ( root == null ) { root = node ; } if ( stack . length != 0 ) { if ( set . has ( stack [ stack . length - 1 ] ) ) { set . delete ( stack [ stack . length - 1 ] ) ; stack . pop ( ) . right = node ; } else { stack [ stack . length - 1 ] . left = node ; } } stack . push ( node ) ; } while ( preorder [ pre ++ ] != inorder [ In ] && pre < preorder . length ) ; node = null ; while ( stack . length != 0 && In < inorder . length && stack [ stack . length - 1 ] . val == inorder [ In ] ) { node = stack . pop ( ) ; In ++ ; } if ( node != null ) { set . add ( node ) ; stack . push ( node ) ; } } return root ; } function printInorder ( node ) { if ( node == null ) return ; printInorder ( node . left ) ; document . write ( node . val + " " ) ; printInorder ( node . right ) ; } let In = [ 9 , 8 , 4 , 2 , 10 , 5 , 10 , 1 , 6 , 3 , 13 , 12 , 7 ] ; let pre = [ 1 , 2 , 4 , 8 , 9 , 5 , 10 , 10 , 3 , 6 , 7 , 12 , 13 ] ; let len = In . length ; let root = buildTree ( pre , In ) ; printInorder ( root ) ;

Index/key variables: In, pre
Accumulator variables: In, pre
Iterator variables: pre
Class/struct names: TreeNode
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . prev = null ; this . next = null ; } } function newNode ( val ) { var temp = new Node ( ) ; temp . data = val ; temp . left = temp . right = null ; return temp ; } function storeInorder ( root , v ) { if ( root == null ) return ; storeInorder ( root . left , v ) ; v . push ( root . data ) ; storeInorder ( root . right , v ) ; } function checkBSTs ( root1 , root2 ) { if ( root1 != null && root2 != null ) return true ; if ( ( root1 == null && root2 != null ) || ( root1 != null && root2 == null ) ) return false ; var v1 = [ ] ; var v2 = [ ] ; storeInorder ( root1 , v1 ) ; storeInorder ( root2 , v2 ) ; return ( v1 == v2 ) ; } var root1 = newNode ( 15 ) ; root1 . left = newNode ( 10 ) ; root1 . right = newNode ( 20 ) ; root1 . left . left = newNode ( 5 ) ; root1 . left . right = newNode ( 12 ) ; root1 . right . right = newNode ( 25 ) ; var root2 = newNode ( 15 ) ; root2 . left = newNode ( 12 ) ; root2 . right = newNode ( 20 ) ; root2 . left . left = newNode ( 5 ) ; root2 . left . left . right = newNode ( 10 ) ; root2 . right . right = newNode ( 25 ) ; if ( checkBSTs ( root1 , root2 ) ) document . write ( " " ) ; else document . write ( " " ) ;

Class/struct names: Node
Javascript program:
class Node { constructor ( ) { this . key = 0 ; this . left = null ; this . right = null ; } } function newNode ( key ) { var ptr = new Node ( ) ; ptr . key = key ; ptr . left = null ; ptr . right = null ; return ptr ; } function insert ( root , key ) { if ( root == null ) root = newNode ( key ) ; else if ( root . key > key ) root . left = insert ( root . left , key ) ; else if ( root . key < key ) root . right = insert ( root . right , key ) ; return root ; } function distanceFromRoot ( root , x ) { if ( root . key == x ) return 0 ; else if ( root . key > x ) return 1 + distanceFromRoot ( root . left , x ) ; return 1 + distanceFromRoot ( root . right , x ) ; } function distanceBetween2 ( root , a , b ) { if ( root == null ) return 0 ; if ( root . key > a && root . key > b ) return distanceBetween2 ( root . left , a , b ) ; if ( root . key < a && root . key < b ) return distanceBetween2 ( root . right , a , b ) ; if ( root . key >= a && root . key <= b ) return distanceFromRoot ( root , a ) + distanceFromRoot ( root , b ) ; return 0 ; } function findDistWrapper ( root , a , b ) { var temp = 0 ; if ( a > b ) { temp = a ; a = b ; b = temp ; } return distanceBetween2 ( root , a , b ) ; } var root = null ; root = insert ( root , 20 ) ; insert ( root , 10 ) ; insert ( root , 5 ) ; insert ( root , 15 ) ; insert ( root , 30 ) ; insert ( root , 25 ) ; insert ( root , 35 ) ; document . write ( findDistWrapper ( root , 5 , 35 ) ) ;

Class/struct names: Node
Javascript program:
class node { constructor ( ) { this . data = 0 ; this . left = null ; this . right = null ; } } function RangeTraversal ( root , n1 , n2 ) { if ( root == null ) return ; var curr = root ; while ( curr != null ) { if ( curr . left == null ) { if ( curr . data <= n2 && curr . data >= n1 ) { document . write ( curr . data + " " ) ; } curr = curr . right ; } else { var pre = curr . left ; while ( pre . right != null && pre . right != curr ) pre = pre . right ; if ( pre . right == null ) { pre . right = curr ; curr = curr . left ; } else { pre . right = null ; if ( curr . data <= n2 && curr . data >= n1 ) { document . write ( curr . data + " " ) ; } curr = curr . right ; } } } } function newNode ( data ) { temp = new node ( ) ; temp . data = data ; temp . right = null ; temp . left = null ; return temp ; } root = newNode ( 4 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 7 ) ; root . left . left = newNode ( 1 ) ; root . left . right = newNode ( 3 ) ; root . right . left = newNode ( 6 ) ; root . right . right = newNode ( 10 ) ; RangeTraversal ( root , 4 , 12 ) ;

Class/struct names: node
Javascript program:
class node { constructor ( val ) { this . data = val ; this . left = null ; this . right = null ; } } class INT { constructor ( ) { this . a = 0 ; } } function inRange ( root , low , high ) { return root . data >= low && root . data <= high ; } function getCountUtil ( root , low , high , count ) { if ( root == null ) return true ; var l = getCountUtil ( root . left , low , high , count ) ; var r = getCountUtil ( root . right , low , high , count ) ; if ( l && r && inRange ( root , low , high ) ) { ++ count . a ; return true ; } return false ; } function getCount ( root , low , high ) { var count = new INT ( ) ; count . a = 0 ; getCountUtil ( root , low , high , count ) ; return count ; } function newNode ( data ) { var temp = new node ( ) ; temp . data = data ; temp . left = temp . right = null ; return ( temp ) ; } var root = newNode ( 10 ) ; root . left = newNode ( 5 ) ; root . right = newNode ( 50 ) ; root . left . left = newNode ( 1 ) ; root . right . left = newNode ( 40 ) ; root . right . right = newNode ( 100 ) ; var l = 5 ; var h = 45 ; document . write ( " " + l + " " + h + " " + getCount ( root , l , h ) . a ) ;

Class/struct names: INT, node
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . left = null ; this . right = null ; } } function newNode ( data ) { var temp = new Node ( ) ; temp . data = data ; temp . left = null ; temp . right = null ; return temp ; } function insert ( root , data ) { if ( root == null ) return newNode ( data ) ; if ( data < root . data ) root . left = insert ( root . left , data ) ; else if ( data > root . data ) root . right = insert ( root . right , data ) ; return root ; } function inorder ( root ) { if ( root != null ) { inorder ( root . left ) ; document . write ( root . data + " " ) ; inorder ( root . right ) ; } } function leafDelete ( root ) { if ( root == null ) { return null ; } if ( root . left == null && root . right == null ) { return null ; } root . left = leafDelete ( root . left ) ; root . right = leafDelete ( root . right ) ; return root ; } var root = null ; root = insert ( root , 20 ) ; insert ( root , 10 ) ; insert ( root , 5 ) ; insert ( root , 15 ) ; insert ( root , 30 ) ; insert ( root , 25 ) ; insert ( root , 35 ) ; document . write ( " " ) ; inorder ( root ) ; document . write ( " " ) ; leafDelete ( root ) ; document . write ( " " ) ; inorder ( root ) ;

Class/struct names: Node
Javascript program:
class Node { constructor ( ) { this . data = 0 ; this . left = null ; this . right = null ; } } function createNode ( data ) { var new_Node = new Node ( ) ; new_Node . left = null ; new_Node . right = null ; new_Node . data = data ; return new_Node ; } function insert ( root , key ) { if ( root == null ) return createNode ( key ) ; if ( root . data > key ) root . left = insert ( root . left , key ) ; else if ( root . data < key ) root . right = insert ( root . right , key ) ; return root ; } var count = 0 ; function ksmallestElementSumRec ( root , k ) { if ( root == null ) return 0 ; if ( count > k ) return 0 ; var res = ksmallestElementSumRec ( root . left , k ) ; if ( count >= k ) return res ; res += root . data ; count ++ ; if ( count >= k ) return res ; return res + ksmallestElementSumRec ( root . right , k ) ; } function ksmallestElementSum ( root , k ) { var res = ksmallestElementSumRec ( root , k ) ; return res ; } var root = null ; root = insert ( root , 20 ) ; root = insert ( root , 8 ) ; root = insert ( root , 4 ) ; root = insert ( root , 12 ) ; root = insert ( root , 10 ) ; root = insert ( root , 14 ) ; root = insert ( root , 22 ) ; var k = 3 ; var count = ksmallestElementSum ( root , k ) ; document . write ( count ) ;

Accumulator variables: count, res
Class/struct names: Node
Javascript program:
class Node { constructor ( val ) { this . key = val ; this . left = null ; this . right = null ; } } var pre ; var suc ; function findPreSuc ( root , key ) { if ( root == null ) return ; while ( root != null ) { if ( root . key == key ) { if ( root . right != null ) { suc = root . right ; while ( suc . left != null ) suc = suc . left ; } if ( root . left != null ) { pre = root . left ; while ( pre . right != null ) pre = pre . right ; } return ; } else if ( root . key < key ) { pre = root ; root = root . right ; } else { suc = root ; root = root . left ; } } } function newNode ( item ) { var temp = new Node ( ) ; temp . key = item ; temp . left = temp . right = null ; return temp ; } function insert ( node , key ) { if ( node == null ) return newNode ( key ) ; if ( key < node . key ) node . left = insert ( node . left , key ) ; else node . right = insert ( node . right , key ) ; return node ; } var key = 65 ; var root = null ; root = insert ( root , 50 ) ; insert ( root , 30 ) ; insert ( root , 20 ) ; insert ( root , 40 ) ; insert ( root , 70 ) ; insert ( root , 60 ) ; insert ( root , 80 ) ; findPreSuc ( root , key ) ; if ( pre != null ) document . write ( " " + pre . key + " " ) ; else document . write ( " " ) ; if ( suc != null ) document . write ( " " + suc . key ) ; else document . write ( " " ) ;

Class/struct names: Node
Javascript program:
class node { constructor ( val ) { this . key = val ; this . left = null ; this . right = null ; } } var head ; var tail ; function convertBSTtoDLL ( root ) { if ( root == null ) return ; if ( root . left != null ) convertBSTtoDLL ( root . left ) ; root . left = tail ; if ( tail != null ) ( tail ) . right = root ; else head = root ; tail = root ; if ( root . right != null ) convertBSTtoDLL ( root . right ) ; } function isPresentInDLL ( head , tail , sum ) { while ( head != tail ) { var curr = head . key + tail . key ; if ( curr == sum ) return true ; else if ( curr > sum ) tail = tail . left ; else head = head . right ; } return false ; } function isTripletPresent ( root ) { if ( root == null ) return false ; head = null ; tail = null ; convertBSTtoDLL ( root ) ; while ( ( head . right != tail ) && ( head . key < 0 ) ) { if ( isPresentInDLL ( head . right , tail , - 1 * head . key ) ) return true ; else head = head . right ; } return false ; } function newNode ( num ) { var temp = new node ( ) ; temp . key = num ; temp . left = temp . right = null ; return temp ; } function insert ( root , key ) { if ( root == null ) return newNode ( key ) ; if ( root . key > key ) root . left = insert ( root . left , key ) ; else root . right = insert ( root . right , key ) ; return root ; } var root = null ; root = insert ( root , 6 ) ; root = insert ( root , - 13 ) ; root = insert ( root , 14 ) ; root = insert ( root , - 8 ) ; root = insert ( root , 15 ) ; root = insert ( root , 13 ) ; root = insert ( root , 7 ) ; if ( isTripletPresent ( root ) ) document . write ( " " ) ; else document . write ( " " ) ;

Class/struct names: node
Javascript program:
class Node { constructor ( val ) { this . data = val ; this . left = null ; this . right = null ; this . rightThread = false ; } }

Boolean variables: rightThread
Class/struct names: Node
Javascript program:
class Node { constructor ( val ) { this . data = val ; this . left = null ; this . right = null ; this . isThreaded = false ; } } function createThreaded ( root ) { if ( root == null ) return null ; if ( root . left == null && root . right == null ) return root ; if ( root . left != null ) { var l = createThreaded ( root . left ) ; l . right = root ; l . isThreaded = true ; } if ( root . right == null ) return root ; return createThreaded ( root . right ) ; } function leftMost ( root ) { while ( root != null && root . left != null ) root = root . left ; return root ; } function inOrder ( root ) { if ( root == null ) return ; var cur = leftMost ( root ) ; while ( cur != null ) { document . write ( cur . key + " " ) ; if ( cur . isThreaded ) cur = cur . right ; else cur = leftMost ( cur . right ) ; } } function newNode ( key ) { var temp = new Node ( ) ; temp . left = temp . right = null ; temp . key = key ; return temp ; } var root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 5 ) ; root . right . left = newNode ( 6 ) ; root . right . right = newNode ( 7 ) ; createThreaded ( root ) ; document . write ( " " + " " ) ; inOrder ( root ) ;

Boolean variables: isThreaded
Class/struct names: Node
Javascript program:
class Node { constructor ( key ) { this . key = key ; this . left = this . right = this . parent = null ; } } var root = null ; function insert ( node , key ) { if ( node == null ) return new Node ( key ) ; if ( key < node . key ) { node . left = insert ( node . left , key ) ; node . left . parent = node ; } else if ( key > node . key ) { node . right = insert ( node . right , key ) ; node . right . parent = node ; } return node ; } function inorder ( root ) { var leftdone = false ; while ( root != null ) { if ( ! leftdone ) { while ( root . left != null ) { root = root . left ; } } document . write ( root . key + " " ) ; leftdone = true ; if ( root . right != null ) { leftdone = false ; root = root . right ; } else if ( root . parent != null ) { while ( root . parent != null && root == root . parent . right ) root = root . parent ; if ( root . parent == null ) break ; root = root . parent ; } else break ; } } root = insert ( root , 24 ) ; root = insert ( root , 27 ) ; root = insert ( root , 29 ) ; root = insert ( root , 34 ) ; root = insert ( root , 14 ) ; root = insert ( root , 4 ) ; root = insert ( root , 10 ) ; root = insert ( root , 22 ) ; root = insert ( root , 13 ) ; root = insert ( root , 3 ) ; root = insert ( root , 2 ) ; root = insert ( root , 6 ) ; document . write ( " " ) ; inorder ( root ) ;

Boolean variables: leftdone
Class/struct names: Node
Javascript program:
function printSorted ( arr , start , end ) { if ( start > end ) return ; printSorted ( arr , start * 2 + 1 , end ) ; document . write ( arr [ start ] + " " ) ; printSorted ( arr , start * 2 + 2 , end ) ; } var arr = [ 4 , 2 , 5 , 1 , 3 ] ; printSorted ( arr , 0 , arr . length - 1 ) ;

Index/key variables: start
Javascript program:
class Node { constructor ( x ) { this . data = x ; this . left = null ; this . right = null ; } } let root ; function Ceil ( node , input ) { if ( node == null ) { return - 1 ; } if ( node . data == input ) { return node . data ; } if ( node . data < input ) { return Ceil ( node . right , input ) ; } let ceil = Ceil ( node . left , input ) ; return ( ceil >= input ) ? ceil : node . data ; } root = new Node ( 8 ) root . left = new Node ( 4 ) root . right = new Node ( 12 ) root . left . left = new Node ( 2 ) root . left . right = new Node ( 6 ) root . right . left = new Node ( 10 ) root . right . right = new Node ( 14 ) for ( let i = 0 ; i < 16 ; i ++ ) { document . write ( i + " " + Ceil ( root , i ) + " " ) ; }

Accumulator variables: i
Iterator variables: i
Class/struct names: Node
Javascript program:
class node { constructor ( ) { this . key = 0 ; this . count = 0 ; this . left = null ; this . right = null ; } } function newNode ( item ) { var temp = new node ( ) ; temp . key = item ; temp . left = temp . right = null ; temp . count = 1 ; return temp ; } function inorder ( root ) { if ( root != null ) { inorder ( root . left ) ; document . write ( root . key + " " + root . count + " " ) ; inorder ( root . right ) ; } } function insert ( node , key ) { if ( node == null ) return newNode ( key ) ; if ( key == node . key ) { ( node . count ) ++ ; return node ; } if ( key < node . key ) node . left = insert ( node . left , key ) ; else node . right = insert ( node . right , key ) ; return node ; } function minValueNode ( node ) { var current = node ; while ( current . left != null ) current = current . left ; return current ; } function deleteNode ( root , key ) { if ( root == null ) return root ; if ( key < root . key ) root . left = deleteNode ( root . left , key ) ; else if ( key > root . key ) root . right = deleteNode ( root . right , key ) ; else { if ( root . count > 1 ) { ( root . count ) -- ; return root ; } if ( root . left == null ) { var temp = root . right ; root = null ; return temp ; } else if ( root . right == null ) { var temp = root . left ; root = null ; return temp ; } var temp = minValueNode ( root . right ) ; root . key = temp . key ; root . right = deleteNode ( root . right , temp . key ) ; } return root ; } var root = null ; root = insert ( root , 12 ) ; root = insert ( root , 10 ) ; root = insert ( root , 20 ) ; root = insert ( root , 9 ) ; root = insert ( root , 11 ) ; root = insert ( root , 10 ) ; root = insert ( root , 12 ) ; root = insert ( root , 12 ) ; document . write ( " " + " " + " " ) ; inorder ( root ) ; document . write ( " " ) ; root = deleteNode ( root , 20 ) ; document . write ( " " + " " ) ; inorder ( root ) ; document . write ( " " ) ; root = deleteNode ( root , 12 ) ; document . write ( " " + " " ) ; inorder ( root ) ; document . write ( " " ) ; root = deleteNode ( root , 9 ) ; document . write ( " " + " " ) ; inorder ( root ) ;

Class/struct names: node
Javascript program:
class node { constructor ( ) { this . key = 0 ; this . left = null ; this . right = null ; } } var root = null ; function newNode ( item ) { var temp = new node ( ) ; temp . key = item ; temp . left = null ; temp . right = null ; return temp ; } function inorder ( root ) { if ( root != null ) { inorder ( root . left ) ; document . write ( root . key + " " ) ; inorder ( root . right ) ; } } function insert ( node , key ) { if ( node == null ) return newNode ( key ) ; if ( key < node . key ) node . left = insert ( node . left , key ) ; else node . right = insert ( node . right , key ) ; return node ; } function minValueNode ( Node ) { var current = Node ; while ( current . left != null ) current = current . left ; return current ; } function deleteNode ( root , key ) { if ( root == null ) return root ; if ( key < root . key ) root . left = deleteNode ( root . left , key ) ; else if ( key > root . key ) root . right = deleteNode ( root . right , key ) ; else { if ( root . left == null ) { temp = root . right ; return temp ; } else if ( root . right == null ) { temp = root . left ; return temp ; } var temp = minValueNode ( root . right ) ; root . key = temp . key ; root . right = deleteNode ( root . right , temp . key ) ; } return root ; } function changeKey ( root , oldVal , newVal ) { root = deleteNode ( root , oldVal ) ; root = insert ( root , newVal ) ; return root ; } root = insert ( root , 50 ) ; root = insert ( root , 30 ) ; root = insert ( root , 20 ) ; root = insert ( root , 40 ) ; root = insert ( root , 70 ) ; root = insert ( root , 60 ) ; root = insert ( root , 80 ) ; document . write ( " " ) ; inorder ( root ) ; root = changeKey ( root , 40 , 10 ) ; document . write ( " " ) ; inorder ( root ) ;

Class/struct names: node