I am doing pset 3 tideman.
For this I first implemented mergesort recursively. Then, to adjust it to the problem, I introduced a new part of the pair data structure, margin, and adjusted my mergesort to look at each pair's .margin.
(i had to look ahead at a video on pointers, because I first tried to implement mergesort and kept getting segmentation faults)
However, I don't quite understand how memory allocation works for your own data structs.
If I have data type, say pair as described above, I can create an array of three pairs. When I use the pointer to the first element, I can use +1 on the pointer to access the next memory slot. But somehow this next memory slot contains all three parts of my type pair (it contains the .winner .loser and .margin), when each of these is of type int and I would have thought required their own slot in memory each? Maybe I am misunderstanding how memory is labelled?
pair arr[3];
pair *my_pointer = &arr[0];
printf("%i", (*(my_pointer + 1)).margin); //the second element of arr is of type pair, and its margin is printed