954,190 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

radix sort using queue and linked list

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

happy8899
Newbie Poster
24 posts since Aug 2006
Reputation Points: 10
Solved Threads: 0
 
Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

Where are you stuck?

Grunt
Junior Poster
152 posts since Jul 2006
Reputation Points: 197
Solved Threads: 12
 
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

happy8899
Newbie Poster
24 posts since Aug 2006
Reputation Points: 10
Solved Threads: 0
 
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.

Grunt
Junior Poster
152 posts since Jul 2006
Reputation Points: 197
Solved Threads: 12
 

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.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

quote=Salem;245110]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.[/quote]

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

happy8899
Newbie Poster
24 posts since Aug 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You