我正在寻找一种可以学习和理解合并排序的简单方法。我在网上查看过,发现合并排序对单链表非常有用,但我不明白该怎么做。这是我找到的网站: Wikipedia Merge sort and Specific 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);
};