jimmysuncpt / algorithms Goto Github PK
View Code? Open in Web Editor NEWThe codes and my solutions to exercises from the book "Algorithms" (4th edition) by Robert Sedgewick and Kevin Wayne.
The codes and my solutions to exercises from the book "Algorithms" (4th edition) by Robert Sedgewick and Kevin Wayne.
在判断是否overflow时,int值好像本身就不会超过max和min,所以判断a + b < MAX这种是不是并不能得到想要的效果?
其次,min应该是2^31,所以是-2147483648,不是-2147483647;
我的想法就是,比如ab>0且a > 0,根据a + b <= max,判断b是否符合b <= max - a...不知道这样是否可以
另外minus和divide也需要判断一下overflow吧
in the while condition, you didn't check the boundary
public static int count(int key, int[] a) {
int num = 1;
int pos = rank(key, a);
while (a[pos] == a[++pos]) {
num++;
}
return num;
}
if we input an example 1 2 3 4 5 5, and execute count(5, a), this will cause java.lang.ArrayIndexOutOfBoundsException
您好,练习1.1.14中传入参数若为负数,应输出0,而本例程将会进入死循环
https://github.com/jimmysuncpt/Algorithms/blob/master/src/com/jimmysun/algorithms/chapter1_1/Ex14.java
只实现了3个方法?
问下 这题的构造函数里为什么要有下面的if条件?
if (denominator < 0)
{
numerator = -numerator;
denominator = -denominator;
}
大佬你好,Exercise 1.1.30 是不是有错误,0 和 0 应该不是互质的,另外 0 和 1 也不是互质的。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.