Week1 Assignment - Princeton-Algorithms-PartI

博主分享了在Coursera上参加Princeton的《Algorithms partI》课程的经历,利用寒假时间充电学习,并表示将发布课程的Java代码,以帮助他人参考学习。
摘要由CSDN通过智能技术生成

题注

这本来是我新浪博客中的一个文章,不过感觉技术博客还是在CSDN中发表比较合适,以后CSDN会是自己的领地了!把以前的一些有用的,阅读量比较多的博客搬过来,造福更多人吧~

转眼又到寒假了,话说我这简单的技术小博客一直没有更新呢~ 寒假有充足的时间给自己充电,整个寒假净忙着弄英语、看论文、写ReportReview,当然还有我自己最喜欢的:上Coursera的课程了~这个寒假总共注册了三门课程:Stanford《Introduction toDatabase》;Princeton《Algorithms partI》;以及一门和以后研究方向有关的《Health info inCloud》。对于Introduction toDatabase这门课来说,Stanford的作业量那真是超大…都贴常来我博客就爆了…不过我还是争取在闲余时间把那门课的InteractiveExercise的答案贴出来,供大家参考。Princeton的算法课程完全用Java写,这是我的最爱嘛~贴上来代码和大家分享一下,我觉得对于我和对于有兴趣阅读这一系列博客的人来说都会有帮助。

对于《Algorithms》这门课,如果想做一做这里面的Assignment,首先必须要到他的官方网站下面下载一些jar文件,链接如下:http://algs4.cs.princeton.edu/home/。应用它提供的很多库函数以及实例代码,可以帮助我们简化编程题目的难度。

题目

Programming Assignment 1: Percolation

Write a program to estimate the value of the percolationthreshold via Monte Carlo simulation.

Percolation. Given a composite systems comprised ofrandomly distributed insulating and metallic materials: whatfraction of the materials need to be metallic so that the compositesystem is an electrical conductor? Given a porous landscape withwater on the surface (or oil below), under what conditions will thewater be able to drain through to the bottom (or the oil to gushthrough to the surface)? Scientists have defined an abstractprocess known aspercolation to model such situations.

The model. We model a percolation system using anN-by-N grid ofsites. Each site iseitheropen or blocked. A full site isan open site that can be connected to an open site in the top rowvia a chain of neighboring (left, right, up, down) open sites. Wesay the systempercolates if there is a full site in thebottom row. In other words, a system percolates if we fill all opensites connected to the top row and that process fills some opensite on the bottom row. (For the insulating/metallic materialsexample, the open sites correspond to metallic materials, so that asystem that percolates has a metallic path from top to bottom, withfull sites conducting. For the porous substance example, the opensites correspond to empty space through which water might flow, sothat a system that percolates lets water fill open sites, flowingfrom top to bottom.)

Percolates

The problem. In a famous scientific problem, researchersare interested in the following question: if sites areindependently set to be open with probabilityp (andtherefore blocked with probability 1 −p), what is theprobability that the system percolates? Whenp equals 0,the system does not percolate; whenp equals 1, the systempercolates. The plots below show the site vacancy probabilityp versus the percolation probability for 20-by-20 randomgrid (left) and 100-by-100 random grid (right).

Percolation threshold for 20-by-20 grid                       
  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值