What is Bubble Sort ? And why do we need this ? Bubble sort is the simplest algorithm to sort any array. Due to its simplicity, bubble sort is often used to introduce the concept of a sorting algorithm. In computer graphics it is popular for its capability to detect a very small error (like swap of just two elements) in almost-sorted arrays and fix it with just linear complexity (2n). For example, it is used in a polygon filling algorithm, where bounding lines are sorted by their x coordinate at a specific scan line (a line parallel to x axis) and with incrementing y their order changes . ALGORITHM :- 1.) Firstly we have an unsorted list, which is to be sorted. 2.) Consider the first element of the list. Then compare it with the next element. 3.) If the second element is greator than the first element than swap them. 4.) If the second element is smaller than the first element, then we don't have to do anything. 5.) Going ahead, now after swap (may or may not), look for second...
It is very useful for me to learn and understand easily. Thanks for sharing your valuable information
ReplyDeletePython Online Course
Python Online Training in India
Got the most appropriate and easy to understand code.
ReplyDelete