Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Apr 24, 2001

Reversing Array Elements in O(n/2)


Reversing Array Elements in O(n/2) where n is the number of elements:
 
Public Sub ReverseArray(arrPerson() as String)
Dim iIndex As Integer
Dim strTemp As String
  For iIndex=LBound(arrPerson) To UBound\2(arrPerson)
    strTemp=arrPerson(iIndex)

arrPerson(iIndex)=arrPerson(UBound(arrPerson)-iIndex+LBound(arrPerson))
    arrPerson(UBound(arrPerson)-iIndex)=strTemp
  Next
End Sub
Prasad Haridass
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap