【发布时间】:2011-08-15 13:40:56
【问题描述】:
我正在寻找一种可以学习和理解合并排序的简单方法。我在网上查看过,发现合并排序对于单链表非常有用,但我不明白该怎么做。这是我找到的网站: Wikipedia Merge sort 和 Specifically linked lists
我不确定要给你什么代码。我基本上只是在我的头文件中有这个,并且是对此的新手,所以我非常基础。提前感谢您的帮助:)
class Node
{
public:
int data;
Node* next;
Node()
{
next = NULL;
data = 0;
}
};
class SLLIntStorage
{
public:
Node* head;
Node* current;
Node* tail;
void Read(istream&);
void Write(ostream&);
void setReadSort(bool);
void sortOwn();
void print();
bool _sortRead;
int numberOfInts;
SLLIntStorage(const SLLIntStorage& copying)
{
}
SLLIntStorage(void);
~SLLIntStorage(void);
};
【问题讨论】:
标签: c++ mergesort singly-linked-list