乌龟和兔子
摘要:如何找到链表中的循环?弗洛伊德有一个算法,也叫兔子和乌龟算法,boolean hasLoop(Node first) { if(first == null) // list does not exist..so no loop either. return false; Node slow, fast; // create two references. slow = fast = first; // make both refer to the start of the list. while(true) { slow = slow.nex...
阅读全文
posted @
2013-09-07 18:59
maxc01
阅读(783)
推荐(0)
matplotlib 绘图
摘要:大致步骤是:import matplotlib.pyplot as pltimport numpy as npx = np.linspace(0, 5, 10)y = x**2# 首先,需要一个figure对象fig = plt.figure()# 然后,axes对象,在axes上面绘图axes = fig.add_axes([0.1, 0.1, 0.8, 0.8])axes.plot(x, y, 'r')axes.set_xlabel('x')axes.set_ylabel('y')axes.set_title('title')
阅读全文
posted @
2013-09-05 21:29
maxc01
阅读(424)
推荐(0)