GATE / CS ARCHIVE

GATE CSE 2025 SET 1 / QUESTION 40

Applying longest-prefix IP routing

Computer Networks · Routing Algorithms · Full GATE CSE 2025 Set 1 paper

GATE 2025 Set 1, Q40 2 marks · MCQ
Report issue

Routing Algorithms

Question 40, GATE 2025: Destination 145.36.109.70 arrives at a router with entries 145.36.0.0/16→E1; 145.36.128.0/17→E2; 145.36.64.0/18→E3; 145.36.255.0/24→E4; default→E5. Which outgoing interface is selected? A E3; B E1; C E2; D E5.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Step through it (3 steps)

Approach: First find all matching network prefixes, then choose the most specific (longest) one.
The first two destination octets are 145.36, so the /16 E1 entry matches. The /17 E2 entry additionally requires the high bit of the third octet to be 1, meaning a third octet from 128 through 255. The destination’s third octet is 109, so that entry does not match.
The /18 E3 prefix fixes the first two bits of the third octet to 01, covering 64 through 127. Since 109 lies in that range, it matches. The /24 E4 entry requires third octet 255, so it does not match.
Among E1’s /16, E3’s /18 and the default, /18 is longest. Thus forward to E3, option A. Routing is not a first-listed-match decision, and a longer prefix is relevant only if it actually matches.

Original paper, page 40 · Answer key