Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The current code will generate a mapping ( that is , a dictionary ) based on a seed and an upper bound values provided by

The current code will generate a mapping (that is, a
dictionary) based on a seed and an upper bound values provided by the user. Your task is to process the
list of cycles based on the generated mapping and the reversed dictionary as described below.
expected output:
Enter two integers: 1238
The generated mapping is:
{1: 11,2: 13,3: 38,4: 38,5: 6,6: 36,7: 9,8: 37,9: 4,10: 9,11: 36,
12: 6,13: 3,15: 29,16: 8,17: 13,19: 22,20: 3,21: 38,22: 33,24: 12,25:
4,27: 11,28: 23,29: 22,30: 3,31: 11,32: 17,33: 9,34: 26,35: 30,36:
31,37: 22,38: 37}
The keys are, from smallest to largest:
[1,2,3,4,5,6,7,8,9,10,11,12,13,15,16,17,19,20,21,22,24,
25,27,28,29,30,31,32,33,34,35,36,37,38]
Properly ordered, the cycles given by the mapping are:
[[4,38,37,22,33,9],[11,36,31]]
The (triply ordered) reversed dictionary per lengths is:
{1: {8: [16],
12: [24],
17: [32],
23: [28],
26: [34],
29: [15],
30: [35],
31: [36],
33: [22]},
2: {4: [9,25],6: [5,12],13: [2,17],36: [6,11],37: [8,38]},
3: {3: [13,20,30],
9: [7,10,33],
11: [1,27,31],
22: [19,29,37],
38: [3,4,21]}}
getting output:
Enter two integers: 1238
The generated mapping is:
{1: 11,2: 13,3: 38,4: 38,5: 6,6: 36,7: 9,8: 37,9: 4,10: 9,11: 36,12: 6,13: 3,15: 29,16: 8,17: 13,19: 22,20: 3,21: 38,22: 33,24: 12,25: 4,27: 11,28: 23,29: 22,30: 3,31: 11,32: 17,33: 9,34: 26,35: 30,36: 31,37: 22,38: 37}
The keys are, from smallest to largest:
[1,2,3,4,5,6,7,8,9,10,11,12,13,15,16,17,19,20,21,22,24,25,27,28,29,30,31,32,33,34,35,36,37,38]
Properly orderes, the cycles given by the mapping are:
[[11,31,36],[4,9,22,33,37,38]]
The (triply ordered) reversed dictionary per length is:
{1: {8: [16],12: [24],17: [32],23: [28],26: [34],29: [15],30: [35],31: [36],33: [22]},2: {4: [9,25],6: [5,12],13: [2,17],36: [6,11],37: [8,38]},3: {3: [13,20,30],9: [7,10,33],11: [1,27,31],22: [19,29,37],38: [3,4,21]}}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

50 Tips And Tricks For MongoDB Developers Get The Most Out Of Your Database

Authors: Kristina Chodorow

1st Edition

1449304613, 978-1449304614

More Books

Students also viewed these Databases questions

Question

b. Where did they come from?

Answered: 1 week ago