Ask Question
2 June, 14:23

Cutting a stick A stick n inches long needs to be cut into n 1-inch pieces. Outline an algorithm that performs this task with the minimum number of cuts if several pieces of the stick can be cut at the same time. Also give a formula for the minimum number of cuts.

+3
Answers (1)
  1. 2 June, 14:57
    0
    The algorithm and its formula are given below

    Explanation:

    Algorithm:

    Start

    Input Length of stick in inches

    while (1) do / / Loop runs until break statement execute

    if (inchesOfStick = = 1) do / / If there is 1 inch stick

    break / / exit from loop

    end if

    if (inchesOfStick % 2 = = 0) do / / if the inches remaining is even

    inchesOfStick / = 2 / / Forula to cut

    end if

    else if (inchesOfStick % 2 = = 1) do / / if the inches remaining is odd

    inchesOfStick = (inchesOfStick + 1) / 2 / / Formula to cut

    increment minimumCuts

    end else

    end while

    print minimum number of cuts

    end program
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Cutting a stick A stick n inches long needs to be cut into n 1-inch pieces. Outline an algorithm that performs this task with the minimum ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers