Write a mini package manager that can install software for you.
Think about using Homebrew (on macOS) and the advanced package tool (APT on Debian/Ubuntu)
to install software. The package manager resolves all dependencies and transitive
dependencies by querying a service and installs all required software in order.
As a mini package manager, think about the real-world case.
For example, user inputs:
apt install chrome fish
Given a dependency service, which has all direct dependencies of all software packages:
chrome -> wget, javascript, graphX
fish -> wget
firefox -> javascript, graphX
javascript -> gcc
// ... millions of other dependencies
zzzzzz -> bbbb, ddddd, xyz
Following software will be installed in order:
wget gcc javascript graphX chrome fish
这是一道 典型 Netflix 风格的系统建模 + 算法结合题。
表面是「依赖安装顺序」,本质是在考:
- 如何建模一个 大规模依赖图
- 如何处理 直接依赖 + 传递依赖
- 如何保证 安装顺序正确且不重复
- 是否能意识到真实系统里「依赖数量巨大」
正文完