| | |
radix sort using queue and linked list
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
•
•
Originally Posted by happy8899
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
The key to eliminating bugs from your code is learning from your mistakes.
•
•
Join Date: Aug 2006
Posts: 20
Reputation:
Solved Threads: 0
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
here is my linked list how to use it in radix sort to sort a list
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
C++ Syntax (Toggle Plain Text)
# 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
C++ Syntax (Toggle Plain Text)
# 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
![]() |
Similar Threads
- Quicksorting linked list - simple algorithm (C)
- sort linked list help please (C)
- Bumping my object on a linked list (C++)
- How Can I Sort a Doubly Linked List Queue? (C)
- help by sorting a simply linked list (C)
Other Threads in the C++ Forum
- Previous Thread: quick ? about vector naming conventions
- Next Thread: if then statement
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy desktop developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker list loop looping loops map math memory multiple news node number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference rpg sorting string strings struct temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






