牛客网 二叉树
sdu@xy
山东大学
展开
-
堆的初始化、插入、删除实现 C++
记录学习 class maxHeap{ public: int arrLen;//数组长度 int heapSize;//当前长度 int *heap;//方便动态增加数组大小 void initHeap(int *theHeap,int size); int pop(); void push(const int theElement); }; void maxHeap::initHeap(int *theHeap,int size){ dele原创 2020-11-07 10:00:41 · 424 阅读 · 0 评论 -
牛客网 树问题 C++实现
1:分别用递归和非递归方式实现二叉树的前序、中序和后序遍历 class Solution{ public: //递归方式依次实现二叉树前序、中序、后序遍历 void preOrder(TreeNode *root,vector<int>&vector){ if(root!=NULL){ vector.emplace_back(root->val); preOrder(root->left,ve原创 2020-10-30 20:24:59 · 139 阅读 · 0 评论