-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava_BS.html
More file actions
106 lines (89 loc) · 2.96 KB
/
Copy pathjava_BS.html
File metadata and controls
106 lines (89 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="../img/CodeHelper.png">
<link rel="stylesheet" href="../css/style.css">
<link href="https://fonts.googleapis.com/css?family=Montserrat|Oswald|Roboto+Condensed" rel="stylesheet">
<title>CodeHelper | Helping students to learn Code.</title>
</head>
<body>
<header>
<nav>
<h1>CodeHelper</h1>
<ul>
<li><a class="homewhite" href="../main.html">Home</a></li>
<li><a class="sameclass" href="../contact_us.html">Contact Us</a>
<li><a class="sameclass" href="../about_us.html">About Us</a>
<li><a class="sameclass" href="#">Our Team</a>
<li><a class="sameclass" href="../login.html">Login</a></li>
<li><a class="sameclass" href="../signup.html">Sign Up</a></li>
</ul>
</nav>
</header>
<div class="main">
<div class="ptext">
<h1>Welcome to Code Helper </h1>
</div>
</div>
<div class="topmenu">
<nav>
<ul>
<li><a class="menucolor" target="_blank" href="../c.html">C</a></li>
<li><a class="menucolor" target="_blank" href="../c++.html">C++</a>
<li><a class="menucolor" target="_blank" href="../python.html">Python</a>
<li><a class="menucolor" target="_blank" href="../java.html">Java</a>
</ul>
</nav>
</div>
<div class="c-bs">
<h1> Bubble Sort</h1><br>
<p>
To find out the factorial of the give number.
</p><br>
<h2 class="source-code">➣ Source Code</h2>
<p>
<pre>
<xmp>
public class BubbleSortExample {
static void bubbleSort(int[] arr) {
int n = arr.length;
int temp = 0;
for(int i=0; i < n; i++){
for(int j=1; j < (n-i); j++){
if(arr[j-1] > arr[j]){
//swap elements
temp = arr[j-1];
arr[j-1] = arr[j];
arr[j] = temp;
}
}
}
}
public static void main(String[] args) {
int arr[] ={3,60,35,2,45,320,5};
System.out.println("Array Before Bubble Sort");
for(int i=0; i < arr.length; i++){
System.out.print(arr[i] + " ");
}
System.out.println();
bubbleSort(arr);//sorting array elements using bubble sort
System.out.println("Array After Bubble Sort");
for(int i=0; i < arr.length; i++){
System.out.print(arr[i] + " ");
}
}
}
</xmp>
</pre>
</p>
<h2 class="source-code"> ➣ Output</h1>
<pre style="font-size: 20px;">
Array Before Bubble Sort
3 60 35 2 45 320 5
Array After Bubble Sort
2 3 5 35 45 60 320
</pre>
</div>
<div class="back"> <a href="../c.html"> BACK </a> </div>
<div class="footermain">Made with ❤</div>