摘要: 1 public class BinarySearchNoRecur { 2 3 public int binarySearch(int arr[], int target) { 4 if (arr == null || arr.length == 0) { 5 return -1; 6 } 7 i 阅读全文
posted @ 2020-08-01 10:22 酱油飘香 阅读(187) 评论(0) 推荐(1) 编辑
摘要: 深度优先遍历是纵向遍历,一直到底,二叉树的前序遍历、中序遍历,后序遍历都是深度优先遍历。 广度优先遍历是横向遍历,层次遍历,遍历完一层再遍历下一层,直到遍历所有元素。 以矩阵为例,分析深度优先遍历(DFS)和广度优先遍历的路径: 插入矩阵: //测试一把图是否创建ok int n = 8; //结点 阅读全文
posted @ 2020-08-01 10:09 酱油飘香 阅读(802) 评论(0) 推荐(1) 编辑