CSCI 301 L01 Worksheet

Lecture 1 - Exercises

Part S - Syllabus

  1. How many classes can you miss without penalty for the Class Participation category?
  2. What is a slip day, how many do you have, and how do you use them?

Part A - Set Builder Notation

Write the following sets in set builder notation:

  1. All the odd integers
  2. All the natural numbers that are perfect squares
  3. All the squares of odd integers
  4. The set of positive rational numbers

Part B - Cardinality

  1. Let \(S = \{n^2 : n \in \mathbb{Z}\}\). Is \(S\) finite or infinite?
  2. What is \(|\{2k + 1 : k \in \mathbb{Z^+} \text{ and } k < 5\}|\)?
  3. What is |\(\varnothing\)|?
  4. What is \(|\{\varnothing\}|\)?
  5. What is \(|\{\varnothing, \{\{\varnothing\}\}\}|\)?

(End of what we covered in Lecture 1)

Part C - Subsets and Power Sets

  1. Let \(A = \{a, \varnothing\}\). True or false:
    1. \(a \in A\)
    2. \(\{a\} \in A\)
    3. \(a \subseteq A\)
    4. \(\{a\} \subseteq A\)
    5. \(\varnothing \subseteq A\)
    6. \(\{\varnothing\} \subseteq A\)
    7. \(\{\varnothing\} \in A\)
  2. Compute the power set of each of the following sets:
    1. \(\{1, 2\}\)
    2. {1}
    3. \(\varnothing\)
    4. \(\{1, \{2\}\}\)

Part D

  1. Recall that the formula for the volume of a sphere is \(\frac{4}{3}\pi r^3\). Racket has a built-in function expt to calculate exponents; its two arguments are the base and the exponent. Racket also has a built-in variable pi containing the (approximate) value of \(\pi\). Define a function that takes one argument, radius, and compute the volume of a sphere with that radius.

  2. Write a function plus-root to compute one root (the one resulting from the + of the \(\pm\)) of the quadratic formula. (reproduced below, in case you don’t presently have it memorized). Use let (or let*) to help you make it as readable as possible.

    \[ x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} \]

    Here’s a couple test cases in case you try it out: (plus-root 0.5 -3 2.5) 5.0 (plus-root 0.5 -3 5) 3.0+1.0i

  3. Modify your function from #2 to return false if there is no real root. So now it should behave as follows:

    (plus-root 0.5 -3 2.5)
    5.0
    (plus-root 0.5 -3 5)
    #f