随笔分类 - 数据结构
初学数据结构写下的笔记
摘要:二叉查找树 对于任意一棵子树,其左子树比根节点小,右子树比根节点大。即:左 < 根 < 右 查找 比较目标值与根节点的大小关系, 大就往右边找; 小就往左边找; 直到找到为止,如果到最后没有找到,则返回 nullptr Node * BST::searchByIter(Node * bst, Dat
阅读全文
摘要:数组利用哨兵位查找元素 存储时把数组的下标0处空出,留着放哨兵位; 从后向前遍历数组,直到找到目标元素,或者找到哨兵结束; 根据被找到元素的所在位置判断元素是否在数组中存在 在 0 处:不存在 不在 0 处:存在 实现: int searchBySent(int * arr, int target)
阅读全文
摘要:二叉树 结构描述: #include <iostream> #include <queue> using namespace std; typedef int DataType; class Node { private: DataType data; Node * left; Node * rig
阅读全文
摘要:双链表 结构描述: #include <iostream> #include <cstdlib> using namespace std; typedef int DataType; //链表节点 typedef struct Node { DataType A; struct Node * Pre
阅读全文
摘要:栈:数组实现 结构描述: #define MAX 100 typedef int DataType; class SeqStack { public: DataType * A; int Top; void Init(); void Push(DataType X); void Pop(); Dat
阅读全文
摘要:栈:链表实现 结构描述 #include <iostream> #include <cstdlib> typedef int DataType; using namespace std; typedef struct Node { DataType A; struct Node * Next; }N
阅读全文
摘要:双栈:数组实现 结构描述: #include <iostream> #include <cstdlib> #define MAX 100 using namespace std; typedef int DataType; class DoubleStack { public: DataType *
阅读全文
摘要:单链表 结构描述 #include <iostream> #include <cstdlib> using namespace std; typedef int DataType; //链表节点 typedef struct Node { DataType A; struct Node * Next
阅读全文
摘要:顺序表 结构描述 #include <iostream> #include <cstdlib> #define MAX 100 using namespace std; typedef int DataType; class SeqList { private: DataType * A; int
阅读全文
摘要:循环队列:链表实现 结构描述 typedef int DataType; typedef struct QueueNode { DataType A; struct QueueNode * Next; }Node; class QueueCycLinked { public: //队头、队尾指针 N
阅读全文
摘要:队列:链表实现 结构描述: typedef int DataType; typedef struct QueueNode { DataType A; struct QueueNode * Next; }Node; class QueueLinked { public: //队头、队尾指针 Node
阅读全文