coursera普林斯顿算法课第一课怎样提升效率的意见

本文主要探讨了在Percolation类中减少WeightedQuickUnionUF对象调用的方法,特别是通过优化.open(int,int)方法来降低不必要的操作,从而提高程序效率。文章强调,在执行任何方法前,应充分考虑所有可能的情况,避免重复或不必要的工作。

1.Call methods when absolutely necessary

the first step to solving it is to look at all of your calls to WeightedQuickUnionUF (WQUUF) objects.I suspect that the most calls are in Percolation.open(int, int) method.A good way to decrease the number of method calls is to restrict the conditions. A method should only be called if absolutely necessary. In other words, don't open a site if it is already open.

2.Before you execute one loop,you should consider all situations can add into the loop

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值