BCA Math Q4b
BCA Math Q4b
b)
Defini ons:
Examples:
Defini on: The floor func on of a real number x is the largest integer less than or equal
to x. In simpler terms, it's the "rounding down" of x to the nearest integer.
Proper es:
o floor(x) <= x.
Defini on: The ceiling func on of a real number x is the smallest integer greater than or
equal to x. It's the "rounding up" to the nearest integer.
Proper es:
o ceil(x) >= x.
1. Rounding:
These func ons are fundamental for rounding numbers to the nearest integer, a common task in
numerical computa on.
2. Integer Arithme c:
They are used when you need the integer part of a number or to ensure that results of calcula ons
involving decimals remain in the integer domain.
3. Algorithm Design:
Array Indexing: In algorithms that deal with arrays, floor and ceiling can be used to
calculate appropriate array indices, especially when working with frac onal values.
Binary Search: Floor and ceiling are used in binary search algorithms to find the
closest elements in a sorted array to a given value.
4. Data Structures:
They can be used in the implementa on of data structures like heaps or trees, where integer
representa ons are needed.
In resource management, they can be used to determine the number of resources needed for a task
(e.g., rounding up the number of pages to print).
Hashing Algorithms:
Floor or ceiling may be used in index calcula ons or hash table resizing.
Scheduling Problems:
Tasks that span mul ple me slots may use ceiling to determine total slots.