IT Community - Software Programming, Web Development and Technical Support

Duplicate elements from an array

This is a discussion on Duplicate elements from an array within the C and C++ Programming forums, part of the Software Development category; Hui Guys please let me know How to remove duplicate elements from an array...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C and C++ Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 08-14-2007, 12:00 AM
vigneshgets vigneshgets is offline
D-Web Genius
 
Join Date: Mar 2007
Posts: 904
vigneshgets is on a distinguished road
Exclamation Duplicate elements from an array

Hui Guys please let me know How to remove duplicate elements from an array
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-06-2007, 08:04 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Wink Re: Duplicate elements from an array

Yes u can using a single pass of a loop....

but it may use an extra array space and the integer range shoould be
specified...
consider the array NUM[1...n]
consdier all numbers in the array are within the range 1...k then we
have another array A from 1...k

then the loop would be...

Code:
for(i=0;i<n;i++)
{

if(A[NUM[i]]==0)
{
A[NUM[i]]=1;
}
if(A[NUM[i]]==1)
{
printf("%d",NUM[i]);
}
}
this loop structure prints only the repeated elements in an array of
integers....
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicate Content vadivelanvaidyanathan Search Engine Optimization 11 02-27-2008 11:10 AM
Removing duplicate rows in a DataSet shaalini ASP and ASP.NET Programming 2 02-13-2008 09:33 PM
Would I get penalized for search engine duplicate content? a.deeban HTML, CSS and Javascript Coding Techniques 1 09-05-2007 11:36 AM
What’s the difference between the System.Array.CopyTo() and System.Array.Clone() ? Archer C# Programming 2 08-25-2007 03:00 AM
How can you sort the elements of the array in descending order In C#. NET 2005? Archer C# Programming 1 07-24-2007 12:33 AM


All times are GMT -7. The time now is 09:42 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0