Difficulty with C++

Status
Not open for further replies.
It's slower, but ideally you will iterate through the container to see if the element has already been stored before putting the same one in there twice.

When you get into Data Structures you'll learn how to greatly optimize that sort of thing through employing more efficient storage/retrieval methods. But that's a topic for later.
 
Actually, I discovered a method so simple it's almost cheap. I just dumped the vector into a set, then dumped the set back into the vector. Not only did the repeats not survive the round trip, my list ended up alphabetized!
 
A new problem has cropped up. I am working with different sorting techniques, and I'm having problems with a quicksort algorithm. I am trying to figure out how to reverse it (so that it sorts in ascending order, not descending order), but I just don't know where to begin.

Note that "top" and "bottom" are actually misnomers; they mean the opposite of what their names imply. Top is the beginning of the array, and bottom is the end of the array. I plan to fix this once the code actually works the way I want it to.


Never mind. Fixed.

Well, that was pretty much my final hurdle for C++ homework...this semester, anyway. In the spring, I'm taking the follow-up course, which is said to be much more advanced, abstract, and labor-intensive.
 
Last edited:
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top