如何区分在线和离线排序算法?
How to distinguish online and offline sorting algorithms?
我有以下排序算法:
Bubble Sort, Selection Sort, Heap Sort, Merge Sort, Quick Sort, Insertion Sort
哪些是在线排序,哪些是离线排序?
提前谢谢你。
这取决于您如何定义"online"排序算法。如果您使用 Wikipedia definition:
In computer science, an online algorithm is one that can process its
input piece-by-piece in a serial fashion, i.e., in the order that the
input is fed to the algorithm, without having the entire input
available from the start.
然后在您列出的算法中,只有插入排序符合要求,因为其他算法要求所有项都在内存中才能开始排序。
使用插入排序,您维护的是一个排序列表:每个项目在收到时都放在适当的位置。到目前为止,您收到的物品清单始终井然有序。
另见,https://cs.stackexchange.com/questions/55012/what-is-the-fastest-online-sorting-algorithm
我有以下排序算法:
Bubble Sort, Selection Sort, Heap Sort, Merge Sort, Quick Sort, Insertion Sort
哪些是在线排序,哪些是离线排序? 提前谢谢你。
这取决于您如何定义"online"排序算法。如果您使用 Wikipedia definition:
In computer science, an online algorithm is one that can process its input piece-by-piece in a serial fashion, i.e., in the order that the input is fed to the algorithm, without having the entire input available from the start.
然后在您列出的算法中,只有插入排序符合要求,因为其他算法要求所有项都在内存中才能开始排序。
使用插入排序,您维护的是一个排序列表:每个项目在收到时都放在适当的位置。到目前为止,您收到的物品清单始终井然有序。
另见,https://cs.stackexchange.com/questions/55012/what-is-the-fastest-online-sorting-algorithm