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

  • Home
  • SEARCH
  • 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 8507987
In Process

The Archive Base Latest Questions

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

This question is for a program I am trying to write which involves connecting

  • 0

This question is for a program I am trying to write which involves connecting chains of physical parts together. I believe I have distilled it down into the simplest form of the question. I would also appreciate if someone knows any additional words that describe this problem, as about 30 min of searching for related questions hasn’t even turned up a name for this problem.

You have N vectors. If you choose one value from each vector and do not allow any repeats, you will have one permutation of the type I am trying to find. What is a pseudo-code algorithm to find all of them without brute forcing?

Example:
You have the vectors

v1=[1 2]   v2=[1 2 3]   v3=[1 2 3 4]  

(Edit note: The nesting of the vectors is unintentional and cannot be leveraged in the algorithm.)
You pick values from each of the vectors and don’t allow repeats.

Value 1 is from v1 ---> 2
Value 2 is from v2 ---> 1   
Value 3 is from v3 ---> 4

Resulting permutation is [2 1 4].

This is one allowable permutation. Here is an example of a permutation that is not allowed because it repeats.

Value 1 is from v1 ---> 2
Value 2 is from v2 ---> 1
Value 3 is from v3 ---> 2    

Resulting permutation is [2 1 2], which is invalid due to repeats.

What is an algorithm to find all valid permutations?

Bonus points if you can calculate how many permutations there are before calculating them.

I’ll be sure to post back if I can come up with an answer before anyone else can.

  • 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-11T03:01:46+00:00Added an answer on June 11, 2026 at 3:01 am

    The example you give has nested vectors, meaning that the entries in v_i are a subset of those in v_{i+1}. If this is indeed the general case for your application, then the number of solutions is simply:

    n_1 * (n_2 - 1) * ... * (n_k - (k-1))
    

    where n_i is the length of v_i and there are k nested vectors.

    As far as algorithms are concerned, if you want to generate all possible solutions, then I cannot see a better way than to choose from each successive vector after eliminating already selected entries.

    If you aren’t nested, a good way to visualize this problem is as a Marriage Problem in the following sense. Make k vertices corresponding to the given k vectors

    v_1  v_2 ...  v_k
    

    and another m vertices corresponding to the distinct entries of the combined vectors

    a_1 a_2 ... a_m
    

    Then connect a_i to v_j if and only if a_i appears in v_j. The goal is to find a maximum matching between the vs and the as that touches all of the v‘s. That is, choose k edges so that each v_i is an endpoint of exactly one edge.

    Any of the standard algorithms, e.g. using augmented paths, will work to find one solution or generate them all.

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

Sidebar

Related Questions

This is a homework question. I have to write a program forking itself 20
Dear all,Now i have this question in my java program,I think it should be
This is the question. write a program that prompts the user to input five
NOTE: This is a followup to my question here. I have a program that
note: I am sorry if this is a stupid question! I have this program
I'm trying to learn Haskell and want to write a small program which prints
I am trying to write a program in Java, which would collect a specified
Imagine we have a program trying to write to a particular file, but failing.
I'm trying to write a program that creates a 2D grid in which the
This question has baffled myself and my cohorts. In the program I had written

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.