I’m trying to use insertion sort on a pointer structure and I’m working with a very simple structure with only one element, but I’m kinda following the logic of an insertion sort using variables like cha or int… so it isn’t really working well… Could someone help me pls
What I mean is just that instead of for example printing Pessoas.nome, I do it like Pessoas->nome and I think that affects how I create the rest of the function… since i have *Pessoas… I’m not sure how it changes the way i should write the fuction tho
It kind of looks like you are doing a bubble sort, not a selection sort? (Bubble sort is when you compare two values and switch them around if they are not in the relevant sort order).
Selection sort is when you search for the smallest item and “select it” to put it in the first location, then ignore that item to redo the steps for selection over the remaining items.
In both sorts you have to repeatedly read through the list over and over to gradually sort it. (For selection sort you would do subsequent iterations over the unworried portion only).