Amazing! The commented example allowed me to finally understand the algorithm. I've watched several videos, read through my textbook, and this example is by far the best illustration of an insertion sort. Thanks.
@ShyamKumar-cn9hb Жыл бұрын
best explanation of code ever
@PortfolioCourses Жыл бұрын
I'm glad you enjoyed it! :-)
@more-uv4nl9 ай бұрын
amazing explanation
@yuripanosyan5267 Жыл бұрын
Sir, your explanation is clearer than the God's soul!! Thanks!
@PortfolioCourses Жыл бұрын
You're welcome Yuri, I'm glad you enjoyed it! :-)
@musabakhtar3938 ай бұрын
can someone please explain the while loop area, like what is in a[ j ] or what is stored in it because I cant seem understand the whole loop specially a [ j ] and a[ j + 1 ]
@tungno7 Жыл бұрын
easy to understand, thanks!
@yaseries2004 Жыл бұрын
Thank you so much love you my dear sir,💐💐💐
@PortfolioCourses Жыл бұрын
Aww you’re welcome! :-)
@yaseries2004 Жыл бұрын
@@PortfolioCourses can I know that where are you from
@PortfolioCourses Жыл бұрын
@@yaseries2004 I am from Canada. 🙂
@yaseries2004 Жыл бұрын
Thank you for reading my comments
@yaseries2004 Жыл бұрын
You look like Henry Cavill 🤔
@default2043 Жыл бұрын
Very nice video! If I want to perform insertion sort in reveres order, then I need to switch "a[j] > key" to "a[j] < key", but unfortunately I will get a segmentation fault this way. Any ideas why this is and how to solve it?
@Roq-stone Жыл бұрын
In the for loop, to print, put i = 7 with i >=0, then decrement i (i-) This will reverse the array numbers. There you go. Sorted.
@t6hp11 ай бұрын
it's likely not due to the comparison operation (a[j] < key), but rather an issue elsewhere in your code that is causing out-of-bounds memory access. The switch in the comparison operator is indeed the correct approach to sort in descending order. Ensure that your loop indices do not cause you to access the array out of its bounds. This could happen if ScannerIndex goes below 0 and you still try to access arr[j].
@Megha-sb2vu Жыл бұрын
The example helped alot and cleared the concept even more!! Tysm 🪄
@PortfolioCourses Жыл бұрын
I'm glad it was helpful for you, and you're very welcome! :-)
@gerdsfargen6687 Жыл бұрын
No way! Was just doing in Java. Mind reader!
@PortfolioCourses Жыл бұрын
Hahaha I think it's that time of year for insertion sort! :-)
@gerdsfargen6687 Жыл бұрын
@@PortfolioCourses you just reminded me of Bugs Bunny and Daffy Duck. "Insertion Season! " "Bubble Season"....fire!
@PortfolioCourses Жыл бұрын
😂
@yoruichi5802 Жыл бұрын
Exact same here lol
@jaderose2886 Жыл бұрын
I love ur vids, but I think it would be really cool if you did some operating system content. Like how to create processes and all tht kinda stuff
@PortfolioCourses Жыл бұрын
Thanks Jade! :-) That's something I want to cover more of one day, in particular creating processes in C.
@FritsvanDoorn Жыл бұрын
Thank you
@PortfolioCourses Жыл бұрын
You're very welcome Frits! :-)
@edensparkish Жыл бұрын
Thank you!!!
@PortfolioCourses Жыл бұрын
You're very welcome! :-)
@jonluis26477 ай бұрын
Best one out there👌🏼👌🏼👌🏼🫡🫡🫡🙏🙏🙏🙏
@PortfolioCourses7 ай бұрын
I’m glad you enjoyed it! :-)
@KrumRashkov Жыл бұрын
I love your videos and you are a really big help with all c and c++ related topics, thank you for putting out this amazing content. However, I was wondering if you can help me with a task given by my university. I have to make an insertion sort that performs the "descent" with an anchor. This means placing the inserted element at the "bottom" of the array to save from the "descend" end condition. Do you happen to have any idea how this could be done?
@PortfolioCourses Жыл бұрын
I'm really glad you enjoy the videos Krum, thank you for sharing that positive feedback! :-) I'm not sure I understand the question and what the anchor would be doing in the algorithm though. Do you have the question text? Was ChatGPT or Google helpful?
@KrumRashkov Жыл бұрын
@@PortfolioCourses hey thanks for the fast reply actually i tried running the question on gpt and phind and I also consulted with some people and no one including me seemed to understand what exactly is the question so I will ask the teacher. Thanks for reaching out though.
@t6hp11 ай бұрын
I think the question is just poorly formulated by the Professor, but what's being asked here is a reverse insertion sort, if I understood correctly. The anchor here is what Kevin refers to as the key, or the element being compared to all previous elements. You really change bigger than > to less than = 0) && (arr[ScannerIndex] < anchor); ScannerIndex--) { // Move the scanned element one position to the right to make space for the anchor arr[ScannerIndex + 1] = arr[ScannerIndex]; } // Once the correct position is found or the start of the array is reached, // insert the anchor. The ScannerIndex would have moved one place left of the // insertion point, so we need to insert at ScannerIndex + 1 arr[ScannerIndex + 1] = anchor; } }
@ramakrishna4092 Жыл бұрын
Hi sir I have one doubt in post increment in c Int a=10; a= a++ ; If I print the value of a the output will be 11 right but why the output is 10 can you pls explain this Thank you..
@PortfolioCourses Жыл бұрын
i = i++ is undefined behaviour in C, this answer explains better than I would be able to: stackoverflow.com/a/26895433. :-)
@4O8 Жыл бұрын
the sorting start from the leftside or rightside?
@cseb-kathirvel2674 Жыл бұрын
Insertion sort in 2d string is it possible,pls try this program and c program for all types of errors pls upload the program
@PortfolioCourses Жыл бұрын
I'm curious what you mean by "all types of errors" Kathir? :-) Can you explain more about what types of errors you would be interested in seeing covered? Compiler errors? Or other types of errors that occur at runtime?
@cseb-kathirvel2674 Жыл бұрын
Sir your instagram I'd
@cseb-kathirvel2674 Жыл бұрын
@@PortfolioCourseshow to all compile errors and runtime errors in c pls upload video ,Why I am asking this question?This question was very important for college students.even I write a own program that time large numbers errors coming ,that errors why coming? how to solve the error?
@cseb-kathirvel2674 Жыл бұрын
@@PortfolioCourses user input in sertion sort in 2d string in c upload this program and explain it
@shashwatmishra49748 ай бұрын
Time and space complexity anyone please ?
@shia9101 Жыл бұрын
is there a pseudocode of this sir?
@PortfolioCourses Жыл бұрын
There is a link to the C++ code in the video description, that might be helpful? :-)