Question

By reading the title it may sound like a silly question, but I have a data structures exam tomorrow and some formulas I need to know for algorithm analysis are read as (n – floor(log (n + 1)). What is the meaning of floor?

Thanks

Was it helpful?

Solution

floor(x) is the largest integer not greater than x. You can easily find this information on the web, here for example.

e.g.

floor(1.12) = 1  
floor(0.53) = 0
floor(-3.4) = -4

One thing that can confuse people is the floor of a negative value. Some might initially think that floor(-3.4) is -3 when in reality it is -4 by the definition of floor(x).


As a note, floor(x) is often written as enter image description here.

OTHER TIPS

To round down to the nearest integer value.

For positive numbers: Remove the decimal portion. eg. floor(3.4): 3

For negative numbers: Remove the decimal portion and subtract one. eg. floor(-3.4): -3 - 1 = -4

Hope this helps.!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top