cs 320 Lecture-02-DW-CS320 copy

Job Interview Questions

Bits Representation of an Integer

  • Question: How many bits do you need to represent the integer 79,956,963,024?

    • Base 10 Representation:

      • 79,956,963,024 has 11 digits.

    • Base 2 Representation:

      • Calculation: (2^7) * (2^10) * (2^10) * (2^10) = 37 bits.

      • Approximation: 11/3*10 = 36.66 bits needed.

Investors and Data Science Graduates

Savings Comparison

  • Scenario: Two investors considering two data science graduates, both aged 22.

    • Investor A:

      • Saves $500 a month for 10 years from age 22 to 32.

      • Stops saving after 10 years.

    • Investor B:

      • Starts saving at age 32, saving for 30 years until age 62.

Outcome after 40 Years

  • The goal is to determine which graduate has $1 million after 40 years.

Savings Growth at 8% Interest

  • Key Observation:

    • At 8% interest, savings double every 9 years.

  • Savings Growth Example:

    • Year 1: $1,000

    • Year 2: $1,080

    • Year 3: $1,166.4

    • Year 4: $1,259.712

    • Year 9: $1,360.48896

    • Year 10: $1,469.32808

Early Saver's Growth

  • The '10 Years and Done' Saver:

    • Interest Rate: 8%

    • Contributions: $6,000 per year for the first 10 years.

  • Cumulative Savings Breakdown:

    • Year 1: Savings = $6,000; Yield = $480; Cumulative = $6,480

    • Year 2: Savings = $6,000; Yield = $998.4; Cumulative = $13,478.4

    • Year 3: Savings = $6,000; Yield = $1,558.272; Cumulative = $21,036.672

    • Year 10: Total after 10 years = $93,872.92478

    • Savings from Year 41 (40 years in total): Approx. $1,020,175.56

Late Saver's Growth

  • The '30 Year Saver':

    • Starts saving $6,000 per year from age 32 for 30 years.

  • Cumulative Savings Breakdown:

    • Year 1: Savings = $6,000; Yield = $480; Cumulative = $6,480

    • Year 10: Total after 10 years = $93,872.92478

    • Year 20: Approx. $202,664

    • Year 30: Approx. $437,536

    • Total at year 40: Approx. $734,072

Exponential Growth and Logarithmic Growth

  • Logarithm in Exponential Growth:

    • Importance of understanding growth with a constant rate—savings example logs.

  • Mathematical Patterns:

    • Savings grow exponentially under constant interest.

Exponentiation and Computational Complexity

  • Matrix Exponentiation:

    • Definitions of functions for determining odd/even exponentiation.

    • Usage of recursive strategies for optimization.

  • Complexity: O(log n) due to halving the exponent, leading to efficient calculations.

  • RSA Encryption:

    • Relates to exponentiation involving public-private key pairs for securing messages.

robot