Go to Post Change your process to change your product. - Justin Montois [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Spotlight this post!  
Unread 30-07-2012, 20:30
Kristian Calhoun's Avatar
Kristian Calhoun Kristian Calhoun is offline
Celebrating 20 years of 25
FRC #0025 (Raider Robotix)
Team Role: Mentor
 
Join Date: Oct 2005
Rookie Year: 2006
Location: No. Brunswick, NJ
Posts: 1,077
Kristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond reputeKristian Calhoun has a reputation beyond repute
Send a message via AIM to Kristian Calhoun
Re: Replacing duplicates in a randomly generated array

One way to represent a set is by using a bit array:
  1. Create an array of size (max - min + 1).
  2. Initialize each element of this bit array to 0.
  3. When you generate a random number, x, check the value of the element in the bit array at index [x - min].
    • If the bit array value is 0, set the value at [x-min] in the bit array to 1.
    • If the bit array value is 1, then x already exists in the set, so generate another random number.
  4. Repeat the process until you've added setSize number of elements to the set.
__________________
Raider Robotix: Home | Twitter | Facebook | Instagram
Brunswick Eruption: Home | Twitter | Facebook

Last edited by Kristian Calhoun : 30-07-2012 at 21:06.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
Forum Jump


All times are GMT -5. The time now is 22:50.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi