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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:35:45+00:00 2026-06-04T04:35:45+00:00

I have a Map<Integer, List<Float>> that represent a position with some scores, and I

  • 0

I have a Map<Integer, List<Float>> that represent a position with some scores, and I would like to generate all possible combinations of scores per position (essentially the cross-product of each list from the original map) into a List<List<Float>>. So let’s say I have the following map:

{ 1 => [0.1f, 0.2f], 2 => [0.3f, 0.4f] }

I would to get the following list of lists of floats:

[[0.1f, 0.3f], [0.1f, 0.4f], [0.2f, 0.3f], [0.2f, 0.4f]]

I am pretty sure I have to use recursion, just not sure how to go on about it..

  • 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-04T04:35:45+00:00Added an answer on June 4, 2026 at 4:35 am

    any time you have a recursive algorithm to code, you need an inductive definition to help design it.

    base case: {} ↦ []
    inductive step: M ↦ L ⇒ ( M ∪ { n ↦ S } ) ↦ L × S

    For each element in S, you add it to the end of every list in L, and add the resulting list to your output.

    List<List<Float>> llfNext = new LinkedList<List<Float>>();
    for (float f : entEach.getValue())
        for (List<Float> lfEach : llfInductive)
            llfNext.add(copyAndAddToEnd(lfEach, f));
    return llfNext;
    

    It should be pretty easy from here, and then you can make it non-recursive and reduce some of the copying going on.

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

Sidebar

Related Questions

Possible Duplicate: Java Ordered Map I have list of product object in the HashMap<Integer,Product>
I have a list of Map.Entry<String,Integer> s that I am looping through, and for
So I have xml that looks like this: <todo-list> <id type=integer>#{id}</id> <name>#{name}</name> <description>#{description}</description> <project-id
I have a Map that uses a Set for the key type, like this:
I have a list of Team objects that have an Integer seed property. I
We have a List of items: List<X> from this List, we would like to
If I have a Map like this: HashMap<Integer, ComparableObject> map; and I want to
I have a Map Map<Integer, List> with key, values. I need to convert this
I have a nested map: Map<Integer, Map<Integer, Double>> areaPrices = new HashMap<Integer, Map<Integer, Double>>();
I have two maps of type Map<Long, Integer>, one named oldValues representing the old

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.