Java ---- 遍历链表(递归与非递归实现)
摘要:二叉树的遍历 二叉树的遍历分为三种:前序遍历 中序遍历 后序遍历 前序遍历:按照“根左右”,先遍历根节点,再遍历左子树 ,再遍历右子树 中序遍历:按照“左根右“,先遍历左子树,再遍历根节点,最后遍历右子树 后续遍历:按照“左右根”,先遍历左子树,再遍历右子树,最后遍历根节点 其中前,后,中指的是每次
阅读全文
Java ---- 链表逆序
摘要:public class LinkedListRevert { public static void main(String[] args) { Node next3 = new Node(4,null); Node next2 = new Node(3,next3); Node next = new Node(2,next2); ...
阅读全文
Java ---- 快速排序
摘要:public class QuickSort { public static void main(String[] args) { int[] arr = { 49, 38, 65, 97, 23, 22, 76, 1, 5, 8, 2, 0, -1, 22 }; quickSort(arr, 0, arr.length - 1); Sys...
阅读全文
Java ---- 二分查找
摘要:public class binSearch { public static void main(String[] args) { int ary[] = {1,5,3,54,32,643,34,2543}; System.out.println(binSearch(ary,0,ary.length-1,643)); } publi...
阅读全文