
算法
基础
ccqq0507
这个作者很懒,什么都没留下…
展开
-
tarjen算法实现scc
//#include <bits/stdc++.h>#include<iostream>#include<stack>using namespace std;#define M (INT_MAX)#define PRINT_ARRAY(a,n) do{for(int i = 0; i < n; i++) cout<<a[i]<<"|"; cout<<endl;}while(0)/***************原创 2021-10-14 17:07:07 · 215 阅读 · 0 评论 -
选择排序之堆排
void heapInsert(int curArr[], int index){ while (curArr[index]>curArr[(index-1)/2]) { swap(curArr[index], curArr[(index - 1) / 2]); index = (index - 1) / 2; }}void heapify(int curArr[], int heapSize){ int rootIndex =原创 2021-09-15 15:21:18 · 99 阅读 · 0 评论 -
交换排序之快速排序
int partion(int curArr[],int lIndex,int rIndex){ int partIndex = rIndex; int moreIndex = rIndex - 1; int lessIndex = lIndex; while (moreIndex != lessIndex) { if (curArr[lessIndex] > curArr[partIndex]) { swap(curArr[原创 2021-09-15 11:10:46 · 84 阅读 · 0 评论 -
四种简单排序
deque<int> merge(deque<int>leftVec, deque<int>rightVec) { deque<int> ret; //reverse(leftVec.begin(), leftVec.end()); //reverse(rightVec.begin(), rightVec.end()); while (leftVec.size()>0&&rightVec.size()>原创 2021-08-26 17:15:38 · 105 阅读 · 0 评论 -
二叉树是否平衡
// fowlup.cpp -- unique_ptr not a good choice#include <iostream>#include <string>#include <stack>#include<vector>#include<string>#include <algorithm>using namespace std;struct TreeNode { int val; TreeNo原创 2021-08-04 20:23:57 · 98 阅读 · 0 评论 -
二叉树所有路径
void traversal(TreeNode* cur, vector<int>& path){ path.push_back(cur->val); if (cur->left == nullptr && cur->right == nullptr) { cout << "path::::"; for (auto it : path) { cout <&l原创 2021-07-29 10:04:25 · 99 阅读 · 0 评论 -
astar的cpp实现
#pragma once#include <iostream>#include <vector>#include <queue>using namespace std;class AStar{public: struct AStarPathPoint { AStarPathPoint* father; int x, y, gval, hval, fval; AStarPathPoint(pair<int, int> point, p原创 2021-04-13 16:35:10 · 184 阅读 · 0 评论 -
二叉树层序遍历
void CengOrder(TreeNode* root,vector<vector<int>>& res) { if (root == nullptr) return; queue<TreeNode*> q; q.push(root); while (!q.empty()) { int cursize = q.size(); res.push_back(vector<int>(原创 2021-06-30 17:30:40 · 95 阅读 · 0 评论 -
二叉树递归
// fowlup.cpp -- unique_ptr not a good choice#include <iostream>#include <string>//#include <memory>#include<vector>#include<string>using namespace std;struct TreeNode { int val; TreeNode* left; TreeNode* r原创 2021-06-17 20:24:21 · 82 阅读 · 0 评论