Home » Ask & Discuss » Board Exams - CBSE, ICSE, State Boards » Computer Science « Back to Discussion



Computer Science

brain bank's Avatar
Blazing goIITian

Joined: 27 Nov 2007
Post: 645
13 Mar 2008 15:25:31 IST
0 People liked this
6
1619 View Post
LOGIC OF INSERTION ,DELETION &BUBBLE SORT
None

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!!!!!!
 


Share this article on:

Comments (6)

LAMPARD's Avatar

Blazing goIITian

Joined: 1 May 2007
Posts: 777
13 Mar 2008 16:25:28 IST
1 people liked this

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.
brain bank's Avatar

Blazing goIITian

Joined: 27 Nov 2007
Posts: 645
13 Mar 2008 16:30:10 IST
0 people liked this

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...............
Nadeem's Avatar

Blazing goIITian

Joined: 25 Aug 2007
Posts: 521
13 Mar 2008 16:38:23 IST
2 people liked this

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.
LAMPARD's Avatar

Blazing goIITian

Joined: 1 May 2007
Posts: 777
13 Mar 2008 16:46:59 IST
1 people liked this

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..

brain bank's Avatar

Blazing goIITian

Joined: 27 Nov 2007
Posts: 645
14 Mar 2008 07:34:29 IST
0 people liked this

THANKS

New kid on the Block

Joined: 17 Jan 2012
Posts: 1
17 Jan 2012 12:53:22 IST
0 people liked this

LOGIC OF INSERTION ,DELETION &BUBBLE SORT



Quick Reply


Reply

Some HTML allowed.
Keep your comments above the belt or risk having them deleted.
Signup for a avatar to have your pictures show up by your comment
If Members see a thread that violates the Posting Rules, bring it to the attention of the Moderator Team
Free Sign Up!

Preparing for IIT-JEE ?

Arihant Revision Package for IIT JEE - Books, Practice Tests + Rank Predictor


@ INR 1,995/-

For Quick Info

Name

Mobile No.

Find Posts by Topics

Physics.

Topics

Mathematics.

Chemistry.

Biology

Parents

Board

Fun Zone

Sponsored Ads