@@motivationwithhb5035 Time complexity usually: Best case for insertion is O(n) compared to Selection sort O(n^2). ie time it take for a computer to run calculations
And it took me 2 hours to understand basic insertion sort not even a single person actually talk about temp everyone was just saying that place in the correct order, and this man taught me in 1 minute
I think this is a good description of insertion sort: The full insertion sort algorithm works by dividing an array into two pieces, a sorted region on the left and an unsorted region on the right. Then, by repeatedly inserting elements from the unsorted half into the sorted half, the algorithm eventually produces a fully sorted array. The full steps of this process for an array, A, are shown below - Designate the leftmost element of *A* as the only element of the sorted side. This side is guaranteed to be sorted by default, since it now contains only one element. - Insert the first element of the unsorted side into the correct place in the sorted side, increasing the number of sorted elements by one. - Repeat step two until there are no unsorted elements left. Notice that this method doesn’t require us to create a new array to store the sorted values. All we have to do is keep track of how much of the original array is sorted. This makes insertion sort an in-place algorithm.
Omg bro you are awesome. You're a natural teacher thank you for the awesome content you really help me with my programming subject. God I wish I had teachers like you.
OMG, yes! My favorite programming channel transformed into an even better one! Love your content, it really really helped me a lot in my studies and with my projects as well! Keep up the good work, you are awesome! Quality content at it's finest! ;)
Thanks for the explanation I have been taking classes at uni about this topic but my teacher hasn't been able to explained right. Thanks for the content. It was so helpful.
Hello bro, just wanted to say congratulations on reaching 100,000 subscribers 😁 (I am glad I stumbled across this channel when I did, your tutorial playlists are the best on youtube)
@@BroCodez 😂 I've been working through my college courses, and only now did I start learning Java Spring. (btw, your DS and algorithm videos have been very helpful so thank you and please continue the good work 😊)
Hey bro 1 request please continue your series on dsa,your explaination is so good that even toughest question can be understood in 1 go.Please its a humble request
@@BroCodez OMG You commented! I Just wanted to say thanks you for making these amazing courses for free! I hope the YT algorithm will help you reach 1 million soon!
@@BroCodez ... You know it Bro, I like the way You do it! I don't know You or Your way of life ... but I know only this one, the hunger for the next one!!! Waitin' for more Bro!!!
would this also be a valid solution: private static void insertionSort(int[] array) { for(int i=1; i < array.length ; i++){ int temp = i; for(int j=0; j < i; j++){ if(temp
@@BroCodez oh, but what if I need my jlabels to have a mouse listener? Currently I have set an icon to my jlabels and can’t rotate them. If I instead use a graphic, will I even be able to use a jlabel, much less have it be clickable? Thanks for your time
look at how much your channel grew, remembering when I came you were under 1k subs. Tho you definetlly deserve and earned them bro, you are literally the best programming tutoring channel I know of! Thank you for this amazing content bro!
public class Main{
// Insertion sort = after comparing elements to the left,
// shift elements to the right to make room to insert a value
// Quadratic time O(n^2)
// small data set = decent
// large data set = BAD
// Less steps than Bubble sort
// Best case is O(n) compared to Selection sort O(n^2)
public static void main(String[] args) {
int array[] = {9, 1, 8, 2, 7, 3, 6, 5, 4};
insertionSort(array);
for(int i : array) {
System.out.print(i + " ");
}
}
private static void insertionSort(int[] array) {
for(int i = 1; i < array.length; i++) {
int temp = array[i];
int j = i - 1;
while(j >= 0 && array[j] > temp) {
array[j + 1] = array[j];
j--;
}
array[j + 1] = temp;
}
}
}
Practicing...
public class Main
{
public static void main(String[] args) {
int array[] = {5,1,4,9,3,7,2,8,6};
insertionSort(array);
for(int i : array){
System.out.print(i + " ");
}
}
public static void insertionSort(int[]array){
for(int i = 1; i < array.length; i++){
int temp = array[i];
int j = i - 1;
while(j >= 0 && array[j] > temp){
array[j+1] = array[j];
j--;
}
array[j+1] = temp;
}
}
}
What are the avantages of insertion sort
@@motivationwithhb5035 Time complexity usually: Best case for insertion is O(n) compared to Selection sort O(n^2). ie time it take for a computer to run calculations
This finally made insertion sort click for me (i have a test tomorrow, pray for me brothers)
How did it went?
@@taminofink677 i got a max grade.
I have my AP exam in 2 weeks
@@kazianup4480 sending luck, have mine wednesday.
Same bro
And it took me 2 hours to understand basic insertion sort not even a single person actually talk about temp everyone was just saying that place in the correct order, and this man taught me in 1 minute
I think this is a good description of insertion sort:
The full insertion sort algorithm works by dividing an array into two pieces, a sorted region on the left and an unsorted region on the right. Then, by repeatedly inserting elements from the unsorted half into the sorted half, the algorithm eventually produces a fully sorted array. The full steps of this process for an array, A, are shown below
- Designate the leftmost element of *A* as the only element of the sorted side. This side is guaranteed to be sorted by default, since it now contains only one element.
- Insert the first element of the unsorted side into the correct place in the sorted side, increasing the number of sorted elements by one.
- Repeat step two until there are no unsorted elements left.
Notice that this method doesn’t require us to create a new array to store the sorted values. All we have to do is keep track of how much of the original array is sorted. This makes insertion sort an in-place algorithm.
Congrats on the 100k !!!! I remember subscribing to you at 15k.
Thank you A&A! It's been one heck of a ride!
2023 1.0M subs🎉
1.02 M subs nice 🔥🔥
1.13 m
1.41 M 🎉
you are my god of programming thank you bro love from india, you are genius
bro is single handedly the reason I am clutching this class on my own, god bless your soul😅🙏🏾
Great explanation!!! You explain by showing what exactly happens -- that's why it makes so much sense :)
You are best my dear sir 🙌
Omg bro you are awesome. You're a natural teacher thank you for the awesome content you really help me with my programming subject. God I wish I had teachers like you.
Thank you for the kind words Linux!
@@BroCodez no problem!
OMG, yes! My favorite programming channel transformed into an even better one! Love your content, it really really helped me a lot in my studies and with my projects as well! Keep up the good work, you are awesome! Quality content at it's finest! ;)
Thank you! Hopefully this channel will continue to evolve in the future!
doing the gods work fr fr
Thanks for the explanation I have been taking classes at uni about this topic but my teacher hasn't been able to explained right. Thanks for the content. It was so helpful.
Please never stop upload waiting for your complete course on data structures and algorithms
Thanks! I don't plan on stopping anytime soon 👍
This is the best explanation I found in TH-cam. Thanks!
"How about a 9 and a 1 and an 8" really got me smiling and singing it for the rest of the video!!
This man is a legend!!!!
🔥this guy video >>>> my 49$ DSA course
Thank you so much for making this video and also the other tutorials for algorithms! Great help!
Thank you bro! It is a pleasure to see your tutorials! You are my source of inspiration and learning! Keep up!
Thanks for the support skin!
great tutorial! is there a reason we do j-- inside while loop and then use the [j+1] index instead of just removing the j-- and using the j index?
Passing my GCSES with this one 🔥
This was what I was waiting for.
nice!
Hey man, just wanted to say, keep up the good work, ur videos have been helping me a lot this sem for data structures, thank you 😎
Thanks for watching Rauf! It's motivating to me when they're helping people!
Brocode rockzz❤thanks to youtube's algorithm for suggesting this channel.
The way I subscribed immediately is crazy
Hello bro, just wanted to say congratulations on reaching 100,000 subscribers 😁
(I am glad I stumbled across this channel when I did, your tutorial playlists are the best on youtube)
Thank you Rew Rose! I remember you from early days of this channel lol
Thank you for sticking around since then!
@@BroCodez 😂 I've been working through my college courses, and only now did I start learning Java Spring.
(btw, your DS and algorithm videos have been very helpful so thank you and please continue the good work 😊)
Hey man, Im from Vietnam
Just came accross your channel and really like it!
Thank you very much👍💪
CONGRATS ON REACHING 100K SUBS!!!! YOU ARE THE BEST, BRO!!!
Thank you Brucc! I owe you guys for getting me here!
Hey bro 1 request please continue your series on dsa,your explaination is so good that even toughest question can be understood in 1 go.Please its a humble request
This is the best video so far on the Insertion sort :)
Your explanations are the best , glad i found your channel 🎉
I love you this is amazing and so quick and simple
What are the avantages of insertion sort
This was such nice explanation! Thank you!
SOOOOOOOO Close to 100k
TH-cam button on your way!
Thanks Ethan!
@@BroCodez YOU DID IT!!!!
@@BroCodez NP!
This was really useful. Thanks!
congrats for reaching 100k!!
Thank you Muhammad! I owe you guys for getting me here!
Man you're a legend, no joke !
You are right dude
Thank you Engima! I will try and live up to that title!
it's generally so overwhelming to do dsa but istg you made it so easy and the concept crystal clear😌👍
DS & A is intimidating.
Thank you for the kind words artsyjaa!
thank you much sir it is help full
You're welcome Tony! Thanks for watching!
Thanks a million. This video is a life saver!♥
Learnt in 7 minutes,THALA FOR A REASON
Come on, seriously bro...😂
Thanks for the video man, really great explanation
Thanks!
best explanation easy.
I hope that you will continue making this for all sorting algorithms there is.
I hope to
Your Content and code is AWESOME brother
Keep it up
Thank you anonymous!
THANK YOU
Thanks, man
You're awesome!
Thanks nozzi!
Yooo ur so close to 100k :000
We made it!!
I commented to boost the algorithm!
Thank you Syllight!
@@BroCodez OMG You commented!
I Just wanted to say thanks you for making these amazing courses for free!
I hope the YT algorithm will help you reach 1 million soon!
@@syllight9053 We'll get there sooner than later! Thanks for being awesome Syllight!
great vid
Great video
Damn this was so easy
thx for this
Congratulations on 100k🙌🙌
Thank you Sheikh! I couldn't have done it without your support!
Love you, ❤
Thanks 👍🏽
Please cover, Heap sort
At 3:27 how did sysout become system.out.println
Pl tell
but if you will understand code + animation then it will be better for us
sweeet
Yo bro, just wanna ask are you gonna drop C language videos anytime soon, wanna refresh my concepts of C that's all
I'm not sure when exactly, but I do plan on releasing C videos sometime in the future
@@BroCodez keep it up bro 👍👍
صحا حمزة
this is a siwon moment !
what did the last line array[j+1]=temp do?
Bro, 100k !!! ... why it's silence on the channel? May be it's error 404 😜
XD
Thank you Tomasz! I've been replying whenever I can lol!
@@BroCodez ... You know it Bro, I like the way You do it! I don't know You or Your way of life ... but I know only this one, the hunger for the next one!!! Waitin' for more Bro!!!
No Dis Likes For This Legend With About 4K Views.
you're op
Gold
Thank you for these epic educational videos. You explain it super clear 💯
You're welcome B N! Thanks for watching!
10k likes and all respect
thank you!
imparator 👑👑
100k special = pls do a c course
I will sometime! Don't worry lol
Thank you sir it's a wonderful channel may I ask you if you can make Django course
I hope to someday!
@@BroCodez plz do I can't understand other Django courses.
👍
would this also be a valid solution:
private static void insertionSort(int[] array) {
for(int i=1; i < array.length ; i++){
int temp = i;
for(int j=0; j < i; j++){
if(temp
soo, bubble sort in reverse?
Can you make Multiplication table using arraylist 2D array?
yes
@@BroCodez thank you!
Bro
Vehan
Bro can you make video on recursion ?
I plan to
random comment for the algorithm
100K soon...
very soon...
@@BroCodez Waiting for nuclear laucnh code
"Random comment" just for the algorithm
Hello will you tell me from where we can practice for our code mean how to build our logic ?? 🙏🙏Plz tell
Tutorials Point has an online compiler you can use to practice, here's the link:
www.tutorialspoint.com/compile_java_online.php
@@BroCodez no means practice questions or problems where I can find.
No means where I can find the practice questions or problems ??
I can't find the practice questions
@@niksddd codewars.com or brilliant.org
how about radix sort?
that's a good topic idea!
Hey bro !
yooooo Jayson!
How do you rotate jlabels?
something like this might work
public void paintComponent(Graphics g) {
Graphics2D gx = (Graphics2D) g;
gx.rotate(0.6, getX() + getWidth()/2, getY() + getHeight()/2);
super.paintComponent(g);
}
@@BroCodez oh, but what if I need my jlabels to have a mouse listener? Currently I have set an icon to my jlabels and can’t rotate them. If I instead use a graphic, will I even be able to use a jlabel, much less have it be clickable? Thanks for your time
❤
Lol can you make a java game dev series?
Not a bad idea
@@BroCodez thx if you make one! Would love it!
ramdom comment
subs:99.9k almost 100k
We did it!!!
@@BroCodez hell yeah congrats
SUIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII!!!!!!!!!!!!!!!!!!!!!!
throw new randomComment
hiiiii
Hi Qwikz!
PYTHON IS THE BEST PROGRAMMING LANGUAGE U R A BOT
bro why didnt yuh covered the Heap sort🥲
Man I can not explain how much I love and appreciate the work you do on this channel.
Hello can you please make videos on this topics.
1. Dynamic Programming
2. Backtracking
look at how much your channel grew, remembering when I came you were under 1k subs.
Tho you definetlly deserve and earned them bro, you are literally the best programming tutoring channel I know of! Thank you for this amazing content bro!
Thank you for the kind words Max! I'm glad you've been here since the era of 1k!