- 博客(5)
- 收藏
- 关注
原创 编写一个程序,实现如下操作:根据序列{40, 28, 6, 72, 100, 3, 54, 15, 80, 91}建立一棵二叉排序树。用括号表示法输出该二叉树。在该二叉树上查找30和80,给出结果。
#include<stdio.h>#include<stdlib.h>#include<malloc.h>typedef int KeyType;typedef int ElemType;typedef struct bstnode{ KeyType key; ElemType data; struct bstnode *leftchild,*rightchild;}BSTNode;int BSTInsert(BSTNode...
2021-11-27 10:57:22
1006
原创 已知有7个待排序的元素,它们的关键字序列为(47, 56, 29, 16, 92, 33, 20),编写一个程序,用如下方法对其进行升序排序,要求显示每趟排序的结果:直接插入排序;希尔排序;冒泡排序
#include<stdio.h>#include<string>#include<stdlib.h>const int MAXSIZE=100;typedef int KeyType;typedef int ElemType;typedef struct{ KeyType key; ElemType data;}SqType;void InsertSort(SqType R[],int n){ int i,j; SqTy...
2021-11-27 10:53:55
2186
1
原创 编写一个函数,实现折半查找算法。实现在8个数据元素的有序表( 12, 24, 35, 47, 50, 62, 83, 115 )中采用折半查找方法,查找关键字90,47和35。
#include <stdio.h>#include <string>#include <stdlib.h>const int MaxSize=50;typedef int KeyType;typedef int ElemType;typedef struct{ KeyType key; ElemType data;} SqType;int BinSearch(SqType R[],int n,KeyType k){ int lo...
2021-11-27 10:49:52
998
原创 编程实现建立一个无向图,然后对此图进行深度优先遍历和广度优先遍历。
#include <stdio.h>#include <stdlib.h>#define MAXVEX 100#define INF 0x3f3f3f3ftypedef char VertexType[10];typedef struct edgenode{int adjvex;int weight;struct edgenode * nextarc;} ArcNode;typedef struct vexnode{VertexType data;ArcN
2021-11-01 14:25:47
2193
原创 编程实现从键盘输入二叉树的括号表示法建立一棵二叉树,然后分别用前序、中序,后序、层次遍历该二叉树,并输出。
#include <iostream>#include <malloc.h>using namespace std;const int MaxSize = 50;typedef char ElementType; typedef struct bitnode{ ElementType data; struct bitnode *left, *right;} bitnode, *bitree; void Cre...
2021-10-25 08:37:31
2636
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人