Saturday 6 January 2018

Bubble Sort Useing python

Bubble Sort Useing Python 2.7

Bubble Sort is simple sorting Algorithm which wark step by step sorting according to the passes or iteration



Rules to sort

  • Number of iteration or passes is to be done is eqal to number of element in the list
  • Compare each pare of adjesent two numbers
  • Swaps them untill the no swaps are needed

Strategy To be use to write python code
  • Use list to take input
  • Append is python define list function
  • For loop of "X" varible is to number of passes or iteration
  • For loopof "XX" is for no of sorting in single pass to be done



PYTHON CODES

Code Useing Simple Python



 C:\Users\rushi\Desktop\mypyDec>python bubbleSort.py
Number of Element to be sort
>4
>3
>1
>8
>6
Your Unsorded List is :- [3, 1, 8, 6]
[1, 3, 6, 8]


Pyhton Program using class is little bit large but easy to understand.

  • Class Name of "sortAlgo" is use .
  • Many Function is use to make program simple to understand.
  • "__init__" is constracter used to define empty List "o_list"


PYTHON CODES

Code Useing Class Concept and Function



C:\Users\rushi\Desktop\mypyDec>python bubbleSortClass.py
Enter Number of Element to be sort
>>4
Enter Element
>3
[3]
>1
[3, 1]
>8
[3, 1, 8]
>6
[3, 1, 8, 6]
Your Unsorded List is:- [3, 1, 8, 6]
Your sorded List is:- [1, 3, 6, 8]

C:\Users\rushi\Desktop\mypyDec>


Monday 1 January 2018

Hello World Program phyton

In Python Printing any thing is easy and simple .
° There's no need to tell that no z

IT's Good