C language tricky good pointers questions answers and explanation operators data types arrays structures questions functions recursion preprocessors, looping, file handling, strings questions switch case if else printf advance c linux objective types mcq faq interview questions and answers with explanation and solution for freshers or beginners. Placement online written test prime numbers Armstrong Fibonacci series factorial palindrome code programs examples on c c++ tutorials and pdf

yes it would give the desired result, but it will also increase the number of comparisons. run your code with an example and the given code with the same example, you'll see the difference

If i wud write the loop as

ReplyDeletefor(i=0 to <s)

{ for(j=0 to<s-i)

{ j=i +1;

swap(a[j],a[j+1]);

}

)

den wud it give desired result?

no i think

Deleteyes it would give the desired result, but it will also increase the number of comparisons.

ReplyDeleterun your code with an example and the given code with the same example, you'll see the difference

Great tutorial

ReplyDeleteTanx :)

Why this is used?

ReplyDeletefor(i=s-2;

s-2 is the second last element of d array ... and we are checking it out with j+1. that's why we have used s-2

Deletebut the first loop start at the end of the array, if you say s-2 how you will reach the last element in taht array

ReplyDeleteyeah absolutely right how to do for last element

Deletein assending or desssinding order???

ReplyDeletecan you explain me this program in details?

ReplyDeletehi ,what u want to ask in this prog,i can explain if you are interested..

DeleteCan u tell me the time complexity for the program "Bubble sort using c program"???

ReplyDeleteIt remains same Big O(n^2)..U can run the program for 30 elements with a loop Counter to get a clear idea..Below 30 results will be confusing

Deletethis code is wrong ...atleast write exact code :(

ReplyDeleteUse for(i=0;i<s-1;i++)

{

for(j=0;j<s-i-1;j+)

i cant understand this s-2 and j+1.. could u pls explain me

ReplyDeletei=s-2 marks the second last element and when j+1 reaches to i it checks the next value(last value) in array so that gets compared too..

Deletecan u explain me the algorithm of this bubble sort

ReplyDeletethis program is using arrays... what can i do for a bubble sort program using functions??

ReplyDeletehey,.. this program is using array,.. what can i do to use bubblesort using functions..???

ReplyDelete