title: How would you design a mac address table (essentially a fast look up table)?
body: <p>This is a programming question related to computer networking. Essentially every router/switch has a mac address table which it looks up to get the interface port on which it has to forward packets on. The table itself looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/OAec8.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OAec8.jpg" alt="enter image description here"></a></p>
  
  <p>So basically given the two keys, vlan and the mac address, a lookup is done on the table and the value of the port (last column) is looked up. In practice, the table might have thousands of rows and the value needs to be returned as fast as possible. So my question is what is the best way to design this lookup table? I was asked this in the interview and I thought of using a hash table, with the combination of vlan and mac address as the key. But it was not convincing. Please suggest a good design for this.</p>