Skip to main content

Answers to Exercises

  • Chapter
  • First Online:
First Course in Algorithms Through Puzzles

Abstract

The numbers are expressed in the binary system by 0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111, 10000, 10001, 10010, 10011, 10100 and in the hexadecimal system by 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10, 11, 12, 13, 14. Let’s consider the relation between these two expressions.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Hardcover Book
USD 49.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    XOR(exclusive-or logical sum):

    This is an operation on 2 bits defined as , , , and . In the usage introduced in the text, it is applied on each digit of binary sequences that express x and y. The operation does not exert any effect on the neighboring digits and can be performed on each digit independently.

  2. 2.

    Some of information on calculus:

    Here, we vaguely refer to “knowledge of calculus,” but what applies in fact is l’Hospital’s rule For an explanation of l’Hospital’s rule, refer to the column at Exercise 13.

  3. 3.

    Proof that two sets are equal:

    This general method may seem conventional and somewhat obvious. However, in my experience, most beginners do not know about it.

  4. 4.

    \(\max (a, b)\):

    \(\max (a, b)\) is a function that takes a and b and returns the larger of them. In other words, if \(a > b\), then \(\max (a, b) = a\). Otherwise, \(max(a, b) = b\).

  5. 5.

    Logarithmic function:

    Refer to Sect. 1.5.

  6. 6.

    William George Horner:1786–1837:

    British mathematician, lecturer.

  7. 7.

    Reason why \(i\ge j\) in line 1:

    If there is only one data item, \(i=j\) holds. Therefore, \(i=j\) instead of \(i\ge j\) apparently works. However, this is not true. Consider carefully the case where only two data exist from a[i] to a[j], i.e., \(j = i + 1\). In this case, we have \(m=i\), and for \(a[m] > x\), we would call BinarySearch\((a,i, i-1,x)\). In other words, when the number of data is 0, a function call occurs with \(j=i-1\). The condition \(i\ge j\) is checked in order to enable correct processing in this case, too.

  8. 8.

    http://oeis.org.

  9. 9.

    Notation to designate intervals:

    An important point when it comes to expressing intervals along a number line is whether or not the extremities are included. The standard mathematical notation is to use [] for intervals that contain the extremities and () for those that do not. In other words, [0, 1] means that this interval contains numbers greater than or equal to 0 and smaller than or equal to 1. On the other hand, (0, 1) means that the interval contains numbers greater than 0 and smaller than 1. Likewise, the interval [ij) means that its values are equal to or greater than i, and smaller than j.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Ryuhei Uehara .

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Springer Nature Singapore Pte Ltd.

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Uehara, R. (2019). Answers to Exercises. In: First Course in Algorithms Through Puzzles. Springer, Singapore. https://doi.org/10.1007/978-981-13-3188-6_8

Download citation

  • DOI: https://doi.org/10.1007/978-981-13-3188-6_8

  • Published:

  • Publisher Name: Springer, Singapore

  • Print ISBN: 978-981-13-3187-9

  • Online ISBN: 978-981-13-3188-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics