Array - 43: Cyclic Sort | Sort the elements from 1 to n

  Рет қаралды 17,164

Coding Simplified

Coding Simplified

Күн бұрын

Пікірлер: 26
@IndianVideoGameCollector
@IndianVideoGameCollector 3 жыл бұрын
Thank you, this was straightforward and easy to understand
@CodingSimplified
@CodingSimplified 3 жыл бұрын
Thanks for your nice feedback. Keep Watching.
@jitendraraghuwanshi1365
@jitendraraghuwanshi1365 4 жыл бұрын
explained very well 👍🏼 keep up the good work
@CodingSimplified
@CodingSimplified 4 жыл бұрын
Glad you liked it. Keep Watching.
@veeresh4441
@veeresh4441 2 жыл бұрын
We can directly replace the values with ind+1 (or ind + x) right? No need to even have checks, what's the use of cycle sort?
@sohailbasha7781
@sohailbasha7781 2 жыл бұрын
Yes, but i think the logic is helpful in solving dsa
@reekrev
@reekrev 2 жыл бұрын
I have two doubts here: 1. The time complexity is O(n^2), not O(n); can you see why? 2. This is not actually sorting. If you know beforehand the desired result is the ordered list of numbers from k…n you can just generate that list in O(n) time: for(int i=k;i
@yashnarang3014
@yashnarang3014 2 ай бұрын
cry about it baby
@KK7155.
@KK7155. 3 жыл бұрын
Thank you so much. Very nicely explained 👍
@CodingSimplified
@CodingSimplified 3 жыл бұрын
Thanks for your nice feedback. Keep Watching.
@pranays6503
@pranays6503 2 жыл бұрын
great explanation broo :)
@CodingSimplified
@CodingSimplified 2 жыл бұрын
Thanks for your nice feedback. Keep Watching :)
@prasanthkumar6393
@prasanthkumar6393 Жыл бұрын
This video defines the channel name❤
@nikhilgoyal8340
@nikhilgoyal8340 3 жыл бұрын
The time complexity mentioned in the description is not correct.
@AmitKumar-rr5jx
@AmitKumar-rr5jx 3 жыл бұрын
Time complexity is correct for the above case. That is if elements are not greater than n. So one can say, this is a special case. But the complexity of cyclic sort is 0(n ^ 2) and the algorithm will be quite different for finding the correct position.
@AnushaPoosala
@AnushaPoosala Жыл бұрын
Sir,, Your way of teaching is Amazing. Please add source code.
@Randomizer02
@Randomizer02 Жыл бұрын
What if duplicate values exist?
@free-palestine000
@free-palestine000 2 жыл бұрын
best channel
@CodingSimplified
@CodingSimplified 2 жыл бұрын
Thanks for your nice feedback. Keep Watching.
@PankajGupta-gh9cm
@PankajGupta-gh9cm 4 жыл бұрын
what if array contains duplicates
@ayushraj2928
@ayushraj2928 4 жыл бұрын
//Scan vector/array A(n) //Now cycle logic for (int i = 0; i < n; i++) { int pos = A[i] - 1; if (A[pos] != A[i]) { swap(A[pos], A[i]); i--; } } //Print elements It will put the numbers in array in correct indexes..and the other indexes whose values are not in array will get any other repeated value Like for INPUT : 5 3 3 1 2 2 OUTPUT : 1 2 3 3 5 2
@as_if
@as_if 2 жыл бұрын
Now this is what you call beautiful
@yogendrapratapsingh7618
@yogendrapratapsingh7618 4 жыл бұрын
Cycle sort is also for non continuous elements
@TheSimpleEngineer
@TheSimpleEngineer 4 жыл бұрын
This is cyclic sort, not cycle sort. There is a difference.
@cwash08
@cwash08 4 жыл бұрын
@@TheSimpleEngineer thanks for the tip
@viharivemuri7202
@viharivemuri7202 7 ай бұрын
What a silly video? You need to do all that to just sort numbers from 1 to n? Why can'y you just do for each index i, arr[i] = i+1?
Array - 44: Find Missing Number in 1 to n+1 numbers range
12:51
Coding Simplified
Рет қаралды 2,6 М.
L -44 Cycle Sort Algorithm | Java plus DSA Placement | FAANG
33:57
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
My scorpion was taken away from me 😢
00:55
TyphoonFast 5
Рет қаралды 2,7 МЛН
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
Array - 37: Find all Quadruple for given Sum
12:38
Coding Simplified
Рет қаралды 9 М.
7 Outside The Box Puzzles
12:16
MindYourDecisions
Рет қаралды 510 М.
Heaps, heapsort, and priority queues - Inside code
19:01
Inside code
Рет қаралды 107 М.
you will never ask about pointers again after watching this video
8:03
Array - 50: Find first missing positive number in given array
19:44
Coding Simplified
Рет қаралды 13 М.
Cycle Sort - Amazon, Google, Microsoft Interview Questions
1:35:32
Kunal Kushwaha
Рет қаралды 419 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 737 М.
Cycle Sort Algorithm - Sorting with Minimal Writes
20:11
Stephen Melvin
Рет қаралды 10 М.
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН