![](https://img-blog.csdnimg.cn/20190918140129601.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
数据结构和算法(前端)
JavaScript语言,数据结构和算法经典题
给各位大佬递茶yao
我是个菜鸡,给各位大佬鞠躬敬茶/\大家不要关注我,我将这个账号当做云笔记用,不保证内容准确性
展开
-
排序算法(js版)
常见的有冒泡排序、插入排序、选择排序、快速排序。原创 2023-03-05 15:40:18 · 55 阅读 · 0 评论 -
前端数据结构与算法
算法思维:二分、贪心、动态规划;原创 2023-01-24 20:53:43 · 62 阅读 · 0 评论 -
正负分界
#include<iostream> using namespace std; void div(int a[],int n) { int* b1 = new int[n](), * b2 = new int[n](); //int b1[100] = { 0 }, b2[100] = {0}; int i, j=0, k=0; for (i = 0; i < n; i++) { if (a[i] < 0) b1[j++] = a[i]; else if原创 2021-01-12 00:24:54 · 131 阅读 · 0 评论 -
折半查找(递归和非递归)
折半查找(递归和非递归) #include<iostream> using namespace std; int Bisearch(int a[], int n, int k)//非递归 { int low = 0, high = n - 1,mid; while (low < high) { mid = (low+high) / 2; if (a[mid] == k) return mid; else if (a[mid] < k) low = mid原创 2021-01-11 23:48:23 · 350 阅读 · 0 评论 -
建立二叉排序树
编写算法,输入一组整数,以9999为结束标志,将这些数据建立二叉排序树。输出中序排序序列检验是否为二叉排序树,并且在二叉排序树内查找值。 #include<iostream> using namespace std; struct BiNode { int key; int data; BiNode* lchild, * rchild; }; class BiSortTree { BiNode* root; void Insert(BiNode*& ptr, int k);原创 2021-01-11 23:02:19 · 1219 阅读 · 0 评论 -
二叉树的平衡因子
二叉树T的结点结构为:data域,平衡因子bal,左子树结点,右子树结点 bal=左子树高度-右子树高度 编写算法求树T中bal值。(//(待定)各结点的bal值) #include<iostream> #include<vector> using namespace std; template<class T> struct BiNode { T data; int bal; BiNode<T>* lchild, * rchild; }; templa原创 2021-01-11 22:47:35 · 701 阅读 · 0 评论 -
逆序data域数值
设单链表L中的结点按data域数值递减排列,设计算法将L中的结点按data域数值递增排列,要求算法复杂性为O(n) 在这里插入代码片 #include<iostream> #pragma warning(disable:4996) using namespace std; template<class T> struct Node { T data; Node<T>* next; }; template<class T> class LinkList {原创 2021-01-11 22:37:25 · 214 阅读 · 0 评论 -
数结①:SeqList的各种操作
#include<iostream> #include<iostream> using namespace std; template<class T,int MaxSize> class SeqList { //私有成员变量 T data[MaxSize]; int length; //函数成员 public: //构造函数 SeqList(); SeqList(int a[], int n);//由数组构造 //遍历函数 void Print();原创 2021-01-02 19:40:59 · 1128 阅读 · 1 评论