• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Cake

 
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q: How many cuts can a round cake have in order to get the maximum number of similar size pieces? justify the answer?

This is a famous interview question..well now most of candidates prepare that question before it asks in an interview but when your first time facing it in a interview its a pretty decent question to measure your analytical or the way of you thinking
 
Marshal
Posts: 67446
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends how sharp the knife is.
 
Marshal
Posts: 25798
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is of course the mathematical ideal cake, right? The one which doesn't break into crumbs as you cut it?

In which case there isn't a maximum number of similar-sized pieces. With n cuts you can always make 2n pieces, no matter how large n is.
 
Harshana Dias
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:This is of course the mathematical ideal cake, right? The one which doesn't break into crumbs as you cut it?

In which case there isn't a maximum number of similar-sized pieces. With n cuts you can always make 2n pieces, no matter how large n is.



opss yes...my mistake..question would be how many minimum cuts need to get equal size 8 pieces of the cake?

:D
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
3
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please explain how 3 cuts makes 8 pieces ?
 
Paul Clapham
Marshal
Posts: 25798
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first cut divides the cake into two pieces. The second cut, which passes through both of those pieces, divides them into four pieces. The third cut, which passes through all four pieces, divides them into eight pieces.

Since this is the mathematical no-crumb cake, four cuts produce 16 pieces, five cuts produce 32 pieces... you should be getting the picture by now.
 
Bartender
Posts: 1848
15
Eclipse IDE Spring VI Editor Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:The first cut divides the cake into two pieces. The second cut, which passes through both of those pieces, divides them into four pieces. The third cut, which passes through all four pieces, divides them into eight pieces.

Since this is the mathematical no-crumb cake, four cuts produce 16 pieces, five cuts produce 32 pieces... you should be getting the picture by now.



They are not similar sized pieces. Or if they are I need a diagram :wink:
 
Rancher
Posts: 3625
40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They can be, if you are permitted to rearrange pieces in between cuts. Nothing in the problem statement seems to preclude this.

For the version of the problem requiring just eight pieces, it's possible to do this without rearranging pieces - if the top and bottom of the cake are identical. Or at least if they're similar enough that the eight octants can be considered "similar sized". For a cake with frosting, most of us would not consider pieces from the top to be equivalent to pieces from the bottom. but perhaps we're supposed to overlook that.
 
Bear Bibeault
Marshal
Posts: 67446
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Give me a piece without frosting and someone gets hurt!
 
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic