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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:04:15+00:00 2026-05-16T21:04:15+00:00

I am having writing an algorithm to generate all possible permutations of an array

  • 0

I am having writing an algorithm to generate all possible permutations of an array of this kind:

n = length
k = number of 1’s in array

So this means if we have k 1’s we will have n-k 0’s in the array.

For example:
n = 5;
k = 3;

So obviously there are 5 choose 3 possible permutations for this array because

n!/(k!(n-k)!
5!/(3!2!) = (5*4)/2 = 10
possible values for the array

Here are all the values:
11100
11010
11001
10110
10101
10011
01110
01101
01011
00111

I am guessing i should use a recursive algorithms but i am just not seeing it. I am writing this algorithm in C++.

Any help would be appreciated!

  • 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-16T21:04:15+00:00Added an answer on May 16, 2026 at 9:04 pm

    You can split up the combinations into those starting with 1 (n-1, k-1) and those starting with 0 (n-1, k).

    This is essentially the recursive formula for the choose function.

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

Sidebar

Related Questions

Possible Duplicate: Generate list of all possible permutations of a string I need to
I am having issues writing this string to my SQL 200 database table: Conversion
I am writing a problem to solve Job schedules but I am having a
I started using ZeroMQ this week, and when using the Request-Response pattern I am
I'm having the hardest time trying to figure out how to balance an AVL
I've been thinking about writing a text editor control that can edit text that
I consider myself fairly competent in understanding and manipulating C-ish languages; it's not a
I am going to be learning Ruby , Haskell and Prolog at university. Now,
I am currently developing an application in C# where I need to write a
The user should input some file names in the command line and the program

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.