Ask Question
13 February, 04:31

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. 13 February, 08:29
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers