Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose you have a cake for a pizza) and you want to use a knife to have long straight cuts through it. Your line cuts

image text in transcribed

image text in transcribed

Suppose you have a cake for a pizza) and you want to use a knife to have long straight cuts through it. Your line cuts DO NOT meet at a central point With one long straight cut, you cut the cake into two pieces. With two long straight cuts, you cut the cake into four pieces. . With three long straight cuts, you cut the cake into seven pleces, and so on. The figure below illustrates: Maximal number of pieces formed when slicing a pancake with nei 2 2 7 11 16 To calculate the number of pieces you can make with n cuts, you can use the following equation: noCuts = 2**n+2 You are required to write a function that takes as input the maximum number of cuts n, then computes and stores in an array the number of cuts you will have as you go cutting your cake from O cuts to n cuts. However, your function will not return the number of cuts. Instead, it will return an array that holds the difference between the number of cuts done this way, and the number of cuts if your lines go through the center of the cake. return an array that holds the difference between the number of cuts done this way, and the number of cuts if your lines go through the center of the cake. 1/C Input: One line containing the number of straight cuts that do not pass through the center Output: The difference between the total number of pieces if the cuts did not pass through the center, and if they passed through the center. The line will display the difference as you progress cutting the cake. Sample Testcase 0: Input: 5 Output: 000136 Explanation If your straight cuts do not pass throught the center, then you will have 1, 2, 4, 7, 11, 16 pieces. If your straight cuts always pass through the center, then you will have 1, 2, 4, 6, 8, 10 pieces. The function returns the array that holds the absolute difference in between #include

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

Students also viewed these Databases questions