Insertion Sort | C++ Example

  Рет қаралды 30,079

Portfolio Courses

Portfolio Courses

Күн бұрын

Пікірлер: 49
@MetalWhale.
@MetalWhale. Жыл бұрын
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
@ShyamKumar-cn9hb Жыл бұрын
best explanation of code ever
@PortfolioCourses
@PortfolioCourses Жыл бұрын
I'm glad you enjoyed it! :-)
@more-uv4nl
@more-uv4nl 9 ай бұрын
amazing explanation
@yuripanosyan5267
@yuripanosyan5267 Жыл бұрын
Sir, your explanation is clearer than the God's soul!! Thanks!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're welcome Yuri, I'm glad you enjoyed it! :-)
@musabakhtar393
@musabakhtar393 8 ай бұрын
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
@tungno7 Жыл бұрын
easy to understand, thanks!
@yaseries2004
@yaseries2004 Жыл бұрын
Thank you so much love you my dear sir,💐💐💐
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Aww you’re welcome! :-)
@yaseries2004
@yaseries2004 Жыл бұрын
@@PortfolioCourses can I know that where are you from
@PortfolioCourses
@PortfolioCourses Жыл бұрын
@@yaseries2004 I am from Canada. 🙂
@yaseries2004
@yaseries2004 Жыл бұрын
Thank you for reading my comments
@yaseries2004
@yaseries2004 Жыл бұрын
You look like Henry Cavill 🤔
@default2043
@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
@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.
@t6hp
@t6hp 11 ай бұрын
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
@Megha-sb2vu Жыл бұрын
The example helped alot and cleared the concept even more!! Tysm 🪄
@PortfolioCourses
@PortfolioCourses Жыл бұрын
I'm glad it was helpful for you, and you're very welcome! :-)
@gerdsfargen6687
@gerdsfargen6687 Жыл бұрын
No way! Was just doing in Java. Mind reader!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Hahaha I think it's that time of year for insertion sort! :-)
@gerdsfargen6687
@gerdsfargen6687 Жыл бұрын
@@PortfolioCourses you just reminded me of Bugs Bunny and Daffy Duck. "Insertion Season! " "Bubble Season"....fire!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
😂
@yoruichi5802
@yoruichi5802 Жыл бұрын
Exact same here lol
@jaderose2886
@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
@PortfolioCourses Жыл бұрын
Thanks Jade! :-) That's something I want to cover more of one day, in particular creating processes in C.
@FritsvanDoorn
@FritsvanDoorn Жыл бұрын
Thank you
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're very welcome Frits! :-)
@edensparkish
@edensparkish Жыл бұрын
Thank you!!!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're very welcome! :-)
@jonluis2647
@jonluis2647 7 ай бұрын
Best one out there👌🏼👌🏼👌🏼🫡🫡🫡🙏🙏🙏🙏
@PortfolioCourses
@PortfolioCourses 7 ай бұрын
I’m glad you enjoyed it! :-)
@KrumRashkov
@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
@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
@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.
@t6hp
@t6hp 11 ай бұрын
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
@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
@PortfolioCourses Жыл бұрын
i = i++ is undefined behaviour in C, this answer explains better than I would be able to: stackoverflow.com/a/26895433. :-)
@4O8
@4O8 Жыл бұрын
the sorting start from the leftside or rightside?
@cseb-kathirvel2674
@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
@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
@cseb-kathirvel2674 Жыл бұрын
Sir your instagram I'd
@cseb-kathirvel2674
@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
@cseb-kathirvel2674 Жыл бұрын
@@PortfolioCourses user input in sertion sort in 2d string in c upload this program and explain it
@shashwatmishra4974
@shashwatmishra4974 8 ай бұрын
Time and space complexity anyone please ?
@shia9101
@shia9101 Жыл бұрын
is there a pseudocode of this sir?
@PortfolioCourses
@PortfolioCourses Жыл бұрын
There is a link to the C++ code in the video description, that might be helpful? :-)
@touristofsongs4946
@touristofsongs4946 Жыл бұрын
I dont get a shit from this.
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Sorry to hear that!
Selection Sort | C++ Example
9:49
Portfolio Courses
Рет қаралды 31 М.
Quicksort | C++ Example
26:50
Portfolio Courses
Рет қаралды 8 М.
Random Emoji Beatbox Challenge #beatbox #tiktok
00:47
BeatboxJCOP
Рет қаралды 63 МЛН
When Cucumbers Meet PVC Pipe The Results Are Wild! 🤭
00:44
Crafty Buddy
Рет қаралды 10 МЛН
2.7.2.  Merge Sort Algorithm
24:07
Abdul Bari
Рет қаралды 1,7 МЛН
Bubble Sort | C++ Example
13:20
Portfolio Courses
Рет қаралды 29 М.
Insertion Sort Algorithm Made Simple [Sorting Algorithms]
8:26
Programming with Mosh
Рет қаралды 307 М.
Insertion Sort | Logical Programming in C | Naresh IT
9:20
Naresh i Technologies
Рет қаралды 359 М.
Insertion sort algorithm
14:15
mycodeschool
Рет қаралды 1,5 МЛН
Selection Sort | C Programming Example
8:00
Portfolio Courses
Рет қаралды 60 М.
you will never ask about pointers again after watching this video
8:03
7.5 Selection Sort in Data Structure | Selection Sort Algorithm with C Program
17:49
Jenny's Lectures CS IT
Рет қаралды 1,4 МЛН
Learn Insertion Sort in 7 minutes 🧩
7:05
Bro Code
Рет қаралды 245 М.
Random Emoji Beatbox Challenge #beatbox #tiktok
00:47
BeatboxJCOP
Рет қаралды 63 МЛН