sign up I login
 advanced
refer a friend - earn nickels!!

Ask & Discuss Questions with Community & Experts

Moderation Team
 90 chars left    advanced
Ask iit jee aieee pet cbse icse state board community Community Discussion Question: LOGIC OF INSERTION ,DELETION &BUBBLE SORT
Forum Index -> Computer Science like the article? email it to a friend.  
Author Message
brainbank (735)

Blazing goIITian

Olaaa!! Perrrfect answer. 129  [174 rates]

brainbank's Avatar

total posts: 590    
offline Offline
HELLO EVERYONE....................
PLEASE EXPLAIN THE LOGIC OF INSERTION,SELECTION AND DELETION SORT.ALSO EXPLAIN THE LOGIC OF FOLLOWING LOOPS:
1.FOR
2.WHILE
3.DO WHILE
 
 
 
HOPING FOR GOOD REPLIES!!!!!!
 
    
LAMPARD (1142)

Blazing goIITian

Olaaa!! Perrrfect answer. 190  [286 rates]

LAMPARD's Avatar

total posts: 777    
offline Offline
Insertion sort-See,insertion sort is carried out round after round.In the K-th round,the Kth element is considered.By comparison with the previous (K-1) elements of the array,its proper position is determined.The element is then inserted into that position after shifting the succeeding elements one place each to the right.

Selection sort-One way to perform it is to select the smallest element from the unsorted portion of the array and put the element in the ordered position,which starts from the first position of the array,pushing the unsorted portion one portion to the right.
I dunno about deletion sort.
In for loops,for eg. you want to do an operation for a particular number of times,den we use for loop.

In while loops,you first put a condition such that if the variable or any other character satisfies that condition,den it will go into the while loop.

In do while loops,the variable or character first goes into the loop and then it is checked whether its satisfies the condition or not.

If u didn understand sumthing,plz clarify it.

MaNuTd RoXxXx..MaNuTd 2 WiN PrEmIeR LeAgUe ThIs SeAsOn ToO AlOnG WiTh ChAmPiOnS LeAgUe.....HaiL RoNaLdO ...HaiL LaMpArD...
 this reply: 5 points  (with Olaaa!! Perrrfect answer.   in 1 votes )   [?]
 
You have to be logged on to rate
  
brainbank (735)

Blazing goIITian

Olaaa!! Perrrfect answer. 129  [174 rates]

brainbank's Avatar

total posts: 590    
offline Offline
thanks lampard.
can you explain the logic for wriiting these sorting.my teacher told us to mug up .but i didn't want to mug up.
please explain them stepwise
and if possible explain with the help of examplesso that i can understand better.
PLEASE REPLY SOON...............
 this reply: 0 points  (with Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
nadeemoidu (1184)

Blazing goIITian

Olaaa!! Perrrfect answer. 200  [292 rates]

nadeemoidu's Avatar

total posts: 487    
offline Offline
http://www.cosc.canterbury.ac.nz/mukundan/dsal/SSort.html
http://www.cosc.canterbury.ac.nz/mukundan/dsal/ISort.html
http://www.cosc.canterbury.ac.nz/mukundan/dsal/BSort.html

these animations will tell u the logic. u 've to figure out what each line means.
 this reply: 5 points  (with Olaaa!! Perrrfect answer.   in 1 votes )   [?]
 
You have to be logged on to rate
  
LAMPARD (1142)

Blazing goIITian

Olaaa!! Perrrfect answer. 190  [286 rates]

LAMPARD's Avatar

total posts: 777    
offline Offline
For insertion sort-
for(i=1;i<n;i++)
{
  temp=a[i];//a[n] is an array to be sorted.Now consider a[0] as 95 and a[1] as 45
    c=i-1;   // When i is 1,c will be 0.
    while((temp<a[c])&&(count>=0))  //Since temp is 95 which is > than 45,while loop will be executed.
       {
          a[c+1]=a[c]; //here,we are making a[c+1],i.e,a[1]=a[0],so a[1] becomes95.
          c=c-1; //
now c has become -1.
         }
    a[c+1]=temp; //now,a[c+1],i.e a[0] is given value of temp,i.e. 45...
}
Thus after for loop is executed for i=1,a[0] has become 45 and a[1] has become 95...similarly,for loop will also be executed for i=2,3,...,n....so each element will be thus compared with previous elements...hope u got it..


MaNuTd RoXxXx..MaNuTd 2 WiN PrEmIeR LeAgUe ThIs SeAsOn ToO AlOnG WiTh ChAmPiOnS LeAgUe.....HaiL RoNaLdO ...HaiL LaMpArD...
 this reply: 5 points  (with Olaaa!! Perrrfect answer.   in 1 votes )   [?]
 
You have to be logged on to rate
  
brainbank (735)

Blazing goIITian

Olaaa!! Perrrfect answer. 129  [174 rates]

brainbank's Avatar

total posts: 590    
offline Offline
THANKS
 this reply: 0 points  (with Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
 
Forum Index -> Computer Science
Go to:   

Top Offers for goIITians
Correspondence Courses
Brilliant Tutorials
Narayana Institute
Aakash Institute
Classroom/Crash Courses
Narayana - Kota , Delhi , Others
Brilliant Tutorials - Class , Crash
Aakash Institute - Medical , Engg
Online Test Series
Brilliant Tutorials
Narayana Institute
Aakash Institute
Mahesh Tutorials
AMITY      Sri Chaitanya