aboutsummaryrefslogtreecommitdiff
path: root/DSAA/chap3_lists_stacks_queues/ex_3.c
blob: 6981ce91991bbc7f3e27644e9d935f5cee33acd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include <stdlib.h>

#include "list.h"

void SwapSinglyAdjacentNode( Position FrontP, Position BackP , List L)
{
        Position TmpCell;

        TmpCell = FindPrevious( FrontP->Element, L );
        TmpCell->Next = BackP;

        TmpCell = FrontP;
        FrontP->Next = BackP->Next;
        BackP->Next = TmpCell;
}

void SwapDoublyAdjacnetNode( Position P1, Position P2 )
{

}

int main()
{
        List L;
        Position Front, Back;

        L = malloc( sizeof( struct Node ) );

        Insert(1, L, L);
        Insert(2, L, L);
        Insert(3, L, L);
        Insert(4, L, L);

        PrintList( L );

        Front = Find(3, L);
        Back = Find(2, L);

        SwapSinglyAdjacentNode(Front, Back, L);

        PrintList( L );

        return 0;
}