①无向图的非递归深度优先搜索需借用一个堆栈保存被访问过的顶点,以便回溯查找已被访问结点的被访问过的邻接点。 ②访问起始顶点v0,visited[v0]标记1,v0入栈,指针p指向v0对应的边表首结点; ③从左到右扫描p所指的边表(邻接表),查找边表中对应顶点的visited[v]标志为0的结点; ④若找到所求结点,则对应的顶点记为v。然后访问v,visited[v]标记1,v入栈,p指向v对应的边表首结点。否则,从栈中出栈一个顶点作为v(即回溯)p指向v对应的边表首结点; ⑤重复②、③直至所有的顶点都被访问一次。
2022-05-14 14:55:21 2KB 深度优先遍历
1
老师布置的作业呐,自己做完调试运行了先序输入是EACBDGF,中序遍历是ABCDEFG,能够运行。>_< 我的运行结果: 输入先序序列:EACBDGF 输入中序序列:ABCDEFG 先序遍历的二叉树:E A C B D G F 中序遍历的二叉树:A B C D E F G 后序遍历的二叉树:B D C A F G E ****************捞分下题目嗷=A=************
2022-05-14 14:26:56 2KB 层次遍历;二叉树;队列
1
该程序用EXCELE中的VBA语言脚本编写,可以实现将任意盘符下的文件及文件夹,也包括子文件夹的路径准确读取,并记录到EXCEL表中,每个单元格中的内容即是文件的磁盘地址,点击即可运行.
1
可以实现将指定目录及子目录所有文件遍历查询出来放于A列和B列,然后在B列进行批量文件名修改,具体附件中有操作截图说明。
2022-05-14 07:05:52 139KB VBA 遍历文件夹 批量修改文件名 excel
1
1.编写按键盘输入的数据建立图的邻接矩阵存储; 2.编写图的深度或广度优先编历程序;
2022-05-12 11:12:57 84KB 遍历 实验指导
1
图的基本操作 图的遍历实验报告
2022-05-12 11:04:00 101KB 数据结构 算法
本文实例讲述了javascript数据结构之多叉树经典操作。分享给大家供大家参考,具体如下: 多叉树可以实现复杂的数据结构的存储,通过遍历方法可以方便高效的查找数据,提高查找的效率,同时方便管理节点数据。javascript的DOM其实就是以多叉树的形式存储的。下面用javascript来实现多叉树的数据结构 1、创造一个节点 数据是以节点的形式存储的: class Node { constructor(data) { this.data = data; this.parent = null; this.children = []; } } 2、创造树 树用
2022-05-11 16:36:23 69KB AS asc c
1
实现n<15的最短遍历 Gord is training for a marathon. Behind his house is a park with a large network of jogging trails connecting water stations. Gord wants to find the shortest jogging route that travels along every trail at least once. Input Input consists of several test cases. The first line of input for each case contains two positive integers: n <= 15, the number of water stations, and m < 1000, the number of trails. For each trail, there is one subsequent line of input containing three positive integers: the first two, between 1 and n, indicating the water stations at the end points of the trail; the third indicates the length of the trail, in cubits. There may be more than one trail between any two stations; each different trail is given only once in the input; each trail can be travelled in either direction. It is possible to reach any trail from any other trail by visiting a sequence of water stations connected by trails. Gord's route may start at any water station, and must end at the same station. A single line containing 0 follows the last test case. Output
2022-05-11 14:30:50 1KB 最短遍历
1
中序遍历线索化二叉树算法的设计与实现实验报告.doc
2022-05-09 19:14:58 594KB 文档资料 算法
供水管网水龄的逐节点遍历简化算法.docx
2022-05-09 19:14:35 487KB 算法 综合资源