Recover an unknown capacity

A PermitPool ADT begins with all C permits available, where C is an unknown positive integer. For positive integer k, take(k) returns true and removes k permits when enough are available; otherwise it returns false and leaves availability unchanged. available() reports availability without changing it.


Consecutive calls produce these results: take(7) returns true, take(8) returns false, take(4) returns true, and available() returns 3. What is the initial capacity C? Answer in permits, to zero decimal places.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Abstract Data Types (ADTs) Questions: