Hello everyone, it's been a while since i've been on here!
Anyways, I'm having one heck of a time with a doubly linked list; specifically reversing the linked list. Here's what I have
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
template<typename T> // TODO
void DLinkedList<T>::RevList()
{
Node<T>* Tfirst = first; // creates new node pointer type called Tfirst which is set to the first node
Node<T>* Tlast = last; // creates new node pointer type called Tlast and sets to the last node
Node<T>* TempC = 0; // creates new node pointer type called TempC and sets its value to zero
if (Tfirst == Tlast){ // if first is equal to last
return; // just return
}
if (Tlast == NULL || Tfirst == NULL) { // if First or Last are NULL
return; // just return
|
without posting all of the code; I'm able to pass 2 of my 4 cases (both are for instances of an empty node and one where the first forward is equal to the last backward
I just need some help understanding how to traverse the list and swap the info/values for each node.
an example would be if i have 5 nodes and each of their info is {1,2,3,4,5} I want to switch them to {5,4,3,2,1}
I hope I explain what I can without giving out my code. I'm not asking for handout, just some understanding