i wan to know the code for the radix sort using a queue and a radix sort using a linked list

Where are you stuck?

i dunno how to develope a program that need to use linked list both the single linked list and double linked list which need to enter the list of number using linked list and using radix sort that is developed using linked list

i dunno how to develope a program that need to use linked list both the single linked list and double linked list which need to enter the list of number using linked list and using radix sort that is developed using linked list

Buddy we can't explain everything to you here. For that you have to look into the books. If you have a specific doubt, post here. Definetly someone here will help you out.

Well can you do the "populate a linked list with some data" part of the problem?

There's no point talking about the "sort" side of things until you can do that.

I mean, "here is my linked list code", how do I radix sort it would at least show some effort on your part.

Well can you do the "populate a linked list with some data" part of the problem?
There's no point talking about the "sort" side of things until you can do that.
I mean, "here is my linked list code", how do I radix sort it would at least show some effort on your part.

first linked list

# include <iostream>
using namespace std;
#ifndef DLL_QUEUE
#define DLL_QUEUE
#include <list>
template <class T>
class linkedList
{
public:
 linkedList()
 {
 }
 void clear()
 {
  lst.clear();
 }
 bool empty() const
 {
  return lst.empty();
 }
 T& front()
 {
  return lst.front();
 }
 T dequeue()
 {
  T el = lst.front();
  lst.pop_front();
  return el;
 }
 void enqueue(const T& el)
 {
  lst.push_back(el);
 }
private:
 list<T> lst;
};
#endif






# ifndef INT_LINKED_LIST
# define INT_LINKED_LIST
using namespace std; 
class IntSLLNode
{
public:
 int info;
 IntSLLNode *next;
 IntSLLNode (int el, IntSLLNode *ptr = 0)
 {
  info = el;
  next =ptr;
 }
};
class IntSLList
{
public:
 IntSLList()
 {
  head = tail = 0;
 }
    ~IntSLList();

 int empty()
 {
  return head ==0;
 }

 void addToHead(int);
 void addToTail(int);
 int deleteFromHead();
 int deleteFromTail();
 void deleteNode(int);
 bool isInList(int) const;
 void insertNode(int&);
 void print();
 int get();

private:
 IntSLLNode *head, *tail;
 int t;
};
IntSLList::~IntSLList()
{
 for(IntSLLNode *p; !empty();)
 {
  p = head->next;
  delete head;
  head = p;
 }
}
void IntSLList::addToHead(int el)
{
 head = new IntSLLNode(el, head);
 if(tail == 0)
  tail == head;
}

void IntSLList::addToTail(int el)
{
 if(tail!= 0)
 {
  tail->next = new IntSLLNode(el);
     tail = tail->next;
 }

 else head = tail = new IntSLLNode(el);
}
void IntSLList::deleteNode(int el)
{
 if(head!=0)
  if(head == tail && el == head->info)
  {
   delete head;
   head = tail =0;
  }
  else if (el == head->info)
  {
   IntSLLNode *temp = head;
   head = head->next;
   delete temp;
  }
  else
  {
   IntSLLNode *pred, *tmp;
   for (pred = head, tmp = head->next; tmp!=0 && !(tmp->info == el);
        pred = pred->next, tmp = tmp->next);
   if (tmp!=0)
   {
    pred->next = tmp->next;
    if(tmp == tail)
     tail = pred;
    delete tmp;
   }
  }
}
int IntSLList::deleteFromHead()
{
 int el = head->info;
 IntSLLNode *tmp = head;
 if(head == tail)
  head = tail = 0;
 else head = head->next;
 //cout<<"     "<<head->info;
 delete tmp;
 return el;
}

int IntSLList::deleteFromTail()
{
 int el = tail->info;
 if (head == tail)
 {
  delete head;
  head = tail = 0;
 }
 else
 {
  IntSLLNode *tmp;
  for (tmp = head; tmp->next !=tail; tmp = tmp->next)
  delete tail;
  tail = tmp;
  tail->next=0;
    }
 return el;
}
void IntSLList::print()
{
 IntSLLNode *current;

 current = head;

 while (current != NULL)
 {
  cout<< current->info<<"    ";
  current = current->next;
 }
}
int IntSLList::get()
{
 IntSLLNode *current;
 IntSLLNode *yy;

 current = head;
 yy = current;

 cout<<"get";
 t = yy->info;
 cout<<endl<<t<<" ggggg "<<endl;
 yy = yy->next;
 cout<<yy->info;
 //current->next = NULL;
 //head = head->next;
 //delete current;
 return t;
}
#endif

here is my linked list how to use it in radix sort to sort a list

Edited 3 Years Ago by Dani: Formatting fixed

This article has been dead for over six months. Start a new discussion instead.