1 Replies - 1257 Views - Last Post: 03 March 2012 - 05:37 PM Rate Topic: -----

#1 DivaStyle  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 02-March 12

Sorting Algorithms

Posted 02 March 2012 - 02:25 PM

I am taking a programming class for the first time and I have an assignment with the following criteria:
Allows the user to enter 10 integers for sorting
Allows the user to select one of two types of sorting techniques (bubble sort and selection sort)
Allows the user to select either the ascending or descending order
Displays the sorted list of numbes according to the options selected by the user.

I've written the code, which I'm not sure is correct, but I've tried. However, I'm not sure how to write the codes for the sort techniques. Would you please give me some direction and help if the code below is not what it needs to be? Thanks


Public Class frmMain

' module-level array
Private strIntegers(9) As String
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click
' allow user to enter 10 integers for sorting
' stores ten integers in the module-level
' strIntegers array

lstNumbers.Items.Clear()

For intSub As Integer = 0 To strIntegers.GetUpperBound(0)
strIntegers(intSub) =
InputBox("Enter 10 Numbers")
Next intSub

End Sub

Private Sub btnAscending_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAscending.Click
' sorts the array values in ascending order, then
' displays the array values in ascending order

lstNumbers.Items.Clear()

Array.Sort(strIntegers)
For Each strInteger As String In strIntegers
lstNumbers.Items.Add(strInteger)
Next strInteger

End Sub

Private Sub btnDescending_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDescending.Click
' sorts the array values in decending order, then
' display the array values in descending order

lstNumbers.Items.Clear()

Array.Sort(strIntegers)
Array.Reverse(strIntegers)
For Each strInteger As String In strIntegers
lstNumbers.Items.Add(strInteger)
Next strInteger

End Sub

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class

This post has been edited by AdamSpeight2008: 02 March 2012 - 03:12 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Sorting Algorithms

#2 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 840
  • Joined: 21-December 11

Re: Sorting Algorithms

Posted 03 March 2012 - 05:37 PM

As far as I understood, you must wrote your own algorithm for sorting. Both bubble and selection technique. First you must learn and understand sorting techniques. Here you can find explanations and pseudo code:Bubble sort,Selection sort

This post has been edited by sela007: 03 March 2012 - 05:41 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1