I am trying to re-learn algorithms, since I’m feeling really unconfident about solving interview questions. These are some of the starter questions from the book “Algorithms in C, Part 1-4” by Robert Sedgewick. I am not really confident in any of my answers.

  1. Give the output that a connectivity algorithm should produce when given the input 0-2, 1-4, 2-5, 3-6, 0-4, 6-0, and 1-3.

My solution:

Input Output Connection
0-2 0-2 -
1-4 1-4 -
2-5 2-5 -
3-6 3-6 -
0-4 0-4 -
6-0 6-0 -
1-3 - 1-4-0-6-3
  1. List all the different ways to connect two different objects for the ex­ample in Figure I.I.

My solution:

No idea, honestly.

  1. Describe a simple method for counting the number of sets remaining after using the union and find operations to solve the connectivity problem as described in the text.

My solution:

We use a variable “count” that increments for the pair of objects that were not previously connected, using the find function.

  • velox_vulnusOP
    link
    fedilink
    English
    arrow-up
    3
    ·
    5 months ago

    I don’t know at this point. I’ve been jobless for too long, and at this point, I’m re-learning the stuff they teach in college.