notebook/notes/algebra/floor-ceiling.md

14 KiB

title TARGET DECK FILE TAGS tags
Floors & Ceilings Obsidian::STEM algebra algorithm
algebra

Overview

The floor of x is the greatest integer less than x. The ceiling of x is the least integer greater than x. These values are denoted \lfloor x \rfloor and \lceil x \rceil respectively.

%%ANKI Basic How is the floor of x denoted? Back: \lfloor x \rfloor Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic What is the floor of x? Back: The greatest integer less than or equal to x. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic How is the ceiling of x denoted? Back: \lceil x \rceil Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic What is the ceiling of x? Back: The least integer greater than or equal to x. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic When does \lfloor x / 2 \rfloor = \lceil x / 2 \rceil? Back: When x is even. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic When does \lfloor x / 2 \rfloor \neq \lceil x / 2 \rceil? Back: When x is odd. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic What does \lceil x \rceil - \lfloor x \rfloor equal? Back: Either 0 or 1. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic What can be said about x if \lceil x \rceil - \lfloor x \rfloor = 0? Back: x is an integer. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic What can be said about x if \lceil x \rceil - \lfloor x \rfloor = 1? Back: x is not an integer. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic What values of x satisfy \lfloor x \rfloor = \lceil x \rceil - 1? Back: Non-integral values. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic What values of x satisfy \lceil x \rceil = \lfloor x \rfloor + 1? Back: Non-integral values. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic What values of x satisfy \lfloor x \rfloor = \lceil x \rceil + 1? Back: None. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic What values of x satisfy \lceil x \rceil = \lfloor x \rfloor - 1? Back: None. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic For what values k is horizontal and vertical shifting of \lfloor x \rfloor the same? Back: Integral values. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic What C operator corresponds to floor division? Back: None. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic What C operator corresponds to integer division? Back: / Reference: Bryant, Randal E., and David O'Hallaron. Computer Systems: A Programmer's Perspective. Third edition, Global edition. Always Learning. Pearson, 2016.

END%%

%%ANKI Basic When does C operator / behave like floor division? Back: When the result is a nonnegative value. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic When does C operator / behave like ceiling division? Back: When the result is a nonpositive value. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic What C operator corresponds to ceiling division? Back: None. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic How does C evaluate 10 / 3? Back: 3 Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994). Tags: c17

END%%

%%ANKI Basic How does C evaluate floor(10.f / 3)? Back: 3 Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994). Tags: c17

END%%

%%ANKI Basic How does C evaluate ceil(10.f / 3)? Back: 4 Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994). Tags: c17

END%%

%%ANKI Basic How does C evaluate -10 / 3? Back: -3 Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994). Tags: c17

END%%

%%ANKI Basic How does C evaluate floor(-10.f / 3)? Back: -4 Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994). Tags: c17

END%%

%%ANKI Basic How does C evaluate ceil(-10.f / 3)? Back: -3 Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994). Tags: c17

END%%

%%ANKI Basic Given r = \lfloor (p + q) / 2 \rfloor, fair partitioning requires A[r] to be included in which of A[p..r-1] or A[r+1..q]? Back: A[p..r-1] Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic Given r = \lfloor (p + q) / 2 \rfloor, when is A[p..r] or A[r+1..q] equally sized? Back: When A[p..q] has even size. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic Given r = \lceil (p + q) / 2 \rceil, fair partitioning requires A[r] to be included in which of A[p..r-1] or A[r+1..q]? Back: A[r+1..q] Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic If A[p..q] has odd size, what r most fairly allows partitions A[p..r] and A[r+1..q]? Back: r = (p + q) / 2 Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic If A[p..q] has odd size, what r most fairly allows partitions A[p..r-1] and A[r..q]? Back: r = (p + q) / 2 Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic If A[p..q] has odd size, what r ensures A[p..r-1] has same size as A[r+1..q]? Back: r = (p + q) / 2 Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic If A[p..q] has even size, what r most fairly allows partitions A[p..r] and A[r+1..q]? Back: r = \lfloor (p + q) / 2 \rfloor Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic If A[p..q] has even size, what r most fairly allows partitions A[p..r-1] and A[r..q]? Back: r = \lceil (p + q) / 2 \rceil Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic Given A[p..q] and r = \lfloor (p + q) / 2 \rfloor, how does the size of A[p..r] compare to A[r+1..q]? Back: It either has zero or one more members. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic Given A[p..q] and r = \lfloor (p + q) / 2 \rfloor, what is the size of A[p..r] in terms of n = q - p + 1? Back: \lceil n / 2 \rceil. Reference: Thomas H. Cormen et al., Introduction to Algorithms, 3rd ed (Cambridge, Mass: MIT Press, 2009).

END%%

%%ANKI Basic Given A[p..q] and r = \lfloor (p + q) / 2 \rfloor, what is the size of A[r+1..q] in terms of n = q - p + 1? Back: \lfloor n / 2 \rfloor. Reference: Thomas H. Cormen et al., Introduction to Algorithms, 3rd ed (Cambridge, Mass: MIT Press, 2009).

END%%

%%ANKI Basic Given A[p..q] and r = \lceil (p + q) / 2 \rceil, how does the size of A[p..r-1] compare to A[r..q]? Back: It either has zero or one fewer members. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic Given A[p..q] and r = \lceil (p + q) / 2 \rceil, what is the size of A[r..q] in terms of n = q - p + 1? Back: \lceil n / 2 \rceil. Reference: Thomas H. Cormen et al., Introduction to Algorithms, 3rd ed (Cambridge, Mass: MIT Press, 2009).

END%%

%%ANKI Basic Given A[p..q] and r = \lceil (p + q) / 2 \rceil, what is the size of A[p..r-1] in terms of n = q - p + 1? Back: \lfloor n / 2 \rfloor. Reference: Thomas H. Cormen et al., Introduction to Algorithms, 3rd ed (Cambridge, Mass: MIT Press, 2009).

END%%

%%ANKI Basic Given A[p..q] and r = \lfloor (p + q) / 2 \rfloor, how does the size of A[p..r-1] compare to A[r..q]? Back: It either has one or two fewer members. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic Given A[p..q] and r = \lceil (p + q) / 2 \rceil, how does the size of A[p..r] compare to A[r+1..q]? Back: It either has one or two more members. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

%%ANKI Basic Given A[p..q] and r = \lfloor (p + q) / 2 \rfloor, why is the size of A[p..r] potentially larger than A[r+1..q]? Back: If A[p..q] has odd size, A[p..r] contains the midpoint. Reference: Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).

END%%

References

  • Bryant, Randal E., and David O'Hallaron. Computer Systems: A Programmer's Perspective. Third edition, Global edition. Always Learning. Pearson, 2016.
  • Ronald L. Graham, Donald Ervin Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science, 2nd ed (Reading, Mass: Addison-Wesley, 1994).
  • Thomas H. Cormen et al., Introduction to Algorithms, 3rd ed (Cambridge, Mass: MIT Press, 2009).