Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee4cf21

Browse files
Update HeapSort.java
minor changes in variables and removed extra variables.
1 parenta95b4ac commitee4cf21

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

‎Sorting/HeapSort.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
packagesorting;
22

3-
importjava.util.Random;
3+
importjava.util.*;
44

55
publicclassHeapSort {
66

@@ -31,20 +31,20 @@ private void sink(int[] arr, int index, int N) {
3131
}
3232

3333
privatevoidswap(int[]arr,intindex1,intindex2) {
34-
inttemp =arr[index1];
34+
intt =arr[index1];
3535
arr[index1] =arr[index2];
36-
arr[index2] =temp;
36+
arr[index2] =t;
3737
}
3838

3939
publicstaticvoidmain(String[]args) {
4040
HeapSortheap =newHeapSort();
4141

42-
intN =10;
43-
int[]arr =newint[N];
42+
43+
int[]arr =newint[10];
4444
Randomrm =newRandom();
4545
System.out.println("Original array: ");
4646
for(inti=0;i<arr.length;i++) {
47-
arr[i] =rm.nextInt(100);
47+
arr[i] =rm.nextInt(50);
4848
System.out.print(arr[i] +" ");
4949
}
5050

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp