永发信息网

求解计算机问题 代码题目

答案:1  悬赏:70  手机版
解决时间 2021-04-30 11:38

我考试题目啊 不然我会死的 只求代码

Assessment Description - Overview
Two di erent methods for generating random permutations of the numbers < 1; 2; : : : ; n >
are given in the module lecture notes. For this assessment you should implement both of
these in Java and present some ndings about their behaviour.
Assessment Description Details
The implementation should be given as a Java class,
public class Permutation
Class Fields
Type Description
private int [] permOne The permutation of < 1; 2; : : : ; n > produced
by Method 1.
private int [] permTwo The permutation of < 1; 2; : : : ; n > produced
by Method 2.
private Random randomSequence The random number sequence for this instance.
private int size The value of n for this instance.
private int counter1 Will hold the number of calls of the method
randomSequence.nextInt() made by Method 1.
private int counter2 Will hold the number of calls of the method
randomSequence.nextInt() made by Method 2.
Constructors
The class has a single constructor,
Permutation(int n)

The statement P = new Permutation(n) will create an instance (P) of the Permutation class to
be used to produce a random permutation n of the numbers < 1; 2; : : : ; n >. The constructor
must carry out the following:
a. Set size = n.
b. Instantiate the arrays PermOne and PermTwo as new int[n] with PermOne[i]=i+1 and
PermTwo[i]=i+1.
c. Create instance of the random number sequence via RandomSequence=new Random().
d. Set both counter1 and counter2 to be 0.

Instance Methods
Name Description
public void randomPermOne() Forms a random permutation of < 1; 2; : : : ; n >
in PermOne[].
Count number of calls to randomSequence.nextInt()
in the variable counter1.
This should use Method 1 of the lecture notes.
public void randomPermTwo() Forms a random permutation of < 1; 2; : : : ; n >
in PermTwo[].
Count the number of calls to randomSequence.nextInt()
in the variable counter2.
This should use Method 2 of the lecture notes.
public int[ ] getPermOne() Returns content of PermOne[]
public int[ ] getPermTwo() Returns content of PermTwo[]
public int getCountPermOne() Returns the value stored in counter1
after RandomPermOne() has been used.
public int getCountPermTwo() Returns the value stored in counter2
after RandomPermTwo() has been used.
Hints and Suggestions
Reminder - The Permutation Generation Methods
Note: The "easiest" way to record that k has been chosen (using the method described) is
to set TempPerm[k] = 0: in subsequent stages "k has not been chosen before" is the same as
"TempPerm[k]! = 0".
Algorithm 1 Method 1 for Generating Random Permutations of < 1; 2; : : : ; size >
nextPlace = 0
int[ ] tempPerm = new int[size]
for i = 0 to size

最佳答案
你要问什么?
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
不太懂???
我装了卡巴安全软件后网页打不开,请问更改卡
装宽带的问题
衬衣破了怎么补看不到痕迹
每天吃很多的各种各样的水果好吗?
青岛大学理科分数线大约是多少?多少分能上?
名扬快运士多店在什么地方啊,我要过去处理事
有谁知道这种头发叫什么名字的?
低血压要怎么办?
为什么有些人换季会长痘痘?
心口刺痛怎么办?
cf完整客户端
为何胎儿在肚子里面横着,这是怎么一回事情,
能给个手机QQ2010触屏JAVA下载地址么??急
大家谁知道Photoshop cs4哪里能下载完整版?
推荐资讯
电脑第一次和第2次开机就会卡着死机,第3.4次
这赛季詹姆斯能超越科比吗?
帮我看一下手工
DNF中到底有没有万人斩这把武器?
所谓金牌导购的标准是?
我姓李女儿2009年10月27日出生帮忙起一个名字
易赛代理软件最新版是什么,谁可以发易赛数据
请评下这首黑色的童话
济南哪里有魔方专卖店?
求腾讯出的手机游戏帝国的加速版
屏蔽怎样设置的?
如何点亮QQ2009所有图标
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?