CSCI 370 - Lecture 4: Optimization and Design Patterns in Software Engineering


Topics Covered


Traveling Salesman Problem (TSP) & Christofides’ Algorithm

The Problem

Real-World Relevance

Christofides’ Algorithm Overview

Christofides’ algorithm offers an approximate solution with a guaranteed upper bound of 1.5 times the optimal route length.

Steps:

  1. Minimum Spanning Tree (MST):

    • Connect all nodes (cities) without creating loops.
    • Use shortest possible total edge weight.
  2. Find Odd-Degree Vertices:

    • Identify vertices in the MST with an odd number of connections.
  3. Minimum Weight Perfect Matching:

    • Pair all odd-degree vertices with minimum-weight connections.
  4. Combine to Form Eulerian Circuit:

    • Result is a multigraph with all even-degree vertices, allowing an Eulerian circuit (visits every edge once).
  5. Convert to Hamiltonian Circuit:

    • Remove repeated cities to obtain a path visiting each city exactly once.

Benefits:

Example Use Case:

A delivery company must visit 15 addresses. Christofides’ algorithm reduces route length, saving fuel and time.


AI in Drug Discovery & Healthcare

AI Applications in Healthcare

Machine Learning in COVID-19 Detection

Model Performance

AI in Vaccine Development

Limitations

Future Outlook


Strategy Pattern (Design Pattern)

Problem with Inheritance:

Strategy Pattern Solution:

Encapsulate interchangeable behaviors and pass them to objects.

Structure:

Benefits:

Real-World Analogy:


Observer Pattern (Design Pattern)

Use Case:

Notifying interested parties (observers) when an object (subject) changes.

Example:

Initial Problem:

Observer Pattern Structure:

Benefits:

Real-World Example:


Key Software Engineering Principle:

Open-Closed Principle (OCP)

Software entities should be open for extension but closed for modification.


Summary

Lecture 5 focused on optimization and design patterns that emphasize clean, maintainable code. Christofides’ algorithm provides a real-world solution to TSP, while Strategy and Observer patterns illustrate how to write flexible, reusable object-oriented code. These patterns support the Open-Closed Principle, ensuring scalable and bug-resistant systems.