text: Recursive Bubble Sort | C # program for recursive implementation of Bubble sort ; A function to implement bubble sort ; Base case ; One pass of bubble sort . After this pass , the largest element is moved ( or bubbled ) to end . ; swap arr [ i ] , arr [ i + 1 ] ; Largest element is fixed , recur for remaining array ; Driver code
code: using System ; class GFG { static void bubbleSort ( int [ ] arr , int n ) { if ( n == 1 ) return ; for ( int i = 0 ; i < n - 1 ; i ++ ) if ( arr [ i ] > arr [ i + 1 ] ) { int temp = arr [ i ] ; arr [ i ] = arr [ i + 1 ] ; arr [ i + 1 ] = temp ; } bubbleSort ( arr , n - 1 ) ; } static void Main ( ) { int [ ] arr = { 64 , 34 , 25 , 12 , 22 , 11 , 90 } ; bubbleSort ( arr , arr . Length ) ; Console . WriteLine ( " Sorted ▁ array ▁ : ▁ " ) ; for ( int i = 0 ; i < arr . Length ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }