← Citadel Interview Insights

Citadel·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Citadel quant engineer interview with at least one algorithmic problem thrown in. Not much detail shared but the tree diameter question was apparently part of it.

Questions Asked (1)

Q1

Given a tree, find the length of its longest path between any two nodes (the diameter).

Algorithms & Data Structures
Author's notes

Classic problem, the kind you've either drilled or you haven't.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify that the tree is unweighted and then present a linear-time solution using two BFS/DFS traversals: first from any node to find the farthest node A, then from A to find the farthest node B, where the distance between A and B is the diameter. Alternatively, mention a single DFS that computes the diameter by combining the two longest downward paths at each node.

Pro tip: Emphasize that the two-BFS approach works only for trees (or unweighted graphs) and that for weighted trees you need the DP approach; also discuss handling edge cases like a single node or empty tree.

1. Clarify assumptions

Confirm whether the tree is unweighted, whether it's a binary tree or general tree, and how the input is represented (adjacency list, edges, etc.).

2. Explain the two-BFS approach

Describe the algorithm: pick an arbitrary node, run BFS to find the farthest node A, then run BFS from A to find the farthest node B; the distance from A to B is the diameter.

3. Provide proof of correctness

Briefly justify why the first BFS finds an endpoint of the diameter: if the farthest node from an arbitrary node is not an endpoint, a longer path can be constructed, leading to a contradiction.

4. Analyze complexity

State that the algorithm runs in O(N) time and O(N) space, where N is the number of nodes, since each BFS visits all nodes and edges once.

5. Discuss alternative and edge cases

Mention the single DFS DP approach for weighted trees or if recursion is preferred, and cover edge cases such as a single node (diameter 0) or empty tree.

Key Points to Mention

  • Definition of tree diameter as the longest path between any two nodes.
  • Two BFS/DFS traversals: first to find one endpoint, second to find the other.
  • Proof of correctness: the farthest node from any node is an endpoint of a diameter.
  • Time and space complexity: O(N) time, O(N) space.
  • Alternative DP approach for weighted trees or single-pass DFS.
  • Edge cases: single node, empty tree, and handling of large inputs.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.