Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6354581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:35:54+00:00 2026-05-24T22:35:54+00:00

Note: This is part 2 of a 2 part question. Part 1 here I’m

  • 0

Note: This is part 2 of a 2 part question.

Part 1 here

I’m wanting to more about sorting algorithms and what better way to do than then to code! So I figure I need some data to work with.

My approach to creating some “standard” data will be as follows: create a set number of items, not sure how large to make it but I want to have fun and make my computer groan a little bit 😀

Once I have that list, I’ll push it into a text file and just read off that to run my algorithms against. I should have a total of 4 text files filled with the same data but just sorted differently to run my algorithms against (see below).

Correct me if I’m wrong but I believe I need 4 different types of scenarios to profile my algorithms.

  • Randomly sorted data (for this I’m going to use the knuth shuffle)
  • Reversed data (easy enough)
  • Nearly sorted (not sure how to implement this)
  • Few unique (once again not sure how to approach this)

This question is for generating a list with a few unique items of data.

Which approach is best to generate a dataset with a few unique items.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:35:54+00:00Added an answer on May 24, 2026 at 10:35 pm

    Answering my own question here. Don’t know if this is the best but it works.

        public static int[] FewUnique(int uniqueCount, int returnSize)
        {
            Random r = _random;
            int[] values = new int[uniqueCount];
            for (int i = 0; i < uniqueCount; i++)
            {
                values[i] = i;
            }
    
            int[] array = new int[returnSize];
            for (int i = 0; i < returnSize; i++)
            {
                array[i] = values[r.Next(0, values.Count())];
            }
    
            return array;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Note : The code in this question is part of deSleeper if you want
(NOTE: This question is not about escaping queries, it's about escaping results) I'm using
Note: This question was originally part of Magento SOAP API V2 with C#: Issue
Note 1: This is my first question here. Please be gentle. Note 2: Yes,
Important note : this question is not about the superiority of a bracing style
Note This is not a REBOL-specific question. You can answer it in any language.
Note this question was originally posted in 2009, before C++11 was ratified and before
I recently asked this question here and got some great answers! Custom SQL GROUP
Update: What I really wanted all along were greenlets . Note: This question mutated
Here's a deceptively simple question: What is the proper way to asynchronously play an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.