CS201 Example Problems    Date: ______ Name: ________________

Logical order of  List 1:__________________________   Logical order of List 2: __________________________
Logical order of List 3: __________________________   Logical order of List 4: _________________________

Complete the following operations on these  linked list (You should not assume these list are linked in ascending order)

       List 1
List=3      Free=4

0 45   6
1  32  5
2  56  -1
3  21  1
4  78  0
5  66  2
6  17  -1

 add 60 Prev =5

       List 2
List=2    Free=4

0 34 3
1 21 5
2 55 6
3 78 -1
4 31 1
5 45 -1
6 60 0

Add 50     Prev = -1

     List 3
List=3   Free=6

0 55 4
1 67 5
2 12 -1
3 90 1
4 34 -1
5 77 2
6 20 0

Add 35     Prev=2

     List 4
List=3       Free=6

0 64 5
1 16 -1
2 48 -1
3 22 0
4 74 1
5 94 4
6 20 2

Delete 64

    List 5
List=2  Free=4

0 70 5
1 50 -1
2 60 6
3 40 0
4 20 1
5 30 -1
6 80 3

Delete 40

List=2       Free=-1

0 30 3
1 10 5
2 70 6
3 20 1
4 40 0
5 50 -1
6 80 4

Delete 50

List=   1    Free=5

0 94 3
1 51 4
2 25 6
3 68 -1
4 81 2
5 35 0
6 70 -1

Add 10    Prev= 1

List=    2   Free=5

0 25 -1
1 37 3
2 44 6
3 50 -1
4 64 0
5 77 1
6 80 4

Add 54    Prev=0

List=3       Free=6

0 04 5
1 16 -1
2 28 -1
3 55
0
4 54 1
5 64 4
6 70 2

Delete 55

List= 2       Free=4

0 30 5
1 50 -1
2 80 6
3 90 0
4 90 1
5 70 -1
6 30 3

Delete 90

Complete the following operations on the double linked list (List are linked in ascending order)

  Free=               Fl=   Bl=

0 50

1 70

2 20
 
3 60

4

   
5  
 
6  
.......

 Free=5  FL=1 BL=6

0 34 3  
1 21 4 -1
2 55 6  4
3 78 -1
4 31 2  1
5 45 0
6 60 -1  2

Add 15

Free=4   FL=2 BL=3

0 55 1
2
1 67 3 0
2 12 0
-1
3 90 -1  1
4
5

5
6

6
-1

Add 85 

Double Circular  
  Free=5   FL= 3  BL=2

0 34 4
 3
1 66 2  4
2 78  3
 1
3 12 0  2
4 54 1  0
5
6

6
-1

Delete 12

Double Cicurlar
   Free=4  FL=2 BL=1

0 50
 
1 80
 
2 20
 
3 40
 
4   

5


6


Add 10