Learn Selection Sort in 8 minutes 🔦

  Рет қаралды 200,910

Bro Code

Bro Code

3 жыл бұрын

data structures and algorithms selection sort algorithm
#selection #sort #algorithm
// selection sort = search through an array and keep track of the minimum value during
// each iteration. At the end of each iteration, we swap variables.
// Quadratic time O(n^2)
// small data set = okay
// large data set = BAD
music credits 🎼 :
===========================================================
Block Party - Bad Snacks
link: • bad snacks: KZbin Au...
===========================================================

Пікірлер: 173
@BroCodez
@BroCodez 3 жыл бұрын
public class Main{ // selection sort = search through an array and keep track of the minimum value during // each iteration. At the end of each iteration, we swap values. // Quadratic time O(n^2) // small data set = okay // large data set = BAD public static void main(String[] args) { int array[] = {8, 7, 9, 2, 3, 1, 5, 4, 6}; selectionSort(array); for(int i : array) { System.out.print(i); } } private static void selectionSort(int[] array) { for(int i = 0; i < array.length - 1; i++) { int min = i; for(int j = i + 1; j < array.length; j++) { if(array[min] > array[j]) { min = j; } } int temp = array[i]; array[i] = array[min]; array[min] = temp; } } }
@aditya_asundi
@aditya_asundi 3 жыл бұрын
u forgot to pin it =)
@joyceasante8292
@joyceasante8292 Жыл бұрын
Practicing... Ascending Order public class Main { public static void main(String[] args) { int array[] = {8,3,4,1,0,5,2,6,7}; selectionSort(array); for(int i : array){ System.out.print(i); } } public static void selectionSort(int[]array){ for(int i = 0; i < array.length - 1; i++){ int min = i; for(int j = i + 1; j array[j]){ min = j; } } int temp = array[i]; array[i] = array[min]; array[min] = temp; } } } ******************** Descending order public class Main { public static void main(String[] args) { int array[] = {8,3,4,1,0,5,2,6,7}; selectionSort(array); for(int i : array){ System.out.print(i); } } public static void selectionSort(int[]array){ for(int i = 0; i < array.length - 1; i++){ int min = i; for(int j = i + 1; j
@giorgiogiorato
@giorgiogiorato Жыл бұрын
4:35
@faizanhamza4717
@faizanhamza4717 5 ай бұрын
Half of my tension wipes away when he says sit back and relax
@adi_is_back
@adi_is_back Жыл бұрын
Studying as usual one day before a test and I was so confused on selection sort, but this video has helped me a lot! Thanks and keep up the great work!
@mykytakaida6663
@mykytakaida6663 3 жыл бұрын
Man, I wish you will become the greatest programming KZbinr in a year
@Remolhunter97
@Remolhunter97 3 жыл бұрын
He already is, he just has not enough visibility !
@solens4810
@solens4810 3 жыл бұрын
Me too, I love himmmm
@BroCodez
@BroCodez 3 жыл бұрын
Thanks guys! You are all the best! ❤️
@mrnotrobot
@mrnotrobot Жыл бұрын
@@BroCodez Thanks sir! For all the work!
@ritikbisen798
@ritikbisen798 11 ай бұрын
May your dreams come true bro 😊😊
@hridayinfovlogs
@hridayinfovlogs 9 ай бұрын
Bro,, Programming tortures me due to the bad teachers I have But u, r the best programmer and teacher U help me learn programming like it is just a childhood game. Thanks a lot !,
@j.m8480
@j.m8480 Жыл бұрын
I'm studying to become a software engineer atm... and I keep returning here time and time again for insanely good and fast introductions to pretty much ALL the concepts 🤣🤣 Bro is the master. Thank you!
@diegoortega2374
@diegoortega2374 10 ай бұрын
Thanks brother, I really liked your explanation and the effort you made to graphically show the algorithm. Cheers!
@manikantaanumalla4104
@manikantaanumalla4104 Жыл бұрын
Super visual and incredibly interesting way of learning of DS and algorithms. Bro code rocks!!!
@necothegrim3419
@necothegrim3419 7 ай бұрын
Everybody gangsta till your teacher gives sorting algorithm assignment on *linked lists with multiple variables* .
@halloheinz
@halloheinz 3 ай бұрын
A man uses paint to explain in 8 minutes an algorithm and achieves more than a professor at the university in 6 Months. Well done and thanks.
@LeoLeo-us5rs
@LeoLeo-us5rs 3 жыл бұрын
Best selection sort explanation on KZbin
@patrickmayer9218
@patrickmayer9218 8 ай бұрын
It's basically the naive way of sorting, but slightly smarter because the array gets smaller each iteration. Thanks for the video!
@nareshmangalpalli1480
@nareshmangalpalli1480 Жыл бұрын
best Explanation + nice examples = This Video
@supernovic99
@supernovic99 Жыл бұрын
Thank you so much for this video bro!!! It was really helpful
@qrinni4042
@qrinni4042 4 ай бұрын
Bro, you made this so easy to understand. Tysm
@coder4937
@coder4937 2 жыл бұрын
you are very good person who is teaching free of cost i'm glad to found this channel and n amazing person ^^
@nidarr4878
@nidarr4878 5 ай бұрын
This was really helpfull. It made selection sort a piece of cake. Thanks a lot. Outstanding video
@ShimmerBodyCream
@ShimmerBodyCream 4 ай бұрын
This is a fantastic explanation, thank you.
@JatBadmos
@JatBadmos 9 ай бұрын
love your videos bro thanks for the help 😃
@aminmoafi5148
@aminmoafi5148 11 ай бұрын
Lifesaver! Thank you!
@JorgeFerreira-dp9og
@JorgeFerreira-dp9og Жыл бұрын
Best explanation ever! Thank you
@iamfromasean705
@iamfromasean705 3 жыл бұрын
Thanks for the tutorial!
@MinecraftTestSquad
@MinecraftTestSquad 3 жыл бұрын
I'm just going to leave this comment on your most recent video for the best chance of you seeing it. You are insane. I'm going through your Python full course video atm and I'm about 3-4 hours in, and I just noticed that you have full course/crash course videos for several different programming languages and then also HTML/CSS on top of that. That's amazing. I might even poke through your Java course just to see what new things I'll learn even though I already know a pretty good bit about Java. I'll probably watch your Java swing videos since I don't know a whole bunch about swing. This channel deserves *MUCH* more attention.
@BroCodez
@BroCodez 3 жыл бұрын
Thank you MinecraftTestSquad! Yes I am a little insane 🤪
@youssofprogrammer7546
@youssofprogrammer7546 Жыл бұрын
you are amazing you are the only youtuber in whole youtube let me know this topic very very thanks
@kenanturan824
@kenanturan824 3 жыл бұрын
Hi bro. I just discovered this youtube channel so I'm happy. I learn English about for 1 years and I'll watch your videos
@BroCodez
@BroCodez 3 жыл бұрын
Thanks Kenan! I believe there's translation available if that helps
@ravishyadav7964
@ravishyadav7964 3 жыл бұрын
Just amazing how many videos you are going to upload in this data structure and algo series I want to learn a lot from you
@BroCodez
@BroCodez 3 жыл бұрын
I'm not quite sure yet. I'm planning 20+ topics for this series, there's a lot to cover
@ravishyadav7964
@ravishyadav7964 3 жыл бұрын
@@BroCodez yeah you can make it as long as you want because it is quite important series we will watch all of them
@ITATheshark
@ITATheshark 3 жыл бұрын
great job man, keep it up
@BroCodez
@BroCodez 3 жыл бұрын
Thanks Maurizio! I'll keep it up!
@sushruthkumaresan6087
@sushruthkumaresan6087 6 ай бұрын
Bro finished a 30min lesson in 8 minutes and looks like its more clearer than ever
@raihanrony1810
@raihanrony1810 3 жыл бұрын
Thanks for the visual presentation. I figured out how tk do it on my own thanks to the slide.
@BroCodez
@BroCodez 3 жыл бұрын
Thanks for watching Raihan!
@raykos4257
@raykos4257 8 ай бұрын
Woah. That was a really good video.
@Anonymationsthecoolanimator
@Anonymationsthecoolanimator 3 жыл бұрын
I have seen that many people love Bubble sort because it is easier to learn however I think Selection sort is better as it seems simpler to me other than being faster than Bubble sort.
@supernovic99
@supernovic99 9 ай бұрын
Oh my god. I completely agree. I never understood why people consider bubble sort to be easy. For me, selection and insertion sort are much easier.
@andreuz_2998
@andreuz_2998 4 ай бұрын
insertion is even better , it just make the change everytime it needs to , after studying both for hours , and practice many of examples , the conclusion was that insertion will always be better than selection.
@okeuwechue9238
@okeuwechue9238 3 ай бұрын
Bubble is extremely inefficient. Shouldn't be used in RL
@kalyankumar8629
@kalyankumar8629 2 жыл бұрын
"bro code"ur doing really great job bro!
@CSstudent_1001
@CSstudent_1001 7 ай бұрын
Great 🌸🌸🌸
@FarizAzim
@FarizAzim 8 ай бұрын
thanks bro saved my butt in class
@AnuragKumar-ce8hl
@AnuragKumar-ce8hl 3 жыл бұрын
wow , such a nice & simple explanation, Thank you so much Bro Code
@BroCodez
@BroCodez 3 жыл бұрын
You're welcome Anurag! Thanks for watching!
@abdullahalhomedna836
@abdullahalhomedna836 4 ай бұрын
Well said.
@plasmafox2568
@plasmafox2568 Жыл бұрын
Thank you bro!
@sylvanfranklin6904
@sylvanfranklin6904 3 жыл бұрын
Bro, epic graphic design on the thumbnail and explanation!
@BroCodez
@BroCodez 3 жыл бұрын
Thanks Sylvan! I've been trying to improve the thumbnails. I'm no graphic designer tho :/
@sylvanfranklin6904
@sylvanfranklin6904 3 жыл бұрын
@@BroCodez They look great
@cynthiaalvarez1346
@cynthiaalvarez1346 Жыл бұрын
bro code, your background music is great study music. Do you have a playlist?
@thestars8300
@thestars8300 8 ай бұрын
Thank you so much I have a data structure exam tomorrow I hope I will get full marks
@anonimanonim1223
@anonimanonim1223 Жыл бұрын
best videos
@MrLoser-ks2xn
@MrLoser-ks2xn Жыл бұрын
Thanks!
@Smile-ih5xf
@Smile-ih5xf 10 ай бұрын
Have the feeling he likes carrying nines around 😂
@marcosangelmedina5845
@marcosangelmedina5845 Жыл бұрын
thx bro, love you
@sungazing59
@sungazing59 Ай бұрын
Thank you bro
@eueudruadh2268
@eueudruadh2268 3 жыл бұрын
Thanks bro, i really appreciate it
@BroCodez
@BroCodez 3 жыл бұрын
You're welcome! Thanks for watching Eueud!
@heynermarquez6652
@heynermarquez6652 Жыл бұрын
Great S
@marckhycs319
@marckhycs319 3 жыл бұрын
Just got busy studying PHP for final project, here I am again studying Java😁 Big thanks😍
@BroCodez
@BroCodez 3 жыл бұрын
You're welcome Marckhycs! Thanks for watching!
@nonameiskickass1319
@nonameiskickass1319 2 жыл бұрын
Bro is really cool 🚀🚀🚀
@muhammedemad1155
@muhammedemad1155 Жыл бұрын
Thank you sir
@ShadowKnightdxrk
@ShadowKnightdxrk 4 ай бұрын
I m lucky to find his Btw im a new subascriba
@vishalratna2703
@vishalratna2703 3 жыл бұрын
Congrats for 100k
@jyotirmoydasdeep6568
@jyotirmoydasdeep6568 Жыл бұрын
You are the best
@hasanaalbaker1115
@hasanaalbaker1115 2 жыл бұрын
thanks brother
@KashifKhan-tq1um
@KashifKhan-tq1um 3 жыл бұрын
You are great Sir.
@BroCodez
@BroCodez 3 жыл бұрын
Thanks Kashif!
@amanthakur6913
@amanthakur6913 3 жыл бұрын
Amazing Explanation Bro
@BroCodez
@BroCodez 3 жыл бұрын
Thank you Aman! I'm happy to help
@aymanbou4847
@aymanbou4847 Ай бұрын
Thanks bro
@okeuwechue9238
@okeuwechue9238 3 ай бұрын
Thnx for the vid. Very clear explanation. However, it implies that the algo is caching the VALUE of the array elements when searching for the min element. That's not the case. What the algo caches is simply the INDEX of the value, so @2:02 it should cache the index value "3", not the data value "2", then use that index value to locate the corresponding data and perform the swap.
@AmNotLegend
@AmNotLegend Жыл бұрын
time complexity o[n2], space complexity o[1], it seems the same as bubble sorting
@Ben_in_4k
@Ben_in_4k Жыл бұрын
thanks bro
@TonyMalik7
@TonyMalik7 3 жыл бұрын
thankyou so much for teach me sir your all videos are the best video i was see many video of teach coding but your teaching is best in world of youtube thank you so much
@BroCodez
@BroCodez 3 жыл бұрын
Thank you for the kind words Tony! I'm happy to help!
@TonyMalik7
@TonyMalik7 3 жыл бұрын
@@BroCodez welcome sir and thank you for reply
@_max_7770
@_max_7770 3 жыл бұрын
hey @Bro Code may I ask you what shoud I learn in free time at hight school? I mean for the future job what will be the best programming language for example in the US. PS. I really appreciate you work at yt and I hope you will be very lucky in the future:)
@BroCodez
@BroCodez 3 жыл бұрын
Thanks for the support max! It really varies on what U.S. employers want so it's difficult to give a definite answer. There's a lot of overlap between languages. If you know one, a lot of what you learned transfers to another.
@piotrp4102
@piotrp4102 4 ай бұрын
Thanks
@wahidom
@wahidom 28 күн бұрын
thanks king
@jrdatutorial9862
@jrdatutorial9862 3 жыл бұрын
The best explanation
@BroCodez
@BroCodez 3 жыл бұрын
Thank you jrda!
@petrone1821
@petrone1821 3 жыл бұрын
Bro what do you think of flutter? Are we going to get any guides on it down day?
@BroCodez
@BroCodez 3 жыл бұрын
maybe! I'll likely have you all vote on future video topics once I finish JavaScript and the C-family langauges
@navjotsingh2457
@navjotsingh2457 Жыл бұрын
ty
@SpeaksYourWord
@SpeaksYourWord 8 ай бұрын
Wouldn't it be simpler if we just applied the bubble sort logic and start iterating from the end and keep swapping the smaller value to the front?
@hannibalbianchi1466
@hannibalbianchi1466 3 жыл бұрын
👍👍👍
@tbs-founder
@tbs-founder 9 ай бұрын
just the best
@piyushbarve2618
@piyushbarve2618 2 жыл бұрын
Hello, Bro. I know this course has completed but can you please add Dynamic Programming in it?
@youngo_music8089
@youngo_music8089 2 жыл бұрын
why did you use length-1 in the nested loop.
@yaverjavid
@yaverjavid 3 жыл бұрын
I created this without checking any algorithm: array = input("Enter Array *[max element: (10)^18] (Numbers Separated By Space):").split(" ") a = len(array) sorted_array = [] while a > 0: smallest = 1000000000000000000 for i in array : if(int(i)
@kindness3110
@kindness3110 2 жыл бұрын
Hey Bro! Can i ask a question? why in inner loop j = i + 1, why not just j = 1? I'm still trying to getting a hang of this
@samson-zq7gc
@samson-zq7gc 2 жыл бұрын
I think because you are not sorting the very last element in the array. Because once the first four items are sorted, you don't have to iterate through the last element in the array. There is no where else for it to go.
@augischadiegils.5109
@augischadiegils.5109 3 жыл бұрын
@chal7z
@chal7z Ай бұрын
tyyy
@buraktreaty4720
@buraktreaty4720 6 ай бұрын
Let bro cook🔥🔥🔥🔥🔥
@scarlett9921
@scarlett9921 3 ай бұрын
谢谢你
@lellal5354
@lellal5354 10 ай бұрын
holy crap its a two that quote killed me hahahaha
@Rockyzach88
@Rockyzach88 9 ай бұрын
I guess if you knew there was no repeating numbers and if the new min is 1 above it, then you don't need to search the rest of the array.
@vishalratna2703
@vishalratna2703 3 жыл бұрын
Pls make a node js tutorial
@nguyenxuanthienphu3402
@nguyenxuanthienphu3402 3 жыл бұрын
can you do networking?
@ernestosandoval7575
@ernestosandoval7575 Жыл бұрын
Why is it that at 7:10 (line 25) you defined int min = i? Why could it not be array[i] since we are focused on the element and it is the same position regardless? Also, could anyone explain to me the lines of code that go from line 32 to line 34? Thank you in advance.
@loisarcangeles3954
@loisarcangeles3954 2 жыл бұрын
Great video! but may I ask what was the point of the code temp=num[i]; num[i]=num[j]; num[j]=temp;
@vijayanks1714
@vijayanks1714 2 жыл бұрын
int a = 1; int b = 10; now u swap the two value u need one extra variable to store it temp so declare int temp; execution temp = b; //temp store 10 b=a; //now b store 1 a=temp; // in the 2nd step b value is change so need a extra variable to store the b variable before the 2nd step, that's the logic behind that
@ernestosandoval7575
@ernestosandoval7575 Жыл бұрын
@@vijayanks1714 Why is outer loop arraylength - 1? Instead of just being arraylength?
@yon1623
@yon1623 Жыл бұрын
int min = 1 i; on line 25. i goes from 0 to length of array-1 . how does that help?
@aar7790
@aar7790 3 жыл бұрын
thank u bro
@BroCodez
@BroCodez 3 жыл бұрын
Thanks for watching AAR!
@harshalpatel3774
@harshalpatel3774 2 жыл бұрын
comic sans intro
@w3jd4n
@w3jd4n Жыл бұрын
i don't even need an explanation atp i watch your videosjust for fun after studying
@ernestosandoval7575
@ernestosandoval7575 Жыл бұрын
Why is it that at 7:10 (line 25) he defined int min = i? Why could it not be array[i] since we are focused on the element and it is the same position regardless? Also, could you explain to me the lines of code that go from line 32 to line 34? Thank you in advance.
@w3jd4n
@w3jd4n Жыл бұрын
​@@ernestosandoval7575 we declare the index only so it's easy to work with indexes when we want to traverse through the array
@w3jd4n
@w3jd4n Жыл бұрын
@@ernestosandoval7575 we have 9 elements, outer for loop compares the first 8 elements with the inner loop/last 8 elements. we compare i with j and if i is bigger than j, we swap i with j using the help of the two variables, min & temp
@w3jd4n
@w3jd4n Жыл бұрын
@@ernestosandoval7575 btw we use min variable so we don't lose the reference of i if you're wondering why not just directly use i
@baubaudinamo
@baubaudinamo 3 жыл бұрын
thx bro
@BroCodez
@BroCodez 3 жыл бұрын
you're welcome Alex! Thanks for watching and commenting!
@saisaketh23
@saisaketh23 3 жыл бұрын
Hey Bro Code love ur videos
@BroCodez
@BroCodez 3 жыл бұрын
Thank you Sai!
@mikhailsandigan1424
@mikhailsandigan1424 3 жыл бұрын
What software are you using for your explanation?
@BroCodez
@BroCodez 3 жыл бұрын
Paint.net I'm not skilled with animations, but I'm decent with my photoshop skillz
@mikhailsandigan1424
@mikhailsandigan1424 3 жыл бұрын
@@BroCodez thank you bro, you are an inspiration!
@yon1623
@yon1623 Жыл бұрын
I dont understand the code. but atlist i have the code for the homework.
@GrittyMaholmes
@GrittyMaholmes 3 жыл бұрын
what are your c specs
@nevilleodhiambo1370
@nevilleodhiambo1370 Жыл бұрын
how are you printing the result am running the same code as you but it just print the first unsorted array...please help
@khajazulfiqaar43
@khajazulfiqaar43 Жыл бұрын
🥲 thanks🌹
@toxiclucien8168
@toxiclucien8168 2 жыл бұрын
pog
@VictoriaLaRocque
@VictoriaLaRocque Жыл бұрын
nice voice :)
@deadvision22
@deadvision22 Жыл бұрын
Omg
@lemmgua
@lemmgua Жыл бұрын
HOLY CRAP IT'S A TWO
@weirdchamp7790
@weirdchamp7790 Жыл бұрын
Chad programmer
Learn Insertion Sort in 7 minutes 🧩
7:05
Bro Code
Рет қаралды 182 М.
Learn Merge Sort in 13 minutes 🔪
13:45
Bro Code
Рет қаралды 258 М.
100❤️
00:20
Nonomen ノノメン
Рет қаралды 73 МЛН
Please be kind🙏
00:34
ISSEI / いっせい
Рет қаралды 66 МЛН
В ДЕТСТВЕ СТРОИШЬ ДОМ ПОД СТОЛОМ
00:17
SIDELNIKOVVV
Рет қаралды 4 МЛН
How to bring sweets anywhere 😋🍰🍫
00:32
TooTool
Рет қаралды 50 МЛН
Learn Hash Tables in 13 minutes #️⃣
13:26
Bro Code
Рет қаралды 318 М.
Selection Sort Tutorial in Java: The Snail's Guide to Sorting
14:17
Coding with John
Рет қаралды 48 М.
7.5 Selection Sort in Data Structure | Selection Sort Algorithm with C Program
17:49
Jenny's Lectures CS IT
Рет қаралды 1,3 МЛН
Learn Bubble Sort in 7 minutes 🤿
7:44
Bro Code
Рет қаралды 214 М.
Java Program #21 - Sort Numbers using Bubble Sort in Java
8:03
Programming For Beginners
Рет қаралды 36 М.
Selection sort algorithm
10:18
mycodeschool
Рет қаралды 1,2 МЛН
Learn Quick Sort in 13 minutes ⚡
13:49
Bro Code
Рет қаралды 289 М.
every good programmer should know how to code this data structure (its easy)
21:08
Introduction to Selection Sort
10:56
Lalitha Natraj
Рет қаралды 208 М.
Selection Sort In Python Explained (With Example And Code)
8:27
FelixTechTips
Рет қаралды 55 М.
One To Three USB Convert
0:42
Edit Zone 1.8M views
Рет қаралды 440 М.
APPLE совершила РЕВОЛЮЦИЮ!
0:39
ÉЖИ АКСЁНОВ
Рет қаралды 1,6 МЛН
Apple watch hidden camera
0:34
_vector_
Рет қаралды 63 МЛН
Девушка и AirPods Max 😳
0:59
ОТЛИЧНИКИ
Рет қаралды 17 М.