subject
Engineering, 18.09.2021 08:40 nsutton9985

Given an integer, store its binary representation bin as a string or an array with digits indexed from 0 to
length(bin) - 1. Reduce its binary representation to
zero by using the following operations:
1. Change the ith binary digit only if (i+1)th binary
digit is 1 and all other binary digits from (i+2) to
the end are zeros.
2. Change the rightmost digit without restriction.
What is the minimum number of operations
required to complete this task?
Example
n = 4
The binary representation of 4 is 100 so for the
example, bin = [1, 0, 0].
100 101 111 110 → 010 011 001
-> 000

ansver
Answers: 2

Another question on Engineering

question
Engineering, 04.07.2019 16:10
The force on a cutting tool are 2600n vertically downward and 2100 horizontal. determine the resultant force acting on the tool and the angle at which it acts.
Answers: 1
question
Engineering, 04.07.2019 18:10
Fluids at rest possess no flow energy. a)- true b)- false
Answers: 3
question
Engineering, 04.07.2019 18:10
During a steady flow process, the change of energy with respect to time is zero. a)- true b)- false
Answers: 2
question
Engineering, 04.07.2019 18:10
The higher the astm grain size number, the finer the gran is. a)-true b)-false
Answers: 2
You know the right answer?
Given an integer, store its binary representation bin as a string or an array with digits indexed...
Questions
question
Mathematics, 04.05.2021 20:20
question
Mathematics, 04.05.2021 20:20
question
Mathematics, 04.05.2021 20:20
question
Mathematics, 04.05.2021 20:20
question
Mathematics, 04.05.2021 20:20
Questions on the website: 13722363