Homework 5 for Spring 2025 -- CMSC331

  1. Inheritance in Programming

    List two disadvantages and one advantage of supporting multiple inheritance in a programming language. Provide an example where multiple inheritance could cause ambiguity.

  2. Ruby List Set Difference (No Built-ins)

    Write a Ruby function that returns the difference of two sets (represented as lists), i.e., elements in the first set that are not in the second. Don't use built-in methods like -, difference, or uniq.

    Example: set_difference([1, 2, 3], [2, 4]) => [1, 3]

  3. Parameter Passing Semantics

    a: Explain the key distinction between call-by-name and call-by-value.

    b: Write pseudo-code where these two passing strategies lead to different outcomes.

  4. Write the stack class (as defined by problem 2 of homework 3) but in Ruby this time.