Fewest Hops to Route a Message Across MQ Queue Managers
Last updated: November 29, 2026
Quick Overview
Given channels between IBM MQ queue managers as an undirected list of pairs, return the shortest route (as a list of manager names) from a source to a destination, or an empty list if unreachable.
IBM
November 29, 20260
0
0 solved
Given channels between IBM MQ queue managers as an undirected list of pairs, return the shortest route (as a list of manager names) from a source to a destination, or an empty list if unreachable.
IBM MQ connects queue managers through channels, and routing a message through the fewest intermediate managers is an intuitive BFS framing used in integration and middleware team interviews. The interviewer checks adjacency-list construction, BFS with a parent map, and path reconstruction.
What the Interviewer Expects
- Build an adjacency list from the edge list
- Use BFS, not DFS, for unweighted shortest paths
- Reconstruct the path with a parent map
- Handle source equal to destination and unreachable targets
- State O(V + E) complexity
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you return all shortest routes?
- What if channels have different latencies?
- How would bidirectional BFS help on a large network?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: channels, a list of (a, b) pairs, plus src and dst. Output: the list of managers on one shortest route including both ends, [src] if src == dst, or [] if no route exists. Channels...
High-Level Design
Build a dictionary of neighbor lists. Run BFS from src, storing for each discovered manager the manager that discovered it. BFS explores in layers, so the first time dst is discovered we have a mi...