摘要: 红黑树是一种二叉平衡查找树,每个结点上有一个存储位来表示结点的颜色,可以是RED或BLACK。红黑树具有以下性质: (1) 每个结点是红色或是黑色 (2) 根结点是黑色的 (3) 如果一个结点是红色的,则它的两个儿子都是黑色的 (4) 对于每个结点,从该结点到其子孙结点的所有路径上包含相同数目的黑结 阅读全文
posted @ 2017-12-07 15:06 evasean 阅读(3165) 评论(0) 推荐(0) 编辑
摘要: 题目地址:http://coursera.cs.princeton.edu/algs4/assignments/kdtree.html 分析: Brute-force implementation. 蛮力实现的方法比较简单,就是逐个遍历每个point进行比较,实现下述API就可以了,没有什么难度。 阅读全文
posted @ 2017-08-15 21:24 evasean 阅读(1240) 评论(0) 推荐(0) 编辑
摘要: 题目原文: Design an algorithm to perform an inorder traversal of a binary search tree using only a constant amount of extra space. 1 public void traverse( 阅读全文
posted @ 2017-08-14 17:56 evasean 阅读(829) 评论(0) 推荐(0) 编辑
摘要: 题目原文: Given a binary tree where each 𝙽𝚘𝚍𝚎 contains a key, determine whether it is a binary search tree. Use extra space proportional to the height 阅读全文
posted @ 2017-08-14 16:46 evasean 阅读(350) 评论(0) 推荐(0) 编辑
摘要: 树还是应该做成可视化的方便查看和调试,后续我将更新一个可视化的生成图的版本出来,恩,一定要记得这件事 阅读全文
posted @ 2017-08-09 19:29 evasean 阅读(631) 评论(0) 推荐(0) 编辑
摘要: 1. Java autoboxing and equals(). Consider two double values a and b and their corresponding Double value x and y. Find values such that (𝚊==𝚋) is 𝚝 阅读全文
posted @ 2017-08-09 14:46 evasean 阅读(380) 评论(0) 推荐(0) 编辑
摘要: 题目原文:http://coursera.cs.princeton.edu/algs4/assignments/8puzzle.html 题目要求:设计一个程序解决8 puzzle问题以及该问题的推广,例如8-puzzle是3*3,程序要能解决n*n的同类问题(2 ≤ n < 128) 典型的8 p 阅读全文
posted @ 2017-08-04 00:03 evasean 阅读(2155) 评论(0) 推荐(0) 编辑
摘要: 题目原文: Decimal dominants. Given an array with n keys, design an algorithm to find all values that occur more than n/10 times. The expected running time 阅读全文
posted @ 2017-08-02 14:51 evasean 阅读(1414) 评论(0) 推荐(0) 编辑
摘要: 题目原文 Selection in two sorted arrays. Given two sorted arrays a[] and b[], of sizes n1 and n2, respectively, design an algorithm to find the kth larges 阅读全文
posted @ 2017-08-02 14:32 evasean 阅读(930) 评论(0) 推荐(1) 编辑
摘要: 题目原文详见http://coursera.cs.princeton.edu/algs4/assignments/collinear.html 程序的主要目的是寻找n个points中的line segment,line segment的要求就是包含不少于4个点。 作业包含三部分程序实现: 一、Poi 阅读全文
posted @ 2017-07-27 21:56 evasean 阅读(1696) 评论(2) 推荐(1) 编辑