Algorithms
Algorithms copied to clipboard
The codes and my solutions to exercises from the book "Algorithms" (4th edition) by Robert Sedgewick and Kevin Wayne.
您好,练习1.1.14中传入参数若为负数,应输出0,而本例程将会进入死循环 https://github.com/jimmysuncpt/Algorithms/blob/master/src/com/jimmysun/algorithms/chapter1_1/Ex14.java
Demo
增加注解
根据题意无从得知传入`rank()`和`count()`的键必定存在于给定数组,故做出了调整,另优化了当等值键过多时的情况 Related to #14
Add answer to Ex09. Fix a bug at parse integer more than 10. Rewrite the answer to Ex10.
在判断是否overflow时,int值好像本身就不会超过max和min,所以判断a + b < MAX这种是不是并不能得到想要的效果? 其次,min应该是2^31,所以是-2147483648,不是-2147483647; 我的想法就是,比如ab>0且a > 0,根据a + b
问下 这题的构造函数里为什么要有下面的if条件? ``` if (denominator < 0) { numerator = -numerator; denominator = -denominator; } ```
1.1.33
只实现了3个方法?
大佬你好,Exercise 1.1.30 是不是有错误,0 和 0 应该不是互质的,另外 0 和 1 也不是互质的。