codeparrot/xlcost-text-to-code huggingface dataset:
Sort the Queue using Recursion | Program to print the given pattern ; Function to push element in last by popping from front until size becomes 0 ; Base condition ; pop front element and push this last in a queue ; Recursive call for pushing element ; Function to push an element in the queue while maintaining the sorted order ; Base condition ; If current element is less than the element at the front ; Call stack with front of queue ; Recursive call for inserting a front element of the queue to the last ; Push front element into last in a queue ; Recursive call for pushing element in a queue ; Function to sort the given queue using recursion ; Return if queue is empty ; Get the front element which will be stored in this variable throughout the recursion stack ; Remove the front element ; Recursive call ; Push the current element into the queue according to the sorting order ; Driver code ; Push elements to the queue ; Sort the queue ; Print the elements of the queue after sorting
using System ; using System . Collections . Generic ; class GFG { static void FrontToLast ( Queue < int > q , int qsize ) { if ( qsize <= 0 ) return ; q . Enqueue ( q . Peek ( ) ) ; q . Dequeue ( ) ; FrontToLast ( q , qsize - 1 ) ; } static void pushInQueue ( Queue < int > q , int temp , int qsize ) { if ( q . Count == 0 qsize == 0 ) { q . Enqueue ( temp ) ; return ; } else if ( temp <= q . Peek ( ) ) { q . Enqueue ( temp ) ; FrontToLast ( q , qsize ) ; } else { q . Enqueue ( q . Peek ( ) ) ; q . Dequeue ( ) ; pushInQueue ( q , temp , qsize - 1 ) ; } } static void sortQueue ( Queue < int > q ) { if ( q . Count == 0 ) return ; int temp = q . Peek ( ) ; q . Dequeue ( ) ; sortQueue ( q ) ; pushInQueue ( q , temp , q . Count ) ; } public static void Main ( String [ ] args ) { Queue < int > qu = new Queue < int > ( ) ; qu . Enqueue ( 10 ) ; qu . Enqueue ( 7 ) ; qu . Enqueue ( 16 ) ; qu . Enqueue ( 9 ) ; qu . Enqueue ( 20 ) ; qu . Enqueue ( 5 ) ; sortQueue ( qu ) ; while ( qu . Count != 0 ) { Console . Write ( qu . Peek ( ) + " ▁ " ) ; qu . Dequeue ( ) ; } } }
Sort the character array based on ASCII % N | C # implementation of the approach ; This function takes last element as pivot , places the pivot element at its correct position in sorted array , and places all smaller ( smaller than pivot ) to left of pivot and all greater elements to right of pivot ; pivot ; Index of smaller element ; If current element is smaller than o equal to pivot Instead of values , ASCII % m values are compared ; Increment index of smaller element ; swap ; The main function that implements QuickSort arr [ ] -- > Array to be sorted , low -- > Starting index , high -- > Ending index ; pi is partitioning index , arr [ p ] is now at right place ; Separately sort elements before partition and after partition ; Function to print the given array ; Driver code ; Sort the given array ; Print the sorted array
using System ; class GFG { static int partition ( char [ ] arr , int low , int high , int mod ) { char pivot = arr [ high ] ; int i = ( low - 1 ) ; char t ; int piv = pivot % mod ; for ( int j = low ; j <= high - 1 ; j ++ ) { int a = arr [ j ] % mod ; if ( a <= piv ) { i ++ ; t = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = t ; } } t = arr [ i + 1 ] ; arr [ i + 1 ] = arr [ high ] ; arr [ high ] = t ; return ( i + 1 ) ; } static void quickSort ( char [ ] arr , int low , int high , int mod ) { if ( low < high ) { int pi = partition ( arr , low , high , mod ) ; quickSort ( arr , low , pi - 1 , mod ) ; quickSort ( arr , pi + 1 , high , mod ) ; } } static void printArray ( char [ ] arr , int size ) { for ( int i = 0 ; i < size ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } public static void Main ( ) { char [ ] arr = { ' g ' , ' e ' , ' e ' , ' k ' , ' s ' } ; int n = arr . Length ; int mod = 8 ; quickSort ( arr , 0 , n - 1 , mod ) ; printArray ( arr , n ) ; } }
Iterative selection sort for linked list | C # implementation of the approach ; Linked List Node ; Utility function to create a new Linked List Node ; Function to sort a linked list using selection sort algorithm by swapping the next pointers ; While b is not the last node ; While d is pointing to a valid node ; If d appears immediately after b ; Case 1 : b is the head of the linked list ; Move d before b ; Swap b and d pointers ; Update the head ; Skip to the next element as it is already in order ; Case 2 : b is not the head of the linked list ; Move d before b ; Swap b and d pointers ; Skip to the next element as it is already in order ; If b and d have some non - zero number of nodes in between them ; Case 3 : b is the head of the linked list ; Swap b . next and d . next ; Swap b and d pointers ; Skip to the next element as it is already in order ; Update the head ; Case 4 : b is not the head of the linked list ; Swap b . next and d . next ; Swap b and d pointers ; Skip to the next element as it is already in order ; Update c and skip to the next element as it is already in order ; Function to print the list ; Driver Code
using System ; class GFG { public class Node { public int data ; public Node next ; } ; static Node newNode ( int val ) { Node temp = new Node ( ) ; temp . data = val ; temp . next = null ; return temp ; } static Node selectionSort ( Node head ) { Node a , b , c , d , r ; a = b = head ; while ( b . next != null ) { c = d = b . next ; while ( d != null ) { if ( b . data > d . data ) { if ( b . next == d ) { if ( b == head ) { b . next = d . next ; d . next = b ; r = b ; b = d ; d = r ; c = d ; head = b ; d = d . next ; } else { b . next = d . next ; d . next = b ; a . next = d ; r = b ; b = d ; d = r ; c = d ; d = d . next ; } } else { if ( b == head ) { r = b . next ; b . next = d . next ; d . next = r ; c . next = b ; r = b ; b = d ; d = r ; c = d ; d = d . next ; head = b ; } else { r = b . next ; b . next = d . next ; d . next = r ; c . next = b ; a . next = d ; r = b ; b = d ; d = r ; c = d ; d = d . next ; } } } else { c = d ; d = d . next ; } } a = b ; b = b . next ; } return head ; } static void printList ( Node head ) { while ( head != null ) { Console . Write ( head . data + " ▁ " ) ; head = head . next ; } } public static void Main ( String [ ] arg ) { Node head = newNode ( 5 ) ; head . next = newNode ( 4 ) ; head . next . next = newNode ( 3 ) ; head = selectionSort ( head ) ; printList ( head ) ; } }
Find original numbers from gcd ( ) every pair | C # implementation for above approach ; Utility function to print the contents of an array ; Function to find the required numbers ; Sort array in decreasing order ; Count frequency of each element ; Size of the resultant array ; Store the highest element in the resultant array ; Decrement the frequency of that element ; Compute GCD ; Decrement GCD value by 2 ; reverse array ; Driver code
using System ; class GFG { static void printArr ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } static void findNumbers ( int [ ] arr , int n ) { Array . Sort ( arr ) ; reverse ( arr ) ; int [ ] freq = new int [ arr [ 0 ] + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { freq [ arr [ i ] ] ++ ; } int size = ( int ) Math . Sqrt ( n ) ; int [ ] brr = new int [ size ] ; int x , l = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq [ arr [ i ] ] > 0 && l < size ) { brr [ l ] = arr [ i ] ; freq [ brr [ l ] ] -- ; l ++ ; for ( int j = 0 ; j < l ; j ++ ) { if ( i != j ) { x = __gcd ( arr [ i ] , brr [ j ] ) ; freq [ x ] -= 2 ; } } } } printArr ( brr , size ) ; } public static void reverse ( int [ ] input ) { int last = input . Length - 1 ; int middle = input . Length / 2 ; for ( int i = 0 ; i <= middle ; i ++ ) { int temp = input [ i ] ; input [ i ] = input [ last - i ] ; input [ last - i ] = temp ; } } static int __gcd ( int a , int b ) { if ( b == 0 ) { return a ; } return __gcd ( b , a % b ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 5 , 5 , 5 , 7 , 10 , 12 , 2 , 2 } ; int n = arr . Length ; findNumbers ( arr , n ) ; } }
Bitwise AND of N binary strings | C # implementation of the above approach : ; Function to find the bitwise AND of all the binary strings ; To store the largest and the smallest string ' s ▁ size , ▁ We ▁ need ▁ this ▁ to ▁ add ▁ ▁ ' 0 's in the resultant string ; Reverse each string Since we need to perform AND operation on bits from Right to Left ; Update the respective length values ; Traverse bits from 0 to smallest string 's size ; If at this bit position , there is a 0 in any of the given strings then AND operation on current bit position will be 0 ; Add resultant bit to result ; Add 0 's to the string. ; Reverse the string Since we started from LEFT to RIGHT ; Return the resultant string ; Utility reversefunction ; Swap values of left and right ; Driver code
using System ; class GfG { static String strBitwiseAND ( String [ ] arr , int n ) { String res = " " ; int smallest_size = int . MaxValue ; int largest_size = int . MinValue ; String temp = " " ; for ( int i = 0 ; i < n ; i ++ ) { temp += arr [ i ] ; arr [ i ] = reverse ( temp ) ; smallest_size = Math . Min ( smallest_size , arr [ i ] . Length ) ; largest_size = Math . Max ( largest_size , arr [ i ] . Length ) ; } for ( int i = 0 ; i < smallest_size ; i ++ ) { bool all_ones = true ; for ( int j = 0 ; j < n ; j ++ ) { if ( arr [ j ] [ i ] == '0' ) { all_ones = false ; break ; } } res += ( all_ones ? '1' : '0' ) ; } for ( int i = 0 ; i < largest_size - smallest_size ; i ++ ) res += '0' ; String temp1 = " " ; temp1 += res ; res = reverse ( temp1 ) ; return res ; } static String reverse ( String input ) { char [ ] temparray = input . ToCharArray ( ) ; int left , right = 0 ; right = temparray . Length - 1 ; for ( left = 0 ; left < right ; left ++ , right -- ) { char temp = temparray [ left ] ; temparray [ left ] = temparray [ right ] ; temparray [ right ] = temp ; } return String . Join ( " " , temparray ) ; } public static void Main ( String [ ] args ) { String [ ] arr = { "101" , "110110" , "111" } ; int n = arr . Length ; Console . WriteLine ( strBitwiseAND ( arr , n ) ) ; } }
Rearrange Odd and Even values in Alternate Fashion in Ascending Order | C # implementation of the above approach ; Collection . sort ( ) sorts the collection in ascending order ; ArrayList v1 = new ArrayList ( ) ; to insert even values ArrayList v2 = new ArrayList ( ) ; to insert odd values ; Set flag to true if first element is even ; Start rearranging array ; If first element is even ; Else , first element is Odd ; Print the rearranged array ; Driver code
using System ; using System . Collections ; class GFG { static void AlternateRearrange ( int [ ] arr , int n ) { Array . Sort ( arr ) ; for ( int j = 0 ; j < n ; j ++ ) if ( arr [ j ] % 2 == 0 ) v1 . Add ( arr [ j ] ) ; else v2 . Add ( arr [ j ] ) ; int index = 0 , i = 0 , k = 0 ; bool flag = false ; if ( arr [ 0 ] % 2 == 0 ) flag = true ; while ( index < n ) { if ( flag == true ) { arr [ index ] = ( int ) v1 [ i ] ; i += 1 ; index += 1 ; flag = ! flag ; } else { arr [ index ] = ( int ) v2 [ k ] ; k += 1 ; index += 1 ; flag = ! flag ; } } for ( i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } static void Main ( ) { int [ ] arr = { 9 , 8 , 13 , 2 , 19 , 14 } ; int n = arr . Length ; AlternateRearrange ( arr , n ) ; } }
Convert given array to Arithmetic Progression by adding an element | C # implementation of the approach ; Function to return the number to be added ; If difference of the current consecutive elements is different from the common difference ; If number has already been chosen then it 's not possible  to add another number ; If the current different is twice the common difference then a number can be added midway from current and previous element ; Number has been chosen ; It 's not possible to maintain  the common difference ; Return last element + common difference if no element is chosen and the array is already in AP ; Else return the chosen number ; Driver code
using System ; public class GFG { static int getNumToAdd ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int d = arr [ 1 ] - arr [ 0 ] ; int numToAdd = - 1 ; bool numAdded = false ; for ( int i = 2 ; i < n ; i ++ ) { int diff = arr [ i ] - arr [ i - 1 ] ; if ( diff != d ) { if ( numAdded ) return - 1 ; if ( diff == 2 * d ) { numToAdd = arr [ i ] - d ; numAdded = true ; } else return - 1 ; } } if ( numToAdd == - 1 ) return ( arr [ n - 1 ] + d ) ; return numToAdd ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 5 , 7 , 11 , 13 , 15 } ; int n = arr . Length ; Console . WriteLine ( getNumToAdd ( arr , n ) ) ; } }
Minimum Numbers of cells that are connected with the smallest path between 3 given cells | C # implementation of the approach ; Function to return the minimum cells that are connected via the minimum length path ; Array to store column number of the given cells ; Sort cells in ascending order of row number ; Middle row number ; Set pair to store required cells ; Range of column number ; Store all cells of middle row within column number range ; Final step to store all the column number of 1 st and 3 rd cell upto MidRow ; vector pair to store X , Y , Z
using System ; using System . Collections . Generic ; class GFG { static int Minimum_Cells ( List < Tuple < int , int > > v ) { int [ ] col = new int [ 3 ] ; int i , j ; for ( i = 0 ; i < 3 ; i ++ ) { int column_number = v [ i ] . Item2 ; col [ i ] = column_number ; } Array . Sort ( col ) ; v . Sort ( ) ; int MidRow = v [ 1 ] . Item1 ; HashSet < Tuple < int , int > > s = new HashSet < Tuple < int , int > > ( ) ; int Maxcol = col [ 2 ] , MinCol = col [ 0 ] ; for ( i = MinCol ; i <= Maxcol ; i ++ ) { s . Add ( new Tuple < int , int > ( MidRow , i ) ) ; } for ( i = 0 ; i < 3 ; i ++ ) { if ( v [ i ] . Item1 == MidRow ) continue ; for ( j = Math . Min ( v [ i ] . Item1 , MidRow ) ; j <= Math . Max ( v [ i ] . Item1 , MidRow ) ; j ++ ) { s . Add ( new Tuple < int , int > ( j , v [ i ] . Item1 ) ) ; } } return s . Count ; } static void Main ( ) { List < Tuple < int , int > > v = new List < Tuple < int , int > > ( ) ; v . Add ( new Tuple < int , int > ( 0 , 0 ) ) ; v . Add ( new Tuple < int , int > ( 1 , 1 ) ) ; v . Add ( new Tuple < int , int > ( 2 , 2 ) ) ; Console . Write ( Minimum_Cells ( v ) ) ; } }
Get maximum items when other items of total cost of an item are free | C # implementation of the above approach ; Function to count the total number of items ; Sort the prices ; Choose the last element ; Initial count of item ; Sum to keep track of the total price of free items ; If total is less than or equal to z then we will add 1 to the answer ; Driver code
using System ; class GFG { static int items ( int n , int [ ] a ) { Array . Sort ( a ) ; int z = a [ n - 1 ] ; int x = 1 ; int s = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { s += a [ i ] ; if ( s <= z ) x += 1 ; else break ; } return x ; } static public void Main ( ) { int n = 5 ; int [ ] a = { 5 , 3 , 1 , 5 , 6 } ; Console . WriteLine ( items ( n , a ) ) ; } }
Sorting array elements with set bits equal to K | C # program for sorting array elements with set bits equal to K ; Represents node of a doubly linked list ; Function to sort elements with set bits equal to k ; initialise two vectors ; first vector contains indices of required element ; second vector contains required elements ; sorting the elements in second vector ; replacing the elements with k set bits with the sorted elements ; printing the new sorted array elements ; Utility function ; Driver code
using System ; using System . Collections . Generic ; public class Node { static void sortWithSetbits ( int [ ] arr , int n , int k ) { List < int > v1 = new List < int > ( ) ; List < int > v2 = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( bitCount ( arr [ i ] ) == k ) { v1 . Add ( i ) ; v2 . Add ( arr [ i ] ) ; } } v2 . Sort ( ) ; for ( int i = 0 ; i < v1 . Count ; i ++ ) { arr [ v1 [ i ] ] = v2 [ i ] ; } for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } static int bitCount ( long x ) { int setBits = 0 ; while ( x != 0 ) { x = x & ( x - 1 ) ; setBits ++ ; } return setBits ; } public static void Main ( String [ ] args ) { int [ ] arr = { 14 , 255 , 1 , 7 , 13 } ; int n = arr . Length ; int k = 3 ; sortWithSetbits ( arr , n , k ) ; } }
Minimum boxes required to carry all gifts | C # implementation of above approach ; Function to return number of boxes ; Sort the boxes in ascending order ; Try to fit smallest box with current heaviest box ( from right side ) ; Driver Code
using System ; class GFG { static int numBoxes ( int [ ] A , int n , int K ) { Array . Sort ( A ) ; int i = 0 , j = ( n - 1 ) ; int ans = 0 ; while ( i <= j ) { ans ++ ; if ( A [ i ] + A [ j ] <= K ) i ++ ; j -- ; } return ans ; } static public void Main ( ) { int [ ] A = { 3 , 2 , 2 , 1 } ; int K = 3 ; int n = A . Length ; Console . WriteLine ( numBoxes ( A , n , K ) ) ; } }
Count triplets in a sorted doubly linked list whose product is equal to a given value x | C # implementation to count triplets in a sorted doubly linked list whose product is equal to a given value ' x ' ; Structure of node of doubly linked list ; Function to count triplets in a sorted doubly linked list whose product is equal to a given value ' x ' ; Unordered_map ' um ' implemented as hash table ; Insert the < node data , node pointer > tuple in ' um ' ; Generate all possible pairs ; p_product = product of elements in the current pair ; If ' x / p _ product ' is present in ' um ' and either of the two nodes are not equal to the ' um [ x / p _ product ] ' node ; Increment count ; Required count of triplets division by 3 as each triplet is counted 3 times ; A utility function to insert a new node at the beginning of doubly linked list ; Allocate node ; Put in the data ; Driver code ; Start with an empty doubly linked list ; Insert values in sorted order
using System ; using System . Collections . Generic ; class Node { public int data ; public Node next , prev ; } class GFG { static int countTriplets ( Node head , int x ) { Node ptr , ptr1 , ptr2 ; int count = 0 ; Dictionary < int , Node > um = new Dictionary < int , Node > ( ) ; for ( ptr = head ; ptr != null ; ptr = ptr . next ) { um . Add ( ptr . data , ptr ) ; } for ( ptr1 = head ; ptr1 != null ; ptr1 = ptr1 . next ) { for ( ptr2 = ptr1 . next ; ptr2 != null ; ptr2 = ptr2 . next ) { int p_product = ( ptr1 . data * ptr2 . data ) ; if ( um . ContainsKey ( x / p_product ) && um [ x / p_product ] != ptr1 && um [ x / p_product ] != ptr2 ) { count ++ ; } } } return ( count / 3 ) ; } static Node insert ( Node head , int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . next = temp . prev = null ; if ( head == null ) { head = temp ; } else { temp . next = head ; head . prev = temp ; head = temp ; } return head ; } static public void Main ( ) { Node head = null ; head = insert ( head , 9 ) ; head = insert ( head , 8 ) ; head = insert ( head , 6 ) ; head = insert ( head , 5 ) ; head = insert ( head , 4 ) ; head = insert ( head , 2 ) ; head = insert ( head , 1 ) ; int x = 8 ; Console . WriteLine ( " Count ▁ = ▁ " + countTriplets ( head , x ) ) ; } }
Maximize the profit by selling at | C # implementation of above approach : ; Function to find profit ; Calculating profit for each gadget ; sort the profit array in descending order ; variable to calculate total profit ; check for best M profits ; Driver Code
using System ; class GFG { static int solve ( int N , int M , int [ ] cp , int [ ] sp ) { int [ ] profit = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) profit [ i ] = sp [ i ] - cp [ i ] ; Array . Sort ( profit ) ; Array . Reverse ( profit ) ; int sum = 0 ; for ( int i = 0 ; i < M ; i ++ ) { if ( profit [ i ] > 0 ) sum += profit [ i ] ; else break ; } return sum ; } public static void Main ( ) { int N = 5 , M = 3 ; int [ ] CP = { 5 , 10 , 35 , 7 , 23 } ; int [ ] SP = { 11 , 10 , 0 , 9 , 19 } ; Console . Write ( solve ( N , M , CP , SP ) ) ; } }
Find the largest number that can be formed with the given digits | C # program to generate largest possible number with given digits ; Function to generate largest possible number with given digits ; sort the given array in ascending order and then traverse into descending ; generate the number ; Driver code
using System ; public class GFG { static int findMaxNum ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int num = arr [ 0 ] ; for ( int i = n - 1 ; i >= 0 ; i -- ) { num = num * 10 + arr [ i ] ; } return num ; } static public void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 0 } ; int n = arr . Length ; Console . WriteLine ( findMaxNum ( arr , n ) ) ; } }
Minimum partitions of maximum size 2 and sum limited by given value | C # program to count minimum number of partitions of size 2 and sum smaller than or equal to given key . ; sort the array ; if sum of ith smaller and jth larger element is less than key , then pack both numbers in a set otherwise pack the jth larger number alone in the set ; After ending of loop i will contain minimum number of sets ; Driver Code
using System ; class GFG { static int minimumSets ( int [ ] arr , int n , int key ) { int i , j ; Array . Sort ( arr ) ; for ( i = 0 , j = n - 1 ; i <= j ; ++ i ) if ( arr [ i ] + arr [ j ] <= key ) j -- ; return i ; } public static void Main ( ) { int [ ] arr = { 3 , 5 , 3 , 4 } ; int n = arr . Length ; int key = 5 ; Console . WriteLine ( minimumSets ( arr , n , key ) ) ; } }
Bubble Sort On Doubly Linked List | C # program to sort a doubly linked list using bubble sort ; structure of a node ; Function to insert a node at the beginning of a linked list ; Function to print nodes in a given linked list ; Bubble sort the given linked list ; Checking for empty list ; Driver code ; start with empty linked list ; Create linked list from the array arr [ ] . Created linked list will be 1 -> 11 -> 2 -> 56 -> 12 ; print list before sorting ; sort the linked list ; print list after sorting
using System ; class GFG { public class Node { public int data ; public Node prev ; public Node next ; } ; static Node insertAtTheBegin ( Node start_ref , int data ) { Node ptr1 = new Node ( ) ; ptr1 . data = data ; ptr1 . next = start_ref ; if ( start_ref != null ) ( start_ref ) . prev = ptr1 ; start_ref = ptr1 ; return start_ref ; } static void printList ( Node start ) { Node temp = start ; Console . WriteLine ( ) ; while ( temp != null ) { Console . Write ( temp . data + " ▁ " ) ; temp = temp . next ; } } static Node bubbleSort ( Node start ) { int swapped ; Node ptr1 ; Node lptr = null ; if ( start == null ) return null ; do { swapped = 0 ; ptr1 = start ; while ( ptr1 . next != lptr ) { if ( ptr1 . data > ptr1 . next . data ) { int t = ptr1 . data ; ptr1 . data = ptr1 . next . data ; ptr1 . next . data = t ; swapped = 1 ; } ptr1 = ptr1 . next ; } lptr = ptr1 ; } while ( swapped != 0 ) ; return start ; } public static void Main ( String [ ] args ) { int [ ] arr = { 12 , 56 , 2 , 11 , 1 , 90 } ; int i ; Node start = null ; for ( i = 0 ; i < 6 ; i ++ ) start = insertAtTheBegin ( start , arr [ i ] ) ; Console . Write ( " STRNEWLINE ▁ Linked ▁ list ▁ before ▁ sorting ▁ " ) ; printList ( start ) ; start = bubbleSort ( start ) ; Console . Write ( " STRNEWLINE ▁ Linked ▁ list ▁ after ▁ sorting ▁ " ) ; printList ( start ) ; } }