-6
リンクリストとサイズ変更の配列でいくつかのテストをしています.2のべき乗と2のべき乗+1のテストを行う必要があります(1,2,3,4,5,8,9,16,17)Javaで2^nから(2^n + 1)に変更するにはどうすればよいですか?
私は自分自身に2のべき乗のためにうまくそれをやっているコードをビルドしましたが、2プラスワン
のないFRパワーがここに私のコード
public static void testsForLinkedLists(int maxPowerOf,
int intendedRepeats, String excelFile,
IntToDoubleFunction pushMethod, IntToDoubleFunction popMethod) {
ArrayList<Double> listOfPushTimes = new ArrayList<Double>();
ArrayList<Double> listOfPopTimes = new ArrayList<Double>();
double maxPush = 0;
double minPush = 100;
double maxPop = 0;
double minPop = 100;
double medianPush = 0;
double medianPop = 0;
double sumPush = 0;
double sumPop = 0;
double averagePush = 0;
double averagePop = 0;
int total = 0;
int excelLine = 1;
//int actualPowerOf = 0;
for (int actualPowerOf = 0; actualPowerOf < maxPowerOf; actualPowerOf++) {
listOfPushTimes.clear();
listOfPopTimes.clear();
//actualPowerOf++;
maxPush = 0;
minPush = 100;
maxPop = 0;
minPop = 100;
medianPush = 0;
medianPop = 0;
sumPush = 0;
sumPop = 0;
averagePush = 0;
averagePop = 0;
total = 0;
int powerOf2 = (int)Math.pow(2, actualPowerOf);
for (int i = 0; i < intendedRepeats; i++) {
double timetopush = pushMethod.applyAsDouble(powerOf2);
listOfPushTimes.add(timetopush);
sumPush = sumPush + timetopush;
if (timetopush > maxPush) {
maxPush = timetopush;
}
if (timetopush < minPush) {
minPush = timetopush;
}
double timetopop = pushMethod.applyAsDouble(powerOf2);
listOfPopTimes.add(timetopop);
sumPop = sumPop + timetopop;
if (timetopop > maxPop) {
maxPop = timetopop;
}
if (timetopop < minPop) {
minPop = timetopop;
}
total++;
}
averagePush = sumPush/total;
averagePop = sumPop/total;
medianPush = measuring_tools.medianOf(listOfPushTimes);
medianPop = measuring_tools.medianOf(listOfPopTimes);
}
どのように私はそう私のコードを編集することができますそれは2プラス+1のパワーのテストを実行する?
は、あなたが変数に1を追加することができますどのように私たちを求めていますか? –
はい、私はそれをどのようにするのですか? –
あなたはすべて書きましたが、変数に1を追加する方法が分かりません。それはまったく疑わしいとは思わない。 – Shadov