DSA in Python: Bubble Sort
Transcript
English (Auto-generated)
we are going to implement bubble sort using python before we proceed with implementation. Let's quickly look into the visualization of double sword. So I'm using this side um visual go door net, you can tried out by yourself. Let's this This is an array of array of data which needs to be sorted now we will press sort. Okay. As you can see the process is very simple. We are going to iterate through the array and at each phase we are going to compare two elements and swap them If the next element is is smaller than the previous one. As simple as that. We're going to keep on hydrating until there are no scrubs. So the algorithm algorithm is pretty simple as you can see here. We will be implementing this. So let's move to implementation. Um first of all we will decline a method, good sort and then we will have and outer loop which will take those webs. Uh we can use wild here. Okay. MS. And we will have an inner loop which will I read through the array. Okay. So if let's fix this. Okay. So if it's the previous element is bigger than the next gentleman, then we'll simply swipe it so we can use a temporary variable bird. Will this this is python in view of sweating video. Next If which back then elements would have started here and we need to assume that knows where happened over here. And if the dessert will return already and now we'll write for Well. Right dr accord are crazy. We'll do then zeal is alone. Oh, next next will all the mat matter we created and drink. Mhm. Mhm. Yeah. Yeah. Right. Thank you. Okay. Mhm. Yeah.