Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 6 Max. score: 20.00 Minimum steps You have a starting number X. You can perform one of the following operations on it any number

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Question 6 Max. score: 20.00 Minimum steps You have a starting number X. You can perform one of the following operations on it any number of times: - Multiply by 2 - Divide X by 2 . ( X mst be even to perform this operation) Task Determine the minimum number of steps required to reach Y starting from X, or print 1 if it is not possible. Example Assumptions x=24 - Y=6 Approach - You can perform the operation of the second type twice to reach 6. It can be shown that it is not possible to reach 6 in less than 2 operations, so the answer is 2. Function description Complete the function solve provided in the editor. This function takes the following 2 parameters and returns the required answer: 0/8 Completed the following 2 parameters and returns the required answer: - Represents the value of X - Y Represents the value of Y Input format Note: This is the input format that you must use to provide custom input (available above the Compile and Test button). - The first line contains a single integer T which denotes the number of test cases. T also denotes the number of times you have to run the solve function on a different set of inputs. - For each test case: - The first line contains a single integer x denoting the value of X. - The second line contains a single integer Y denoting the value of Y. Output format For each test case, print a single line containing a single integer representing the answer. Constraints 1T105 1X,Y1018 x=24 y=16

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions