Maximum subset of Cuboid boxes that can fit into one another

Problem  Given a lot of cuboid boxes with different length, breadth and height. We need to find the maximum subset which can fit into each other. Example For example: If Box 1 has LBH as 7 8 9 If Box 2 has LBH as 5 6 8 If Box 3 has LBH as 5 8 7 If Box 4 has LBH as 4 4 4 then answer is 1,2,4 [Read More]

Fit 1*2 dominos in 2*N strip

Problem In how many ways can one tile a 2 X N strip of square cells with 1 X 2 dominos? Solution Please notice that we can put tiles either vertically or horizontally. For putting vertical tiles, we need a gap of at least 2 X 2. For putting horizontal tiles, we need a gap of 2 X 1. Number of arrangements will be the same as the arrangements, we can make with gaps of 1 and 2 (order dependent). [Read More]

Common routing protocol

Problem Explain any common routing protocol in detail. For example: BGP, OSPF, RIP. Solution BGP: Border Gateway Protocol BGP is the core routing protocol of the Internet . When a BGP router first comes up on the Internet, either for the first time or after being turned off, it establishes connections with the other BGP routers with which it directly communicates. The first thing it does is download the entire routing table of each neighboring router. [Read More]

Compare and contrast IPv4 and IPv6

Problem Compare and contrast the IPv4 and IPv6 protocols. Solution IPv4 and IPv6 are the internet protocols applied at the network layer. IPv4 is the most widely used protocol right now and IPv6 is the next generation protocol for internet. Table Cell Table Cell IPv4 is the fourth version of Internet protocol which uses 32 bit addressing IPv6 is a next generation internet protocol which uses 128 bits addressing. [Read More]

What is a network/subnet mask

Problem What is a network / subnet mask? Explain how host A sends a message / packet to host B when: (a) both are on same network and (b) both are on different networks. Explain which layer makes the routing decision and how. Solution A mask is a bit pattern used to identify the network/subnet address. The IP address consists of two components: the network address and the host address. [Read More]

Virtual memory, page fault and thrashing

Problem Explain the following terms: virtual memory, page fault, thrashing. Solution In short: Virtual memory is a technique that uses hard disk pages as main memory. Page fault is the error occurred when transferring pages. Thrashing - When paging occurs very very frequently, causing performance degradation. Now lets go in details: Virtual Memory Virtual memory is a computer system technique which gives an application program the impression that it has contiguous working memory (an address space), while in fact it may be physically fragmented and may even overflow on to disk storage. [Read More]

Searching Questions

Here are some questions on searching Search types Linear Search on Array Binary search on Array - Recursive and iterative Special case of Ranged array By ranged array, I mean that array has some specific size, say N, and numbers in that array can occur in a range of 0 to N-1. I don’t know if some other special name exists for such arrays. But lets go ahead with this name. [Read More]

How to detect duplicate documents in billions of urls

Problem You have a billion urls, where each is a huge page. How do you detect the duplicate documents? Solution Characterstic of page Pages are huge, so bringing all of them in memory is a costly affair. We need a shorter representation of pages in memory. A hash is an obvious choice for this. A hash can depend on links inside page, title, creation Billions of urls exist so we don’t want to compare every page with every other page that would be O(n^2). [Read More]