重点是堆排序怎么实现。
我的写法:
#include <iostream>
#include <vector>// 辅助函数:调整堆
void heapify(std::vector<int>& arr, int n, int i) {int largest i; // 初始化最大值为根节点int left 2 * i 1; // 左子节点…
Collection: Collection 不唯一,无序
List 不唯一,有序
Set 唯一,无序 ArrayList:内部使用长度可变的数组,遍历查询效率高
LinkedList:采用双向链表实现,增删改效率比较高 ArrayL…
在 Windows 系统中执行 .sh 脚本文件通常需要使用类 Unix 环境,因为 .sh 脚本是为 Unix-like 系统(如 Linux 或 macOS)设计的。以下是在 Windows 中执行 .sh 脚本的一些方法: 使用 Windows Subsystem for Linux (WSL): 安装 WSL。…