Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Chocolate stack A shop has a stack of chocolate boxes each containing a positive number of chocolates. Initially, the stack is empty. During the next

Chocolate stack
A shop has a stack of chocolate boxes each containing a positive number of chocolates. Initially, the stack is empty. During the next N minutes, either of these two things may happen:
The box of chocolates on top of the stack gets sold
You receive a box of chocolates from the warehouse and put it on top of the stack.
Determine the number of chocolates in the sold box each time he sells a box.
Notes
If C[i]=0, he sells a box. If C[i]>0, he receives a box containing C[I] chocolates.
It is confirmed that he gets a buyer only when he has a non- empty stack.
The capacity of the stack is infinite.

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

Students also viewed these Databases questions