r/cs2a • u/Cameron_K4102 • Apr 17 '25
platypus Progress Report 8/9
Finished blue quest 8 yesterday and finally finished blue quest 9 today. Understanding the concept behind blue quest 9 was a slow burn for me, never once did it just "click" all at once. My advice is to just sit down with a pen and paper, and draw out example lists. I drew a square for my _SENTINEL_ node, solid dots for any "real" nodes, and an open circle for the nullptr at the end of the list. Start with an empty node (so just _SENTINEL_ and nullptr) and then make a list below it with one node, so in order: {_SENTINEL_, new_node, and nullptr}. Keep track of the _head, _tail, and _prev_to_current members and also use a different color pen to draw lines showing which nodes point to which nodes as their "next" member. When it came time to make the implementations for certain member functions, I would go back to drawing out example lists on paper to try to visualize I was doing. I wish I'd done the drawings sooner, I brute-forced my way through the first couple functions by picturing it all in my head and testing it thoroughly (though not always thoroughly enough) in main. Drawing things out made it a lot simpler.
My first couple submissions didn't work, and I would find myself making a lot of assignment and check errors in my code. When I needed to update the value of say _tail to something, I would occasionally mess up and assign the value of that something to _tail. I caught a few instances of me using "=" when I should have been using "==". If you're getting errors or unintended results in your code, check for these things. You wouldn't want to rewrite the entire code for your function, thinking you had the wrong general idea when all you had to do was change "=" to "==" or "if (this == that) {}" to "if (that == this) {}."