# Linked List implementation of Queue

This is a discussion on Linked List implementation of Queue within the C Programming forums, part of the General Programming Boards category; I am trying to create a queue using LL implementation that will be used for Radix Sort. The algorithm of ...

1. ## Linked List implementation of Queue

I am trying to create a queue using LL implementation that will be used for Radix Sort.

The algorithm of the radix sort is described as follows:
(a) Read in the numbers from a file and create a queue called
Master.
(b) Create 10 other queues called Subqueue[0], Subqueue
[1],. . . ,Subqueue[9].
(c) Remove a number from the Master queue and extract its most
right digit (ones).
(d) Add the number to the Subqueue[digit]
(e) Repeat the (c) and (d) until Master queue is empty.
(f) Remove the first element from the Subqueue[0] and insert it
into the Master queue.
(g) Repeat the previous step until the Subqueue[0] is empty.
(h) Repeat the last step for consecutive Subqueue[i] where i
takes on values from 2 to 9.
(i) Repeat the procedure starting from (b) Max times where the
value of Max is equal to the number of digits
in the largest number of the sequence.

2. Start by creating a few functions to allow you to insert and remove items (in this case ints).

Code:
```typedef struct _ll_node {
int data;
struct _ll_node *next;
} ll_node;```
So then you can declare
ll_node *master;
ll_node *subqueue[10];

And perhaps a function with this prototype

And you would perhaps call it like
master = add_to_list( master, my_data );

3. Originally posted by Salem

....
....

And perhaps a function with this prototype

And you would perhaps call it like
master = add_to_list( master, my_data );

Can we return the new value of master without using a return statement?? I mean return it by reference to an argument???

4. > Can we return the new value of master without using a return statement?
Yes, like so

And perhaps a function with this prototype

And you would perhaps call it like

5. Originally posted by Salem
> Can we return the new value of master without using a return statement?
Yes, like so

And perhaps a function with this prototype

And you would perhaps call it like

Can you tell me which is the preferred way? Which one is used more often... The return statement or by reference to an argument?
The ** confuses me..
head point to the pointer who's value we want to change????
The pointer we want is *head???

6. > Can you tell me which is the preferred way?
Both are valid, and both are useful.

> Which one is used more often... The return statement or by reference to an argument?
I'd go for the return, but that's just me.

> The pointer we want is *head???
Thats it, you would say
Code:
```ll_node *new_node = malloc( sizeof( ll_node ) );
// some code which decides new_node should be the head