ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Programming Assignment 1: Percolation

2021-02-15 11:33:19  阅读:230  来源: 互联网

标签:Percolation int Assignment Programming col double open public row


Percolation API

public class Percolation {
   public Percolation(int n)                // create n-by-n grid, with all sites blocked
   public void open(int row, int col)       // open site (row, col) if it is not open already
   public boolean isOpen(int row, int col)  // is site (row, col) open?
   public boolean isFull(int row, int col)  // is site (row, col) full?
   public int numberOfOpenSites()           // number of open sites
   public boolean percolates()              // does the system percolate?

   public static void main(String[] args)   // test client (optional)
}

isFull()中,蓝色区域为full,即连通区域内的白色方块。

 

我们虚设了两个方块,来判断整个系统的连通性,为了解决回渗问题,建立2个检测WeightedUnion.当来到最后一层的时候,一个与n*n+1相连接,一个不连,最后判断isfull()时可以避免回渗问题。

PercolationStats API

 

public class PercolationStats {
  public PercolationStats(int n, int trials)    // perform trials independent experiments on an n-by-n grid
  public double mean()                          // sample mean of percolation threshold
  public double stddev()                        // sample standard deviation of percolation threshold
  public double confidenceLo()                  // low  endpoint of 95% confidence interval
  public double confidenceHi()                  // high endpoint of 95% confidence interval

  public static void main(String[] args)        // test client (described below)
}

 

 


蒙特卡洛算法,对于在n*n个方格图,随机打开一个方格,检测是否percolate。

标签:Percolation,int,Assignment,Programming,col,double,open,public,row
来源: https://www.cnblogs.com/JasonJ/p/14403417.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有