0

I have a class named Contestant which holds all the info on a person playing a game. Then I have a game class for all the different games a contestant could be playing. My linked list in the game class is defined by the contestant class. I need to swap two players positions recursively in my linked list. I am given the member prototype as:

SwapContestantsR(string first_name_one, string last_name_one, string first_name_two, string last_name_two, ListNode* &node, ListNode** contestant_one, ListNode** contestant_two)

I understand I have two base cases. One, if I find both contestants, then swap. Two, if node=NULL then I have reached the end of my linked list and no contestant by either name exists. Otherwise I recurse by moving to the next node. I complete lost with the implementation and any help would be great.

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Lerner
0

I'm not sure of your exact task, nor whether the function prototype is written in stone.

Based on my (admittedly limited) understanding of your project I'd break it up into (at least three) separate tasks---searching the list for the names, swap the names if both are found (or stopping if they aren't), and then develop a recursive approach to the process (if needed). I'd work on them in that order, only proceeding when I've completed the earlier task.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.