# Priority Linked Lists?

Discussion in 'C' started by tr3molo, Apr 16, 2008.

1. ### tr3moloNew Member

Joined:
Apr 16, 2008
Messages:
2
0
Trophy Points:
0
Hello World, i just started learning the ropes of Linked lists. I get the basic gist of it. Although i am baffled with a question that i clearly do not understand.

here is the main question:

You are rerquired to write a C program on Linux which design, implement and test a
function: sort list(), which will sort such a list according to the priority value computed by
whatever function is passed as its second argument. The frst argument is to be a pointer
to the head of the list. Since the OS will have other structures with pointers to IORB's,
the list must be sorted in place.

within this question i am given this snippet

typedef struct iorb {
short base_pri;
char filler[110];
} IORB;

OK so this is what i do not understand:

1. What is char filler[110] used for?
2. Obviously base_pri means prioity but what exactly is it used for? comparing IORBS?
3. The Bubble sort is easy to implement, but what argument besides *head must i pass?

What i do know is a have to build a linked list to simulate disk I/O in systems programming.
but it is pretty difficult witout first understanding what the question is actually asking of me.

any suggestions will be appreciated. and any non-suggestions also

thanks in advance - tr3molo

2. ### tr3moloNew Member

Joined:
Apr 16, 2008
Messages:
2
0
Trophy Points:
0
Re: New Fix

Ok World i have figured it out. But now i have a new problem. I have searced these forums and cannot find a solid solution to my problem. Basically i have to you a bubble sort to sort out my linked lists using the base_pri values. My code looks some what like this
Code:
```[COLOR=Blue]typedef struct iorb
{
short base_pri;
struct iorb *next;
char filler[110];
} IORB;[/COLOR]
[COLOR=DarkGreen]main()
{

IORB *list1, *list2, *list3,*list4,*list5, *head, *temp;

int list_size;

list1 = (IORB*)malloc(sizeof(IORB));
list2 = (IORB*)malloc(sizeof(IORB));
list3 = (IORB*)malloc(sizeof(IORB));
list4 = (IORB*)malloc(sizeof(IORB));
list5 = (IORB*)malloc(sizeof(IORB));

list1->base_pri = 2;
list1->next = list2;

list2->base_pri = 6;
list2->next = list3;

list3->base_pri = 1;
list3->next = list4;

list4->base_pri = 5;
list4->next = list5;

list5->base_pri = 9;

printf("%i",list_size);