Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » Eliminate Duplicates in an array
Closed Thread
Old 12-11-2006, 07:03 PM   #1 (permalink)
 
Junior Techie

Join Date: Oct 2005

Posts: 63

RobertXYZ

Default Eliminate Duplicates in an array

I created an array with VB-6 which contains appr 6000 company
names,many names are entered several times.

Ex: arr (1) = "ABC"
arr1 (2) = "BBC"
arr1(3) = "FFF"
arr1(4) = "GGG"
arr1(5) = "ABC"
arr1(6) = "BBC"

How can I achieve to have only one name ? The above
example should then look like:

arr2(1) = "ABC"
arr2(2) = "BBC"
arr2(3) = "FFF"
arr2(4) = "GGG"

Any suggestions ?
RobertXYZ is offline  
Old 12-11-2006, 11:29 PM   #2 (permalink)
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,410

office politics will become famous soon enough

Default

i would say alphabetically sort the data. i remember hearing bubble sort being very efficient. then iterate through all elements. check if arr(n) = arr(n - 1). if it does then remove arr(n - 1). i dont know if you can implement a doubly linked list in VB6 but if you were writing in C, it would be the way to go. it would make removing elements easier as you wouldnt have to shift the remaining elements forward.

doubly linked lists
http://en.wikipedia.org/wiki/Linked_...ly-linked_list

bubble sort
http://en.wikipedia.org/wiki/Bubble_sort
office politics is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On