2023年9月14日

c++ 实现 二叉树的 先序遍历,中序遍历 ,后序遍历

摘要: 遍历二叉树 跟数组不同,树是一种非线性的数据结构,是由n(n >=0)个节点组成的有限集合。如果n==0,树为空树。如果n>0,树有一个特定的节点,叫做根节点(root)。 对于树这种数据结构,使用最频繁的是二叉树。每个节点最多只有2个子节点的树,叫做二叉树。二叉树中,每个节点的子节点作为根的两个子 阅读全文

posted @ 2023-09-14 13:40 songsonglailou 阅读(66) 评论(0) 推荐(0) 编辑

C++ 实现 快速排序

摘要: #include<iostream>using namespace std; void quickSort(int(&)[10], int, int);int partition(int(&)[10], int, int); void printArr(const int(&)[10]);void 阅读全文

posted @ 2023-09-14 10:28 songsonglailou 阅读(53) 评论(0) 推荐(0) 编辑

用c++ 实现 二分查找 前提是先把数组排列好

摘要: #include<iostream>using namespace std; // 可以递归调用的二分查找int search(const int(&a)[10], int start, int end, int target){ // 基准情况:目标值超出范围,或者start > end,说明没有 阅读全文

posted @ 2023-09-14 10:14 songsonglailou 阅读(7) 评论(0) 推荐(0) 编辑

导航