codeparrot/xlcost-text-to-code huggingface dataset:
Convert given string to another by minimum replacements of subsequences by its smallest character | C # program for the above approach ; Function to return the minimum number of operation ; Storing data ; Initialize both arrays ; Stores the index of character ; Filling str1array , convChar and hashmap convertMap . ; Not possible to convert ; Calculate result Initializing return values ; Iterating the character from the end ; Increment the number of operations ; Not possible to convert ; To check whether the final element has been added in set S or not . ; Check if v1 [ j ] is present in hashmap or not ; Already converted then then continue ; Not possible to convert ; Print the result ; Driver code ; Given strings ; Function call
using System ; using System . Collections . Generic ; class GFG { static void transformString ( string str1 , string str2 ) { int N = str1 . Length ; List < List < int > > convChar = new List < List < int > > ( ) ; List < List < int > > str1array = new List < List < int > > ( ) ; for ( int i = 0 ; i < 26 ; i ++ ) { convChar . Add ( new List < int > ( ) ) ; str1array . Add ( new List < int > ( ) ) ; } Dictionary < int , char > convertMap = new Dictionary < int , char > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { str1array [ str1 [ i ] - ' a ' ] . Add ( i ) ; } for ( int i = 0 ; i < N ; i ++ ) { if ( str1 [ i ] < str2 [ i ] ) { Console . WriteLine ( - 1 ) ; return ; } else if ( str1 [ i ] == str2 [ i ] ) continue ; else { convChar [ str2 [ i ] - ' a ' ] . Add ( i ) ; convertMap [ i ] = str2 [ i ] ; } } int ret = 0 ; List < List < int > > retv = new List < List < int > > ( ) ; for ( int i = 25 ; i >= 0 ; i -- ) { List < int > v = convChar [ i ] ; if ( v . Count == 0 ) continue ; ret ++ ; List < int > v1 = str1array [ i ] ; if ( v1 . Count == 0 ) { Console . WriteLine ( - 1 ) ; return ; } bool isScompleted = false ; for ( int j = 0 ; j < v1 . Count ; j ++ ) { if ( convertMap . ContainsKey ( v1 [ j ] ) ) { char a = convertMap [ v1 [ j ] ] ; if ( a > i + ' a ' ) continue ; else { v . Add ( v1 [ j ] ) ; isScompleted = true ; retv . Add ( v ) ; break ; } } else { v . Add ( v1 [ j ] ) ; isScompleted = true ; retv . Add ( v ) ; break ; } } if ( ! isScompleted ) { Console . WriteLine ( - 1 ) ; return ; } } Console . WriteLine ( ret ) ; } static void Main ( ) { string A = " abcab " ; string B = " aabab " ; transformString ( A , B ) ; } }
Find largest subtree having identical left and right subtrees | C # program to find the largest subtree having identical left and right subtree ; A binary tree node has data , pointer to left child and a pointer to right child ; Helper function that allocates a new node with the given data and null left and right pointers . ; Sets maxSize to size of largest subtree with identical left and right . maxSize is set with size of the maximum sized subtree . It returns size of subtree rooted with current node . This size is used to keep track of maximum size . ; String to store structure of left and right subtrees ; Traverse left subtree and finds its size ; Traverse right subtree and finds its size ; If left and right subtrees are similar update maximum subtree if needed ( Note that left subtree may have a bigger value than right and vice versa ) ; Append left subtree data ; Append current node data ; Append right subtree data ; Function to find the largest subtree having identical left and right subtree ; Driver code ; Let us construct the following Tree 50 / \ 10 60 / \ / \ 5 20 70 70 / \ / \ 65 80 65 80
using System ; class GFG { public class Node { public int data ; public Node left , right ; } ; static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = node . right = null ; return ( node ) ; } static int maxSize ; static Node maxNode ; public class pair { public int first ; public string second ; public pair ( int a , string b ) { first = a ; second = b ; } } static pair largestSubtreeUtil ( Node root , string str ) { if ( root == null ) return new pair ( 0 , str ) ; string left = " " , right = " " ; pair ls1 = largestSubtreeUtil ( root . left , left ) ; left = ls1 . second ; int ls = ls1 . first ; pair rs1 = largestSubtreeUtil ( root . right , right ) ; right = rs1 . second ; int rs = rs1 . first ; int size = ls + rs + 1 ; if ( left . Equals ( right ) ) { if ( size > maxSize ) { maxSize = size ; maxNode = root ; } } str += " | " + left + " | " ; str += " | " + root . data + " | " ; str += " | " + right + " | " ; return new pair ( size , str ) ; } static int largestSubtree ( Node node ) { maxSize = 0 ; largestSubtreeUtil ( node , " " ) ; return maxSize ; } public static void Main ( string [ ] args ) { Node root = newNode ( 50 ) ; root . left = newNode ( 10 ) ; root . right = newNode ( 60 ) ; root . left . left = newNode ( 5 ) ; root . left . right = newNode ( 20 ) ; root . right . left = newNode ( 70 ) ; root . right . left . left = newNode ( 65 ) ; root . right . left . right = newNode ( 80 ) ; root . right . right = newNode ( 70 ) ; root . right . right . left = newNode ( 65 ) ; root . right . right . right = newNode ( 80 ) ; maxNode = null ; maxSize = largestSubtree ( root ) ; Console . Write ( " Largest ▁ Subtree ▁ is ▁ rooted ▁ at ▁ node ▁ " + maxNode . data + " and size is " } }
Check if a string is a scrambled form of another string | C # program to check if a given string is a scrambled form of another string ; Strings of non - equal length cant ' be scramble strings ; Empty strings are scramble strings ; Equal strings are scramble strings ; Converting string to character array ; Checking condition for Anagram ; Check if S2 [ 0. . . i ] is a scrambled string of S1 [ 0. . . i ] and if S2 [ i + 1. . . n ] is a scrambled string of S1 [ i + 1. . . n ] ; Check if S2 [ 0. . . i ] is a scrambled string of S1 [ n - i ... n ] and S2 [ i + 1. . . n ] is a scramble string of S1 [ 0. . . n - i - 1 ] ; If none of the above conditions are satisfied ; Driver code
using System ; using System . Collections . Generic ; class GFG { static bool isScramble ( string S1 , string S2 ) { if ( S1 . Length != S2 . Length ) { return false ; } int n = S1 . Length ; if ( n == 0 ) { return true ; } if ( S1 . Equals ( S2 ) ) { return true ; } char [ ] tempArray1 = S1 . ToCharArray ( ) ; char [ ] tempArray2 = S2 . ToCharArray ( ) ; Array . Sort ( tempArray1 ) ; Array . Sort ( tempArray2 ) ; string copy_S1 = new string ( tempArray1 ) ; string copy_S2 = new string ( tempArray2 ) ; if ( ! copy_S1 . Equals ( copy_S2 ) ) { return false ; } for ( int i = 1 ; i < n ; i ++ ) { if ( isScramble ( S1 . Substring ( 0 , i ) , S2 . Substring ( 0 , i ) ) && isScramble ( S1 . Substring ( i , n - i ) , S2 . Substring ( i , n - i ) ) ) { return true ; } if ( isScramble ( S1 . Substring ( 0 , i ) , S2 . Substring ( n - i , i ) ) && isScramble ( S1 . Substring ( i , n - i ) , S2 . Substring ( 0 , n - i ) ) ) { return true ; } } return false ; } static void Main ( ) { string S1 = " coder " ; string S2 = " ocred " ; if ( isScramble ( S1 , S2 ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }
Smallest number possible by swapping adjacent even odd pairs | C # program to find the smallest number possible by swapping adjacent digits of different parity ; Function to return the smallest number possible ; Arrays to store odd and even digits in the order their appearance in the given String ; Insert the odd and even digits ; Pointer to odd digit ; Pointer to even digit ; In case number of even and odd digits are not equal If odd digits are remaining ; If even digits are remaining ; Removal of leading 0 's ; Driver code
using System ; using System . Collections . Generic ; class GFG { static String findAns ( String s ) { int digit ; List < int > odd = new List < int > ( ) ; List < int > even = new List < int > ( ) ; foreach ( char c in s . ToCharArray ( ) ) { digit = c - '0' ; if ( digit % 2 == 1 ) odd . Add ( digit ) ; else even . Add ( digit ) ; } int i = 0 ; int j = 0 ; String ans = " " ; while ( i < odd . Count && j < even . Count ) { if ( odd [ i ] < even [ j ] ) ans += ( char ) ( odd [ i ++ ] + '0' ) ; else ans += ( char ) ( even [ j ++ ] + '0' ) ; } while ( i < odd . Count ) ans += ( char ) ( odd [ i ++ ] + '0' ) ; while ( j < even . Count ) ans += ( char ) ( even [ j ++ ] + '0' ) ; while ( ans [ 0 ] == '0' ) { ans = ans . Substring ( 1 ) ; } return ans ; } public static void Main ( String [ ] args ) { String s = "894687536" ; Console . Write ( findAns ( s ) ) ; } }
Program to Convert BCD number into Decimal number | C # code to convert BCD to its decimal number ( base 10 ) . Including Header Files ; Function to convert BCD to Decimal ; Iterating through the bits backwards ; Forming the equivalent digit ( 0 to 9 ) from the group of 4. ; Reinitialize all variables and compute the number . ; Update the answer ; Reverse the number formed . ; Driver code ; Function Call
using System ; class GFG { public static int bcdToDecimal ( String s ) { int len = s . Length ; int check = 0 , check0 = 0 ; int num = 0 , sum = 0 ; int mul = 1 , rev = 0 ; for ( int i = len - 1 ; i >= 0 ; i -- ) { sum += ( s [ i ] - '0' ) * mul ; mul *= 2 ; check ++ ; if ( check == 4 i == 0 ) { if ( sum == 0 && check0 == 0 ) { num = 1 ; check0 = 1 ; } else { num = num * 10 + sum ; } check = 0 ; sum = 0 ; mul = 1 ; } } while ( num > 0 ) { rev = rev * 10 + ( num % 10 ) ; num /= 10 ; } if ( check0 == 1 ) return rev - 1 ; return rev ; } public static void Main ( String [ ] args ) { String s = "100000101000" ; Console . WriteLine ( bcdToDecimal ( s ) ) ; } }
Find Count of Single Valued Subtrees | C # program to find count of single valued subtrees ; Class containing left and right child of current node and key value ; This function increments count by number of single valued subtrees under root . It returns true if subtree under root is Singly , else false . ; Return false to indicate NULL ; Recursively count in left and right subtrees also ; If any of the subtrees is not singly , then this cannot be singly . ; If left subtree is singly and non - empty , but data doesn 't match ; Same for right subtree ; If none of the above conditions is true , then tree rooted under root is single valued , increment count and return true . ; This function mainly calls countSingleRec ( ) after initializing count as 0 ; Recursive function to count ; Driver program to test above functions ; Let us construct the below tree 5 / \ 4 5 / \ \ 4 4 5
using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } public class Count { public int count = 0 ; } public class BinaryTree { public Node root ; public Count ct = new Count ( ) ; public virtual bool countSingleRec ( Node node , Count c ) { if ( node == null ) { return true ; } bool left = countSingleRec ( node . left , c ) ; bool right = countSingleRec ( node . right , c ) ; if ( left == false right == false ) { return false ; } if ( node . left != null && node . data != node . left . data ) { return false ; } if ( node . right != null && node . data != node . right . data ) { return false ; } c . count ++ ; return true ; } public virtual int countSingle ( ) { return countSingle ( root ) ; } public virtual int countSingle ( Node node ) { countSingleRec ( node , ct ) ; return ct . count ; } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 5 ) ; tree . root . left = new Node ( 4 ) ; tree . root . right = new Node ( 5 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 4 ) ; tree . root . right . right = new Node ( 5 ) ; Console . WriteLine ( " The ▁ count ▁ of ▁ single ▁ valued ▁ sub ▁ trees ▁ is ▁ : ▁ " + tree . countSingle ( ) ) ; } }
Count minimum swap to make string palindrome | C # program to Count minimum swap to make string palindrome ; Function to Count minimum swap ; Length of string ; Counter to count minimum swap ; A loop which run in half string from starting ; Left pointer ; Right pointer ; A loop which run from right pointer to left pointer ; if both char same then break the loop if not same then we have to move right pointer to one step left ; it denotes both pointer at same position and we don 't  have sufficient char to make  palindrome string ; Driver Code ; Function calling
using System ; class GFG { static int countSwap ( String str ) { char [ ] s = str . ToCharArray ( ) ; int n = str . Length ; int count = 0 ; for ( int i = 0 ; i < n / 2 ; i ++ ) { int left = i ; int right = n - left - 1 ; while ( left < right ) { if ( s [ left ] == s [ right ] ) { break ; } else { right -- ; } } if ( left == right ) { return - 1 ; } else { for ( int j = right ; j < n - left - 1 ; j ++ ) { char t = s [ j ] ; s [ j ] = s [ j + 1 ] ; s [ j + 1 ] = t ; count ++ ; } } } return count ; } public static void Main ( String [ ] args ) { String s = " geeksfgeeks " ; int ans1 = countSwap ( s ) ; char [ ] charArray = s . ToCharArray ( ) ; Array . Reverse ( charArray ) ; s = new string ( charArray ) ; int ans2 = countSwap ( s ) ; if ( ans1 > ans2 ) Console . WriteLine ( ans1 ) ; else Console . WriteLine ( ans2 ) ; } }
Bitwise XOR of a Binary array | C # implementation of the approach ; Function to return the reverse string ; Function to return the bitwise XOR of all the binary strings ; Get max size and reverse each string Since we have to perform XOR operation on bits from right to left Reversing the string will make it easier to perform operation from left to right ; Add 0 s to the end of strings if needed ; Perform XOR operation on each bit ; Reverse the resultant string to get the final string ; Return the final string ; Driver code
using System ; class GFG { static string reverse ( string str ) { string rev = " " ; for ( int i = str . Length - 1 ; i >= 0 ; i -- ) rev = rev + str [ i ] ; return rev ; } static string strBitwiseXOR ( string [ ] arr , int n ) { string result = " " ; int max_len = int . MinValue ; for ( int i = 0 ; i < n ; i ++ ) { max_len = Math . Max ( max_len , ( int ) arr [ i ] . Length ) ; arr [ i ] = reverse ( arr [ i ] ) ; } for ( int i = 0 ; i < n ; i ++ ) { string s = " " ; for ( int j = 0 ; j < max_len - arr [ i ] . Length ; j ++ ) s += '0' ; arr [ i ] = arr [ i ] + s ; } for ( int i = 0 ; i < max_len ; i ++ ) { int pres_bit = 0 ; for ( int j = 0 ; j < n ; j ++ ) pres_bit = pres_bit ^ ( arr [ j ] [ i ] - '0' ) ; result += ( char ) ( pres_bit + '0' ) ; } result = reverse ( result ) ; return result ; } public static void Main ( ) { string [ ] arr = { "1000" , "10001" , "0011" } ; int n = arr . Length ; Console . Write ( strBitwiseXOR ( arr , n ) ) ; } }
Count of sticks required to represent the given string | C # implementation of the above approach ; stick [ ] stores the count of matchsticks required to represent the alphabets ; number [ ] stores the count of matchsticks required to represent the numerals ; Function that return the count of sticks required to represent the given string ; For every char of the given string ; Add the count of sticks required to represent the current character ; Driver code ; Function call to find the count of matchsticks
using System ; class GFG { static int [ ] 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 } ; static int [ ] number = { 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 } ; static int countSticks ( string str ) { int cnt = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { char ch = str [ i ] ; if ( ch >= ' A ' && ch <= ' Z ' ) { cnt += sticks [ ch - ' A ' ] ; } else { cnt += number [ ch - '0' ] ; } } return cnt ; } public static void Main ( ) { string str = " GEEKSFORGEEKS " ; Console . WriteLine ( countSticks ( str ) ) ; } }
CamelCase Pattern Matching |  ; Concatenating all array elements using Aggregate function of LINQ putting semicolon as delimiter after each element ; Map to store the hashing of each words with every uppercase letter found ; temporary Variables ; Traversing through concatenated String ; Identifying if the current Character is CamelCase If so , then adding to map accordingly ; If pattern matches then print the corresponding mapped words ; If delimiter has reached then reseting temporary string also incrementing word position value ; If pattern matches then print the corresponding mapped words ; Driver 's Code ; Array of Words ; Pattern to be found ; Function call to find the words that match to the given pattern
using System ; using System . Collections . Generic ; using System . Linq ; public class GFG { public static void PrintMatchingCamelCase ( String [ ] arr , String pattern ) { String cctdString = arr . Aggregate ( ( i , j ) = > i + ' ; ' + j ) ; Dictionary < String , List < String > > map = new Dictionary < string , List < string > > ( ) ; int charPos = 0 ; int wordPos = 0 ; string strr = string . Empty ; for ( ; charPos < cctdString . Length ; charPos ++ ) { if ( cctdString [ charPos ] >= ' A ' && cctdString [ charPos ] <= ' Z ' ) { strr += cctdString [ charPos ] ; if ( map . ContainsKey ( strr ) ) { List < String > temp = new List < string > ( ) ; temp . AddRange ( map [ strr ] ) ; temp . Add ( arr [ wordPos ] ) ; map [ strr ] = temp ; } else { map . Add ( strr , new List < string > { arr [ wordPos ] } ) ; } } else if ( cctdString [ charPos ] == ' ; ' ) { wordPos ++ ; strr = string . Empty ; } } if ( map . ContainsKey ( pattern ) ) { foreach ( String word in map [ pattern ] ) { Console . WriteLine ( word ) ; } } else { Console . WriteLine ( " No ▁ Match ▁ Found " ) ; } } public static void Main ( String [ ] args ) { String [ ] arr = { " Hi " , " Hello " , " HelloWorld " , " HiTech " , " HiGeek " , " HiTechWorld " , " HiTechCity " , " HiTechLab " } ; String pattern = " HT " ; PrintMatchingCamelCase ( arr , pattern ) ; } }
Find the last remaining Character in the Binary String according to the given conditions | C # implementation of the above approach ; Converting string to array ; Delete counters for each to count the deletes ; Counters to keep track of characters left from each type ; Queue to simulate the process ; Initializing the queue ; Looping till at least 1 digit is left from both the type ; If there is a floating delete for current character we will delete it and move forward otherwise we will increase delete counter for opposite digit ; If 0 are left then answer is 0 else answer is 1 ; Driver Code ; Input String ; Length of String ; Printing answer
using System ; using System . Collections . Generic ; public class GfG { private static String remainingDigit ( String S , int N ) { char [ ] c = S . ToCharArray ( ) ; int [ ] del = { 0 , 0 } ; int [ ] count = { 0 , 0 } ; List < int > q = new List < int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int x = c [ i ] == '1' ? 1 : 0 ; count [ x ] ++ ; q . Add ( x ) ; } while ( count [ 0 ] > 0 && count [ 1 ] > 0 ) { int t = q [ 0 ] ; q . RemoveAt ( 0 ) ; if ( del [ t ] > 0 ) { del [ t ] -- ; count [ t ] -- ; } else { del [ t ^ 1 ] ++ ; q . Add ( t ) ; } } if ( count [ 0 ] > 0 ) return "0" ; return "1" ; } public static void Main ( String [ ] args ) { String S = "1010100100000" ; int N = S . Length ; Console . Write ( remainingDigit ( S , N ) ) ; } }
Count of sub | C # implementation of the approach ; Function to return the count of valid sub - strings ; Variable ans to store all the possible substrings Initialize its value as total number of substrings that can be formed from the given string ; Stores recent index of the characters ; If character is a update a 's index  and the variable ans ; If character is b update b 's index  and the variable ans ; If character is c update c 's index  and the variable ans ; Driver code
using System ; class GFG { static int CountSubstring ( char [ ] str , int n ) { int ans = ( n * ( n + 1 ) ) / 2 ; int a_index = 0 ; int b_index = 0 ; int c_index = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' a ' ) { a_index = i + 1 ; ans -= Math . Min ( b_index , c_index ) ; } else if ( str [ i ] == ' b ' ) { b_index = i + 1 ; ans -= Math . Min ( a_index , c_index ) ; } else { c_index = i + 1 ; ans -= Math . Min ( a_index , b_index ) ; } } return ans ; } public static void Main ( ) { char [ ] str = " babac " . ToCharArray ( ) ; int n = str . Length ; Console . WriteLine ( CountSubstring ( str , n ) ) ; } }
Find the numbers of strings that can be formed after processing Q queries | C # program to implement above approach ; To store the size of string and number of queries ; To store parent and rank of ith place ; To store maximum interval ; Function for initialization ; Function to find parent ; Function to make union ; Power function to calculate a raised to m1 under modulo 10000007 ; Function to take maxmium interval ; Function to find different possible strings ; Make union of all chracters which are meant to be same ; Find number of different sets formed ; Return the required answer ; Driver Code ; Queries
using System ; using System . Collections . Generic ; class GFG { const int N = 2005 ; const int mod = 1000000007 ; static int n ; static int [ ] par = new int [ N ] ; static int [ ] Rank = new int [ N ] ; static Dictionary < int , int > m = new Dictionary < int , int > ( ) ; static void initialize ( ) { for ( int i = 0 ; i <= n ; i ++ ) { par [ i ] = i ; Rank [ i ] = 0 ; } } static int find ( int x ) { if ( par [ x ] != x ) par [ x ] = find ( par [ x ] ) ; return par [ x ] ; } static void Union ( int x , int y ) { int xpar = find ( x ) ; int ypar = find ( y ) ; if ( Rank [ xpar ] < Rank [ ypar ] ) par [ xpar ] = ypar ; else if ( Rank [ xpar ] > Rank [ ypar ] ) par [ ypar ] = xpar ; else { par [ ypar ] = xpar ; Rank [ xpar ] ++ ; } } static long power ( long a , long m1 ) { if ( m1 == 0 ) return 1 ; else if ( m1 == 1 ) return a ; else if ( m1 == 2 ) return ( 1L * a * a ) % mod ; else if ( m1 % 2 == 1 ) return ( 1L * a * power ( power ( a , m1 / 2 ) , 2 ) ) % mod ; else return power ( power ( a , m1 / 2 ) , 2 ) % mod ; } static void query ( int l , int r ) { if ( m . ContainsKey ( l + r ) ) m [ l + r ] = Math . Max ( m [ l + r ] , r ) ; else m [ l + r ] = r ; } static long possiblestrings ( ) { initialize ( ) ; foreach ( KeyValuePair < int , int > i in m ) { int x = i . Key - m [ i . Key ] ; int y = m [ i . Key ] ; while ( x < y ) { Union ( x , y ) ; x ++ ; y -- ; } } int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) if ( par [ i ] == i ) ans ++ ; return power ( 26 , ans ) % mod ; } public static void Main ( string [ ] args ) { n = 4 ; query ( 1 , 3 ) ; query ( 2 , 4 ) ; Console . Write ( possiblestrings ( ) ) ; } }
Iterative Search for a key ' x ' in Binary Tree | Iterative level order traversal based method to search in Binary Tree ; A binary tree node has data , left child and right child ; Constructor that allocates a new node with the given data and null left and right pointers . ; An iterative process to search an element x in a given binary tree ; Base Case ; Create an empty queue for level order traversal ; Enqueue Root and initialize height ; Queue based level order traversal ; See if current node is same as x ; Remove current node and enqueue its children ; Driver code
using System ; using System . Collections . Generic ; class GFG { public class node { public int data ; public node left ; public node right ; public node ( int data ) { this . data = data ; this . left = null ; this . right = null ; } } ; static Boolean iterativeSearch ( node root , int x ) { if ( root == null ) return false ; Queue < node > q = new Queue < node > ( ) ; q . Enqueue ( root ) ; while ( q . Count > 0 ) { node node = q . Peek ( ) ; if ( node . data == x ) return true ; q . Dequeue ( ) ; if ( node . left != null ) q . Enqueue ( node . left ) ; if ( node . right != null ) q . Enqueue ( node . right ) ; } return false ; } public static void Main ( String [ ] ags ) { node root = new node ( 2 ) ; root . left = new node ( 7 ) ; root . right = new node ( 5 ) ; root . left . right = new node ( 6 ) ; root . left . right . left = new node ( 1 ) ; root . left . right . right = new node ( 11 ) ; root . right . right = new node ( 9 ) ; root . right . right . left = new node ( 4 ) ; Console . WriteLine ( ( iterativeSearch ( root , 6 ) ? " Found STRNEWLINE " : " Not ▁ Found " ) ) ; Console . Write ( ( iterativeSearch ( root , 12 ) ? " Found STRNEWLINE " : " Not ▁ Found STRNEWLINE " ) ) ; } }