How recursive bubble sort work

                                              Recursive Bubble Sort Base Case: If array size is 1, return. Do One Pass of normal Bubble Sort. This pass fixes last element of current subarray. Recur for all elements except last of current subarray. Example: Index=     0 1  2 3 4 5 6 7   100                          90 80 70 60 50 40 30  Array []= Suppose we want to sort the above in the increasing order by the recursive bubble sort. Make a get grater which will return the grater of the array. Compare the first and last element of the array if the first is greater than last the swap with each other. And again call the sort function and decrement the array size by 1; 1) 30                     90 80 70 60 50 40 100    ...

For Loop in C Programming


A for loop is repetition control structure that allows you to efficiently write a loop that needs to execute specific number of times. A for loop inside another loop is called nested loop. The inner loop executes “n(n+1)/2” times for outer loop which executes “n-times”. Syntax of for loop is as follow:
for ( initialization; condition; loop counter)
{
                                                               Statements to be executed;
}
For loop specify following things about a loop
       Counter is set to initial value
       Condition is tested
       If condition is true, loop body executed
       Control is sent back to for statement and counter is incremented 
       Again condition is tested
       Loop exits when condition becomes false
       No semi colon after closing parenthesis

printing the parent with for loop 



Comments

Popular posts from this blog

simple calculator apps project in android studio

Arrays in C Programming Language

Pointers in C