Reversing Doublely Linked Deque in C -


I'm having trouble reverting to double linked deck list (only with one back senile) in C, I I'm passing this switch by pointers and even the code I have done so far:

  / * deck the ultimate reverse: q pointer in deck pre: q is not empty And q is not empty post: Deck has been reversed * / / * Reverse Cyrillicist Dick * / Zero Reverse CyrillistDec (Circuit Summary St * Q) {struct DLink * back = q- & gt; BackSentinel; Struct DLink * seconds = q- & gt; Backstentine-> Previous; Struct DLink * Third = q- & gt; Backstentine-> next; While (second! = Q-> Backstentinal-> Next) {back-> Next = second; Third = back- & gt; Previous; Back-> gt; Next-> gt; Back = back; Back = second; Second = third; }}  

But this does not seem to work, I'm testing it with a deck that looks like this: 1, 2, 3 is output: 3 and it The actual value of the numbers to process the process. To wit. 2 gets 2.90085e-309 ... I think the switching signal is messy, but I'm not getting the problem. And even if it does not mean that my code is correct; It just compile it.

If this is a double link list, then you do not need to change any signal. Just swap on payloads:

pointer1 = first pointer2 = last point pointer 1! = Pointer 2 and Pointer 2- & gt; next! = Pointer 1: temp = pointer1-> Payload Pointer 1- & gt; Payload = pointer2-> Payload Pointer 2- & gt; Payload = temp pointer1 = pointer1-> Next pointer 2 = Pointer 2- & gt; Previous

If you return the previous indicator (as none is available as the first indicator), then you need to move backwards Throw the deck to find it. Although it is difficult to believe that this will be the case because it will be a sufficiently disabled deck (which is considered a double queue queue).


Comments