File tree 4 files changed +45
-0
lines changed
Sorting Algorithm/BubbleSort
4 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ Imports System.IO
2
+ Imports System.Text
3
+
4
+ Module Module1
5
+
6
+ Sub Main()
7
+ Dim path As String = "c:\temp\MyTest.txt"
8
+
9
+ ' Creates (or overwrites) the file in the directory "c:\temp\MyTest.txt".
10
+ Dim fs As FileStream = File.Create(path)
11
+
12
+ ' Add text to the file.
13
+ Dim info As Byte () = New UTF8Encoding( True ).GetBytes( "This is some text in the file." )
14
+ fs.Write(info, 0 , info.Length)
15
+ fs.Close()
16
+ End Sub
17
+
18
+ End Module
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ def BubbleSort (lst ):
2
+ lst = list (lst ) #copy collection to list
3
+ for passesLeft in range (len (lst )- 1 , 0 , - 1 ):
4
+ for i in range (passesLeft ):
5
+ if lst [i ] < lst [i + 1 ]:
6
+ lst [i ], lst [i + 1 ] = lst [i + 1 ], lst [i ]
7
+ return lst
Original file line number Diff line number Diff line change
1
+ Module Module1
2
+ Sub Bubblesort(Array() as Integer , Length as Integer )
3
+ Dim I As Integer
4
+ Dim J As Integer
5
+ Dim Temp As Integer
6
+ Dim Length As Integer
7
+ Dim Array() As String = {}
8
+
9
+ For I = Length - 1 To 1 Step - 1 'the last element on the array does not get sorted.
10
+ For J = 0 To I - 1
11
+ If Array(J) > Array(J + 1 ) Then ' Compare neighboring elements
12
+ Temp = Array(J)
13
+ Array(J) = Array(J + 1 )
14
+ Array(J + 1 ) = Temp
15
+
16
+ End If
17
+ Next
18
+ Next
19
+ End Sub
20
+ End Module
You can’t perform that action at this time.
0 commit comments