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 8706317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:35:11+00:00 2026-06-13T03:35:11+00:00

I am working with large number of integer permutations. The number of elements in

  • 0

I am working with large number of integer permutations. The number of elements in each permutation is K. The element size is 1 byte. I need to generate N unique random permutations.
Constraints: K <= 144, N <= 1,000,000.

I came up with the following straightforward algorithm:

  1. Generate list of N random permutations. Store all permutations in RAM.
  2. Sort the list and delete all duplicates (if any). The number of duplicates will be relatively small.
  3. If there were any duplicates, add random permutations to the list until there are N permutations and return to step 2.

Is there a better way to do this? Especially, is there a way to not store all permutations in RAM (write them on disk while generating)?

Edit: In the end, the generated permutations need to be accessed sequentially (one-by-one, no need for random access). The RAM is more crucial factor (I would prefer to not store all permutations at once in RAM).

  • 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-06-13T03:35:13+00:00Added an answer on June 13, 2026 at 3:35 am

    One possible solution is using bloom filters.

    Store your permutations on disk (write them sequentially) and maintain a bloom filter in RAM.

    Once you generate a permutation – check if it exists in the bloom filter, if the bloom filter says it is not written to disk yet- write it, bloom filters don’t have false negatives.

    If the bloom filter however says it is on the disk – it might be wrong..

    if the bloom filter said “the permutation already exists”, you can decide if you want to quit this candidate and go to the next one without checking if it is really already in the set, or you can search the disk to see if it is really there.

    If you chose the later, you should consider maintaining a smart DS for the permutations such as a hash table or a B+ tree.

    Bloom Filters are perfect match in here – they are designed to represent a set that is expansive to read, while giving 0 false negatives, which is the most important thing here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a project to parse out unique words from a large number
I'm working on a website with a large number of pages, and each one
I am working on a large number adding program (without using biginteger class). I
I am working on porting a large number of .h and .lib files from
I'm working on an interesting project that involves displaying a large number of photos.
I'm working on a project involving enlisting a large number of relatively unskilled workers
I am working on a web page that has a large number of tables.
I'm working on a project which generates a very large number of sequential text
I am working on an application that processes a large number of files placed
I am working on a project requiring me to scan through a large number

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.