上一页 1 ··· 7 8 9 10 11 12 下一页
摘要: 在一些编程场景中,我们常常需要记录下某一个特殊的实例位置(如BST转双向链表题中需要记录最终生成的链表的头节点)。在使用Java编程过程中,需要注意引用的问题。class ListNode { public int val; public ListNode next; public ListNode... 阅读全文
posted @ 2015-06-28 17:24 Chapter 阅读(560) 评论(0) 推荐(0) 编辑
摘要: 二分查找是在完全有序数组(或部分有序)中对某一元素进行快速查找的算法。时间复杂度为O(logn)。实现方式有递归和非递归。非递归实现 public int binarySearch(int[] nums, int key) { if (nums == null || nums.length == ... 阅读全文
posted @ 2015-06-28 11:22 Chapter 阅读(177) 评论(0) 推荐(0) 编辑
摘要: Given a complete binary tree, count the number of nodes.Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, exc... 阅读全文
posted @ 2015-06-25 11:25 Chapter 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 下面对常见的排序算法,包括四种简单排序算法:冒泡排序、选择排序、插入排序和希尔排序;三种平均时间复杂度都是nlogn的高级排序算法:快速排序、归并排序和堆排序,进行全方面的总结,其中包括代码实现、时间复杂度及空间复杂度分析和稳定性分析,最后对以上算法进行较大数据量下的排序测试,验证其时间性能。1. ... 阅读全文
posted @ 2015-06-25 09:16 Chapter 阅读(244) 评论(0) 推荐(0) 编辑
摘要: 树的遍历方式总体上有两种:DFS和BFS;其中DFS包含了前序、中序和后序遍历,而BFS则为层次遍历。DFS的实现方式:(1) 递归;(2) 非递归,使用辅助栈;递归程序public class Recursion { public void preorderRec(TreeNode root) {... 阅读全文
posted @ 2015-06-25 07:58 Chapter 阅读(2339) 评论(0) 推荐(0) 编辑
摘要: http://www.52ml.net/14773.html 阅读全文
posted @ 2015-06-23 09:42 Chapter 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 编辑距离和最长公共子串问题都是经典的DP问题,首先来看看编辑距离问题:问题描述Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each ope... 阅读全文
posted @ 2015-06-19 14:46 Chapter 阅读(359) 评论(0) 推荐(0) 编辑
摘要: 问题描述:Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.... 阅读全文
posted @ 2015-06-16 10:35 Chapter 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 原文链接:http://blog.csdn.net/w28971023/article/details/8240756 阅读全文
posted @ 2015-06-12 09:41 Chapter 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 1.定义卡特兰数又称卡塔兰数,英文名Catalan number,是组合数学中一个常出现在各种计数问题中出现的数列。由以比利时的数学家欧仁·查理·卡塔兰 (1814–1894)命名,其前几项为 :1, 2, 5, 14, 42, 132...递推式:令h(0)=1,h(1)=1,(1) Catala... 阅读全文
posted @ 2015-06-11 12:17 Chapter 阅读(589) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 下一页