Saturday, 16 March 2019

Sorting class 11 python cbse

SORTING

It refers to arranging element in a specific order ascending or descending 

BUBBLE SORTING

The basic idea is to compare 2 adjoining values and exchange ,then if they are not in proper order.In every pass the heaviest element settles at its appropriate position in the bottom.

BUBBLE SORT

alist=[15,6,13,22,35,2]
print("original list is'' : alist)
        n=len(alist)
for i in range (n):
     for j in range (0,n-j,-1):
           if alist (i)>alist (j+1):
                     alist=(j+1):
print("list after sorting:,alist)

INSERTION SORT

lst=[15,14,2,3,4,5,6,77,88,90]
print("original list is:"lst)
for i in range (1,len(lst)):
          temp=lst[i]
          j=i-1
          while j>0 and temp<lst[j]:
                  lst[j+1]=lst[j]
                   j=j-1
             else:
                  lst[j+1]=temp
print("list after sort is:",lst)

12 comments:

  1. how to download assassins creed ragnarokkkkkk

    ReplyDelete
  2. rickshaw chalene me mzao aata hai

    ReplyDelete
  3. plaes follow karo hume on isntagarm @xxxxx

    ReplyDelete
  4. aur batao kaise ho tum hum toh mote hai

    ReplyDelete
  5. hume 12 ka tbale nahi aate hai prr hum bihari hai ......proud to be a bihari.....aap kaha rehete ho hum toh bihar me rehete hai .....kriypa batae .....hum toh bihar me rehete hai .....bihari babu......... :)

    ReplyDelete
  6. bye kal baat karte hai hum aapse from bihar by bihari babu latchay.......

    ReplyDelete