dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int search ( int [ ] arr , int x , int n ) { for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] == x ) return i ; return - 1 ; } static void printPostOrder ( int [ ] in1 , int [ ] pre , int n ) { int root = search ( in1 , pre [ 0 ] , n ) ; int [ ] ar ; if ( root != 0 ) { ar = new int [ n - 1 ] ; Array . Copy ( pre , 1 , ar , 0 , n - 1 ) ; printPostOrder ( in1 , ar , root ) ; } if ( root != n - 1 ) { ar = new int [ n - ( root + 1 ) ] ; Array . Copy ( in1 , root + 1 , ar , 0 , n - ( root + 1 ) ) ; int [ ] ar1 = new int [ n - ( root + 1 ) ] ; Array . Copy ( pre , root + 1 , ar1 , 0 , n - ( root + 1 ) ) ; printPostOrder ( ar , ar1 , n - root - 1 ) ; } Console . Write ( pre [ 0 ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] in1 = { 4 , 2 , 5 , 1 , 3 , 6 } ; int [ ] pre = { 1 , 2 , 4 , 5 , 3 , 6 } ; int n = in1 . Length ; Console . WriteLine ( " Postorder ▁ traversal ▁ " ) ; printPostOrder ( in1 , pre , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } class BinaryTree { Node root ; Node findLCA ( int n1 , int n2 ) { return findLCA ( root , n1 , n2 ) ; } Node findLCA ( Node node , int n1 , int n2 ) { if ( node == null ) return null ; if ( node . data == n1 node . data == n2 ) return node ; Node left_lca = findLCA ( node . left , n1 , n2 ) ; Node right_lca = findLCA ( node . right , n1 , n2 ) ; if ( left_lca != null && right_lca != null ) return node ; return ( left_lca != null ) ? left_lca : right_lca ; } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; tree . root . right . left = new Node ( 6 ) ; tree . root . right . right = new Node ( 7 ) ; Console . WriteLine ( " LCA ( 4 , ▁ 5 ) ▁ = ▁ " + tree . findLCA ( 4 , 5 ) . data ) ; Console . WriteLine ( " LCA ( 4 , ▁ 6 ) ▁ = ▁ " + tree . findLCA ( 4 , 6 ) . data ) ; Console . WriteLine ( " LCA ( 3 , ▁ 4 ) ▁ = ▁ " + tree . findLCA ( 3 , 4 ) . data ) ; Console . WriteLine ( " LCA ( 2 , ▁ 4 ) ▁ = ▁ " + tree . findLCA ( 2 , 4 ) . data ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } public class BinaryTree { public Node root ; public static bool v1 = false , v2 = false ; public virtual Node findLCAUtil ( Node node , int n1 , int n2 ) { if ( node == null ) { return null ; } Node temp = null ; if ( node . data == n1 ) { v1 = true ; temp = node ; } if ( node . data == n2 ) { v2 = true ; temp = node ; } Node left_lca = findLCAUtil ( node . left , n1 , n2 ) ; Node right_lca = findLCAUtil ( node . right , n1 , n2 ) ; if ( temp != null ) { return temp ; } if ( left_lca != null && right_lca != null ) { return node ; } return ( left_lca != null ) ? left_lca : right_lca ; } public virtual Node findLCA ( int n1 , int n2 ) { v1 = false ; v2 = false ; Node lca = findLCAUtil ( root , n1 , n2 ) ; if ( v1 && v2 ) { return lca ; } return null ; } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; tree . root . right . left = new Node ( 6 ) ; tree . root . right . right = new Node ( 7 ) ; Node lca = tree . findLCA ( 4 , 5 ) ; if ( lca != null ) { Console . WriteLine ( " LCA ( 4 , ▁ 5 ) ▁ = ▁ " + lca . data ) ; } else { Console . WriteLine ( " Keys ▁ are ▁ not ▁ present " ) ; } lca = tree . findLCA ( 4 , 10 ) ; if ( lca != null ) { Console . WriteLine ( " LCA ( 4 , ▁ 10 ) ▁ = ▁ " + lca . data ) ; } else { Console . WriteLine ( " Keys ▁ are ▁ not ▁ present " ) ; } } }

Boolean variables: v1, v2
Class/struct names: BinaryTree, Node
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; public class Node { public int key ; public Node left , right , parent ; public Node ( int key ) { this . key = key ; left = right = parent = null ; } } class BinaryTree { Node root , n1 , n2 , lca ; Node insert ( Node node , int 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 ; } Node LCA ( Node n1 , Node n2 ) { Dictionary < Node , Boolean > ancestors = new Dictionary < Node , Boolean > ( ) ; while ( n1 != null ) { ancestors . Add ( n1 , true ) ; n1 = n1 . parent ; } while ( n2 != null ) { if ( ancestors . ContainsKey ( n2 ) ) return n2 ; n2 = n2 . parent ; } return null ; } public static void Main ( String [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = tree . insert ( tree . root , 20 ) ; tree . root = tree . insert ( tree . root , 8 ) ; tree . root = tree . insert ( tree . root , 22 ) ; tree . root = tree . insert ( tree . root , 4 ) ; tree . root = tree . insert ( tree . root , 12 ) ; tree . root = tree . insert ( tree . root , 10 ) ; tree . root = tree . insert ( tree . root , 14 ) ; tree . n1 = tree . root . left . right . left ; tree . n2 = tree . root . left ; tree . lca = tree . LCA ( tree . n1 , tree . n2 ) ; Console . WriteLine ( " LCA ▁ of ▁ " + tree . n1 . key + " ▁ and ▁ " + tree . n2 . key + " ▁ is ▁ " + tree . lca . key ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; public class Node { public int key ; public Node left , right , parent ; public Node ( int key ) { this . key = key ; left = right = parent = null ; } } class GFG { public Node root , n1 , n2 , lca ; public virtual Node insert ( Node node , int 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 ; } public virtual int depth ( Node node ) { int d = - 1 ; while ( node != null ) { ++ d ; node = node . parent ; } return d ; } public virtual Node LCA ( Node n1 , Node n2 ) { int d1 = depth ( n1 ) , d2 = depth ( n2 ) ; int diff = d1 - d2 ; if ( diff < 0 ) { Node temp = n1 ; n1 = n2 ; n2 = temp ; diff = - diff ; } while ( diff -- != 0 ) { n1 = n1 . parent ; } while ( n1 != null && n2 != null ) { if ( n1 == n2 ) { return n1 ; } n1 = n1 . parent ; n2 = n2 . parent ; } return null ; } public static void Main ( string [ ] args ) { GFG tree = new GFG ( ) ; tree . root = tree . insert ( tree . root , 20 ) ; tree . root = tree . insert ( tree . root , 8 ) ; tree . root = tree . insert ( tree . root , 22 ) ; tree . root = tree . insert ( tree . root , 4 ) ; tree . root = tree . insert ( tree . root , 12 ) ; tree . root = tree . insert ( tree . root , 10 ) ; tree . root = tree . insert ( tree . root , 14 ) ; tree . n1 = tree . root . left . right . left ; tree . n2 = tree . root . right ; tree . lca = tree . LCA ( tree . n1 , tree . n2 ) ; Console . WriteLine ( " LCA ▁ of ▁ " + tree . n1 . key + " ▁ and ▁ " + tree . n2 . key + " ▁ is ▁ " + tree . lca . key ) ; } }

Accumulator variables: diff
Class/struct names: GFG, Node
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = null ; right = null ; } } public class BinaryTree { public static Node root ; public static Node findLCA ( Node root , int n1 , int n2 ) { if ( root == null ) { return null ; } if ( root . data == n1 root . data == n2 ) { return root ; } Node left_lca = findLCA ( root . left , n1 , n2 ) ; Node right_lca = findLCA ( root . right , n1 , n2 ) ; if ( left_lca != null && right_lca != null ) { return root ; } return ( left_lca != null ) ? left_lca : right_lca ; } public static bool printAncestors ( Node root , int target ) { if ( root == null ) { return false ; } if ( root . data == target ) { Console . Write ( root . data + " ▁ " ) ; return true ; } if ( printAncestors ( root . left , target ) || printAncestors ( root . right , target ) ) { Console . Write ( root . data + " ▁ " ) ; return true ; } return false ; } public static bool findCommonNodes ( Node root , int first , int second ) { Node LCA = findLCA ( root , first , second ) ; if ( LCA == null ) { return false ; } printAncestors ( root , LCA . data ) ; return true ; } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; BinaryTree . root = new Node ( 1 ) ; BinaryTree . root . left = new Node ( 2 ) ; BinaryTree . root . right = new Node ( 3 ) ; BinaryTree . root . left . left = new Node ( 4 ) ; BinaryTree . root . left . right = new Node ( 5 ) ; BinaryTree . root . right . left = new Node ( 6 ) ; BinaryTree . root . right . right = new Node ( 7 ) ; BinaryTree . root . left . left . left = new Node ( 8 ) ; BinaryTree . root . right . left . left = new Node ( 9 ) ; BinaryTree . root . right . left . right = new Node ( 10 ) ; if ( findCommonNodes ( root , 9 , 7 ) == false ) { Console . WriteLine ( " No ▁ Common ▁ nodes " ) ; } } }

Class/struct names: BinaryTree, Node
C# program:
using System ; class GFG { public static int preIndex = 0 ; public virtual void printPost ( int [ ] arr , int [ ] pre , int inStrt , int inEnd ) { if ( inStrt > inEnd ) { return ; } int inIndex = search ( arr , inStrt , inEnd , pre [ preIndex ++ ] ) ; printPost ( arr , pre , inStrt , inIndex - 1 ) ; printPost ( arr , pre , inIndex + 1 , inEnd ) ; Console . Write ( arr [ inIndex ] + " ▁ " ) ; } public virtual int search ( int [ ] arr , int startIn , int endIn , int data ) { int i = 0 ; for ( i = startIn ; i < endIn ; i ++ ) { if ( arr [ i ] == data ) { return i ; } } return i ; } public static void Main ( string [ ] ars ) { int [ ] arr = new int [ ] { 4 , 2 , 5 , 1 , 3 , 6 } ; int [ ] pre = new int [ ] { 1 , 2 , 4 , 5 , 3 , 6 } ; int len = arr . Length ; GFG tree = new GFG ( ) ; tree . printPost ( arr , pre , 0 , len - 1 ) ; } }

Index/key variables: i, inIndex
Accumulator variables: i, preIndex
Iterator variables: i
Class/struct names: GFG
C# program:
class Node { int key ; Node left , right ; public Node ( int item ) { key = item ; left = right = null ; } }

Class/struct names: Node
C# program:
using System ; public class Node { public int key ; public Node left , right ; public Node ( int key ) { this . key = key ; left = right = null ; } } public class Res { public int r = int . MinValue ; } public class BinaryTree { public Node root ; public virtual int maxDiffUtil ( Node t , Res res ) { if ( t == null ) { return int . MaxValue ; } if ( t . left == null && t . right == null ) { return t . key ; } int val = Math . Min ( maxDiffUtil ( t . left , res ) , maxDiffUtil ( t . right , res ) ) ; res . r = Math . Max ( res . r , t . key - val ) ; return Math . Min ( val , t . key ) ; } public virtual int maxDiff ( Node root ) { Res res = new Res ( ) ; maxDiffUtil ( root , res ) ; return res . r ; } public virtual void inorder ( Node root ) { if ( root != null ) { inorder ( root . left ) ; Console . Write ( root . key + " " ) ; inorder ( root . right ) ; } } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 8 ) ; tree . root . left = new Node ( 3 ) ; tree . root . left . left = new Node ( 1 ) ; tree . root . left . right = new Node ( 6 ) ; tree . root . left . right . left = new Node ( 4 ) ; tree . root . left . right . right = new Node ( 7 ) ; tree . root . right = new Node ( 10 ) ; tree . root . right . right = new Node ( 14 ) ; tree . root . right . right . left = new Node ( 13 ) ; Console . WriteLine ( " Maximum ▁ difference ▁ between ▁ a ▁ node ▁ and " + " ▁ its ▁ ancestor ▁ is ▁ : ▁ " + tree . maxDiff ( tree . root ) ) ; } }

Class/struct names: BinaryTree, Node, Res
C# program:
using System ; using System . Collections . Generic ; public class PrintCommonPath { static Boolean v1 = false , v2 = false ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } static Node findLCAUtil ( Node node , int n1 , int n2 ) { if ( node == null ) return null ; Node temp = null ; if ( node . data == n1 ) { v1 = true ; temp = node ; } if ( node . data == n2 ) { v2 = true ; temp = node ; } Node left_lca = findLCAUtil ( node . left , n1 , n2 ) ; Node right_lca = findLCAUtil ( node . right , n1 , n2 ) ; if ( temp != null ) return temp ; if ( left_lca != null && right_lca != null ) return node ; return ( left_lca != null ) ? left_lca : right_lca ; } static Boolean find ( Node root , int k ) { if ( root == null ) return false ; if ( root . data == k || find ( root . left , k ) || find ( root . right , k ) ) return true ; return false ; } static Node findLCA ( Node root , int n1 , int n2 ) { Node lca = findLCAUtil ( root , n1 , n2 ) ; if ( v1 && v2 || v1 && find ( lca , n2 ) || v2 && find ( lca , n1 ) ) return lca ; return null ; } static Boolean hasPath ( Node root , List < int > arr , int x ) { if ( root == null ) return false ; arr . Add ( root . data ) ; if ( root . data == x ) return true ; if ( hasPath ( root . left , arr , x ) || hasPath ( root . right , arr , x ) ) return true ; arr . Remove ( arr . Count - 1 ) ; return false ; } static void printCommonPath ( Node root , int n1 , int n2 ) { List < int > arr = new List < int > ( ) ; Node lca = findLCA ( root , n1 , n2 ) ; if ( lca != null ) { if ( hasPath ( root , arr , lca . data ) ) { for ( int i = 0 ; i < arr . Count - 1 ; i ++ ) Console . Write ( arr [ i ] + " - > " ) ; Console . Write ( arr [ arr . Count - 1 ] ) ; } } else Console . Write ( " No ▁ Common ▁ Path " ) ; } public static void Main ( String [ ] args ) { Node 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 . left = new Node ( 6 ) ; root . right . right = new Node ( 7 ) ; root . left . right . left = new Node ( 8 ) ; root . right . left . right = new Node ( 9 ) ; int n1 = 4 , n2 = 8 ; printCommonPath ( root , n1 , n2 ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: v1, v2
Class/struct names: Node, PrintCommonPath
C# program:
using System ; using System . Collections ; class GFG { static void dfs ( ArrayList [ ] g , int u , int parent , int [ ] timeIn , int [ ] timeOut , ref int cnt ) { timeIn [ u ] = cnt ++ ; for ( int i = 0 ; i < g [ u ] . Count ; i ++ ) { int v = ( int ) g [ u ] [ i ] ; if ( v != parent ) dfs ( g , v , u , timeIn , timeOut , ref cnt ) ; } timeOut [ u ] = cnt ++ ; } static void preProcess ( int [ , ] edges , int V , int [ ] timeIn , int [ ] timeOut ) { ArrayList [ ] g = new ArrayList [ V ] ; for ( int i = 0 ; i < V ; i ++ ) { g [ i ] = new ArrayList ( ) ; } for ( int i = 0 ; i < V - 1 ; i ++ ) { int u = edges [ i , 0 ] ; int v = edges [ i , 1 ] ; g [ u ] . Add ( v ) ; g [ v ] . Add ( u ) ; } int cnt = 0 ; dfs ( g , 0 , - 1 , timeIn , timeOut , ref cnt ) ; } static string isAncestor ( int u , int v , int [ ] timeIn , int [ ] timeOut ) { bool b = ( timeIn [ u ] <= timeIn [ v ] && timeOut [ v ] <= timeOut [ u ] ) ; return ( b ? " yes " : " no " ) ; } static void Main ( ) { int [ , ] edges = { { 0 , 1 } , { 0 , 2 } , { 1 , 3 } , { 1 , 4 } , { 2 , 5 } , { 4 , 6 } , { 5 , 7 } } ; int E = edges . GetLength ( 0 ) ; int V = E + 1 ; int [ ] timeIn = new int [ V ] ; int [ ] timeOut = new int [ V ] ; preProcess ( edges , V , timeIn , timeOut ) ; int u = 1 ; int v = 6 ; Console . Write ( isAncestor ( u , v , timeIn , timeOut ) + " STRNEWLINE " ) ; u = 1 ; v = 7 ; Console . Write ( isAncestor ( u , v , timeIn , timeOut ) + " STRNEWLINE " ) ; } }

Index/key variables: V, i, u, v
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class PrintPath { public class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; left = right = null ; } } public static Boolean hasPath ( Node root , List < int > arr , int x ) { if ( root == null ) return false ; arr . Add ( root . data ) ; if ( root . data == x ) return true ; if ( hasPath ( root . left , arr , x ) || hasPath ( root . right , arr , x ) ) return true ; arr . RemoveAt ( arr . Count - 1 ) ; return false ; } public static void printPath ( Node root , int x ) { List < int > arr = new List < int > ( ) ; if ( hasPath ( root , arr , x ) ) { for ( int i = 0 ; i < arr . Count - 1 ; i ++ ) Console . Write ( arr [ i ] + " - > " ) ; Console . Write ( arr [ arr . Count - 1 ] ) ; } else Console . Write ( " No ▁ Path " ) ; } public static void Main ( String [ ] args ) { Node 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 . left = new Node ( 6 ) ; root . right . right = new Node ( 7 ) ; int x = 5 ; printPath ( root , x ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: Node, PrintPath
C# program:
using System ; public class Node { public int data ; public Node left , right , nextRight ; public Node ( int item ) { data = item ; left = right = nextRight = null ; } } public class BinaryTree { public Node root ; public virtual bool printAncestors ( Node node , int target ) { if ( node == null ) { return false ; } if ( node . data == target ) { return true ; } if ( printAncestors ( node . left , target ) || printAncestors ( node . right , target ) ) { Console . Write ( node . data + " ▁ " ) ; return true ; } return false ; } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; tree . root . left . left . left = new Node ( 7 ) ; tree . printAncestors ( tree . root , 7 ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; class GFG { public class Node { public int data ; public Node left , right ; } ; static Node temp = null ; static int k ; static Node kthAncestorDFS ( Node root , int node ) { if ( root == null ) return null ; if ( root . data == node || ( temp = kthAncestorDFS ( root . left , node ) ) != null || ( temp = kthAncestorDFS ( root . right , node ) ) != null ) { if ( k > 0 ) k -- ; else if ( k == 0 ) { Console . Write ( " Kth ▁ ancestor ▁ is : ▁ " + root . data ) ; return null ; } return root ; } return null ; } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = temp . right = null ; return temp ; } public static void Main ( String [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 5 ) ; k = 2 ; int node = 5 ; Node parent = kthAncestorDFS ( root , node ) ; if ( parent != null ) Console . WriteLine ( " - 1" ) ; } }

Accumulator variables: k
Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { public class Node { public int key ; public Node left , right ; } ; static Node newNode ( int key ) { Node temp = new Node ( ) ; temp . key = key ; temp . left = temp . right = null ; return ( temp ) ; } static List < Boolean > struc ; static List < int > data ; static Node root ; static void EncodeSuccinct ( Node root ) { if ( root == null ) { struc . Add ( false ) ; return ; } struc . Add ( true ) ; data . Add ( root . key ) ; EncodeSuccinct ( root . left ) ; EncodeSuccinct ( root . right ) ; } static Node DecodeSuccinct ( ) { if ( struc . Count <= 0 ) return null ; bool b = struc [ 0 ] ; struc . RemoveAt ( 0 ) ; if ( b == true ) { int key = data [ 0 ] ; data . Remove ( 0 ) ; Node root = newNode ( key ) ; root . left = DecodeSuccinct ( ) ; root . right = DecodeSuccinct ( ) ; return root ; } return null ; } static void preorder ( Node root ) { if ( root != null ) { Console . Write ( " key : ▁ " + root . key ) ; if ( root . left != null ) Console . Write ( " ▁ left ▁ child : ▁ " + root . left . key ) ; if ( root . right != null ) Console . Write ( " ▁ right ▁ child : ▁ " + root . right . key ) ; Console . WriteLine ( ) ; preorder ( root . left ) ; preorder ( root . right ) ; } } public static void Main ( String [ ] args ) { Node root = newNode ( 10 ) ; root . left = newNode ( 20 ) ; root . right = newNode ( 30 ) ; root . left . left = newNode ( 40 ) ; root . left . right = newNode ( 50 ) ; root . right . right = newNode ( 70 ) ; Console . Write ( " Given ▁ Tree STRNEWLINE " ) ; preorder ( root ) ; struc = new List < Boolean > ( ) ; data = new List < int > ( ) ; EncodeSuccinct ( root ) ; Console . Write ( " STRNEWLINE Encoded ▁ Tree STRNEWLINE " ) ; Console . Write ( " Structure ▁ List STRNEWLINE " ) ; foreach ( bool si in struc ) { if ( si == true ) Console . Write ( 1 + " ▁ " ) ; else Console . Write ( 0 + " ▁ " ) ; } Console . Write ( " STRNEWLINE Data ▁ List STRNEWLINE " ) ; foreach ( int di in data ) Console . Write ( di + " ▁ " ) ; Node newroot = DecodeSuccinct ( ) ; Console . Write ( " STRNEWLINE STRNEWLINE Preorder ▁ traversal " + " of ▁ decoded ▁ tree STRNEWLINE " ) ; preorder ( newroot ) ; } }

Iterator variables: di, si
Class/struct names: GFG, Node
C# program:
using System ; class GfG { static void update ( int [ ] arr , int l , int r , int val ) { arr [ l ] += val ; if ( r + 1 < arr . Length ) arr [ r + 1 ] -= val ; } static int getElement ( int [ ] arr , int i ) { int res = 0 ; for ( int j = 0 ; j <= i ; j ++ ) res += arr [ j ] ; return res ; } public static void Main ( String [ ] args ) { int [ ] arr = { 0 , 0 , 0 , 0 , 0 } ; int n = arr . Length ; int l = 2 , r = 4 , val = 2 ; update ( arr , l , r , val ) ; int index = 4 ; Console . WriteLine ( " Element ▁ at ▁ index ▁ " + index + " ▁ is ▁ " + getElement ( arr , index ) ) ; l = 0 ; r = 3 ; val = 4 ; update ( arr , l , r , val ) ; index = 3 ; Console . WriteLine ( " Element ▁ at ▁ index ▁ " + index + " ▁ is ▁ " + getElement ( arr , index ) ) ; } }

Index/key variables: j, l
Accumulator variables: j, res
Iterator variables: j
Class/struct names: GfG
C# program:
using System ; public class GFG { public const int MAX = 1000 ; public static int [ ] BITree = new int [ MAX ] ; public static void updateBIT ( int n , int index , int val ) { index = index + 1 ; while ( index <= n ) { BITree [ index ] += val ; index += index & ( - index ) ; } } public static void constructBITree ( int [ ] arr , int n ) { for ( int i = 1 ; i <= n ; i ++ ) { BITree [ i ] = 0 ; } for ( int i = 0 ; i < n ; i ++ ) { updateBIT ( n , i , arr [ i ] ) ; } } public static int getSum ( int index ) { int sum = 0 ; index = index + 1 ; while ( index > 0 ) { sum += BITree [ index ] ; index -= index & ( - index ) ; } return sum ; } public static void update ( int l , int r , int n , int val ) { updateBIT ( n , l , val ) ; updateBIT ( n , r + 1 , - val ) ; } public static void Main ( string [ ] args ) { int [ ] arr = new int [ ] { 0 , 0 , 0 , 0 , 0 } ; int n = arr . Length ; constructBITree ( arr , n ) ; int l = 2 , r = 4 , val = 2 ; update ( l , r , n , val ) ; int index = 4 ; Console . WriteLine ( " Element ▁ at ▁ index ▁ " + index + " ▁ is ▁ " + getSum ( index ) ) ; l = 0 ; r = 3 ; val = 4 ; update ( l , r , n , val ) ; index = 3 ; Console . WriteLine ( " Element ▁ at ▁ index ▁ " + index + " ▁ is ▁ " + getSum ( index ) ) ; } }

Index/key variables: MAX, i, index
Accumulator variables: i, index, sum
Iterator variables: i
Class/struct names: GFG