Sir bubble sort also takes (n-1) iterations /passes to sort an array it's not n . And in bubble sort after each pass largest element moves to last position. Let's consider array as [5 4 3 2 1] After Pass 1- 4 3 2 1 5 After Pass 2- 3 2 1 4 5 After Pass 3- 2 1 3 4 5 After Pass 4 - 1 2 3 4 5 So here no. Of passes are 4 so,at max it takes (n-1) passes not n.
Qno 6. Which is not stable sorting algo ? Ans is quick sort .not bubble sort. Only quick sort and selection sort are unstable rest all are stable sorting algo ,but even quick and selection sort also be made stable.
If the array is sorted then it can be detected in the first iteration only with the help of flag variable that will be the BEST CASE scenario for bubble sort with the time complexity of O(n) But if the array is sorted in reversed order which is the WORST CASE scenario for bubble sort taking the time complexity of O(n^2)
Bubble sort is a stable sorting algorithm. This means that if there are multiple elements with the same value, their relative order will be preserved after the sort. For example, if the original array is [5, 2, 5, 1], a stable sort will result in [1, 2, 5, 5], while an unstable sort might result in [1, 5, 2, 5]. In contrast, an unstable sort is a sorting algorithm that may change the relative order of elements with equal values. An example of an unstable sort is selection sort.
Question 1: Both Selection & Bubble takes n-1 iterations
Yes
YES !!! ABSOLUTELY RIGHT 👍
I want more videos like this, l am benifited throughout this learning processes....and also lots of thanks to you and your team.
Thank you so much, Keep watching.
Sir bubble sort also takes (n-1) iterations /passes to sort an array it's not n .
And in bubble sort after each pass largest element moves to last position.
Let's consider array as [5 4 3 2 1]
After Pass 1- 4 3 2 1 5
After Pass 2- 3 2 1 4 5
After Pass 3- 2 1 3 4 5
After Pass 4 - 1 2 3 4 5
So here no. Of passes are 4 so,at max it takes (n-1) passes not n.
Very good... Questions
Bubble Sort is a stable sort algorithm, Quick ain't.
yes answer will be quick sort.....sir plz check the question no.-6 once...
Which is not Stable sorting Algorithm?
Ans:Quick Sort
Yes 👍
Please improve Q 6 answer instead of bubble sort it is a Quick sort
Good explanation sir thanku
Always welcome
Que9: Answer should be Quick sort, in question they mentioned clearly that best for Array, so answer should be Quick sort
Q.N.6) The answer should be Quick Sort right? The question is to choose unstable sorting algorithm.
yea bro
It's helpful.......:)
Glad to hear that
Thanks sir g....
I always support u sir pls make more videos like this
Qno 6. Which is not stable sorting algo ?
Ans is quick sort .not bubble sort.
Only quick sort and selection sort are unstable rest all are stable sorting algo ,but even quick and selection sort also be made stable.
Question 6 quick sort is an answer because it is an unstable sort remaining all stable sorts
Bubble sort n-1 iteration
Selection sort n iteration
Question no 6 ....Ans is -C (Quick Sort)
sir you disussed in ine of your video
if a={2,3,4,5,6}
then bubble sort will take=O(1)
but here discussing o(n*2) ??? please explain
bro one loop for iteration and one for swaping
If the array is sorted then it can be detected in the first iteration only with the help of flag variable that will be the BEST CASE scenario for bubble sort with the time complexity of O(n)
But if the array is sorted in reversed order which is the WORST CASE scenario for bubble sort taking the time complexity of O(n^2)
Great sir👍
Helpful..
Question no 6asked for not stable sorting algorithm ,and u explained for stable.
Yes, the answer would be quick sort. 🙂
@@naveenmanchanda2625 correct!!
Sir....dynamic allocation is possible via malloc function... Is it correct sir
Question 6 quick sort is not stable bubble sort is stable sir
Nice
Thanks
Super sir
More question on sorting and hashing plz
Sir I think 6th question answer may be quick sort sir
Aque. 6th me not stable poocha hai sir ,aap bata rhe ho bubble sort stable h
Bubble sort is a stable sorting algorithm. This means that if there are multiple elements with the same value, their relative order will be preserved after the sort. For example, if the original array is [5, 2, 5, 1], a stable sort will result in [1, 2, 5, 5], while an unstable sort might result in [1, 5, 2, 5].
In contrast, an unstable sort is a sorting algorithm that may change the relative order of elements with equal values. An example of an unstable sort is selection sort.
Question 6 answer is quick sort sir..they asked not stable
Sir question 6 answer is wrong it is quick sort
6 ans is quick sort
❤️
Question 5 is wrong ans should be quick sort