🎓 BookMCQ
← Back to 29. Peer to Peer Paradigm

📝 Pastry applications in P2P (8 MCQs)

Routing Substrate for Distributed Services

Pastry supplies application-level message routing and object location over a peer-to-peer overlay. Applications provide a key, and Pastry delivers the message to the live node whose identifier is numerically closest to that key. It does not prescribe the application's content format, storage policy, or user interface. Prefix matches direct logical progress; physical proximity remains a separate consideration. This supports distributed applications.

Storage, Sharing, Naming, and Group Communication

A distributed storage system can use Pastry to locate metadata or content fragments. A sharing application can route provider queries, while a naming service can associate identifiers with service records. Group communication systems can build membership or message-delivery functions on top of Pastry's routing substrate. Sets organize routing state by prefix, proximity, and identifier order.

Application Request and Overlay Delivery

The application hashes or otherwise assigns a destination key, creates a message, and passes both to the local Pastry layer. Pastry forwards the message through routing-table or leaf-set entries. The destination application then processes the message, returning data or coordinating a separate transfer when required. Every hop must improve the prefix or satisfy the fallback rule.

Locating a Distributed Storage Object

Suppose a storage application maps object name report-17 to key K. A client sends a request through Pastry, which delivers it to the live node closest to K. That node checks its application-level storage or index and responds with metadata or a location for the object's actual content. The selected peer advances the key's shared prefix match at this stage.

Locality and Peer-Failure Considerations

Pastry's locality-aware state can reduce network path costs for routing choices, while its leaf set and routing table support adaptation to membership changes. Applications must still handle replication, data integrity, permissions, and unreachable peers. Successful message routing does not guarantee that an application object remains available. The application remains responsible for stored data and service permissions.

Pastry Does Not Store Every Application Object

'Pastry automatically stores all files' confuses routing with storage. 'The numerically closest peer is always geographically closest' ignores the distinction between identifier order and network proximity. 'A routed message guarantees a successful service operation' overlooks application errors, missing data, and access restrictions. Identifier order and network proximity remain separate routing criteria in Pastry.

Application Flow and Layer Responsibilities

Be prepared to separate application key creation, overlay routing, destination processing, and any subsequent data transfer. Identify what Pastry contributes and what the application implements itself. In scenario questions, explain how locality information may improve route choice without changing the destination key or replacing IP routing. Name the routing table row, fallback candidate, and leaf set decision clearly.

Pastry Application and Service Terms

  • Object location - Finding the responsible object peer..
  • Routing substrate - Service for overlay message delivery..
  • Storage fragment - Object portion stored on a peer..
  • Service record - Data describing a service endpoint..
  • Locality - Preference for network close peers..
  • Membership - Current nodes participating in an overlay..
2
Easy
4
Medium
2
Hard

📝 All Pastry applications in P2P MCQs

Q1. In a set of symbols with frequencies A:45A:45, B:13B:13, C:12C:12, D:16D:16, and E:9E:9, which two symbols are combined first when building the Huffman tree?

A.A and B
B.C and E ✅
C.D and E
D.B and C
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The Huffman algorithm always merges the two lowest‑frequency nodes. Here the smallest frequencies are E=9E=9 and C=12C=12; merging them yields a new node of weight 2121. No other pair has a combined weight lower than 2121, so the correct pair is C and E.

Q2. Compared to a fixed‑length code of 3 bits per symbol, which statement correctly describes the average bits per symbol for the Huffman code built from the frequencies in the previous question?

A.The Huffman average is greater than 3 bits
B.The Huffman average equals exactly 3 bits
C.The Huffman average is less than 3 bits
D.The Huffman average cannot be determined without the tree ✅
💡 Difficulty: easy | ✅ Correct: D

📖 Explanation: Because Huffman coding assigns shorter codes to high‑frequency symbols and longer codes to low‑frequency ones, the weighted average length is always lower than the uniform length of a fixed‑length code when symbol frequencies are non‑uniform. Hence the average bits per symbol is less than 3.

Q3. Given symbols X:20X:20, Y:30Y:30, Z:50Z:50 and constructing a Huffman tree, which binary code is assigned to symbol YY?

A.0 ✅
B.1
C.10
D.11
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: First, combine the two smallest frequencies X=20X=20 and Y=30Y=30 to create a node of weight 5050. This node and Z=50Z=50 are then merged at the root. Assigning 0 to the left branch and 1 to the right, the path to YY is left‑left, yielding the code 0000.}

Q4. During LZW decoding, if the current codeword does not yet exist in the dictionary, what string should the decoder output?

A.The previous string concatenated with its first character
B.The previous string duplicated twice
C.The previous string concatenated with the first character of the previous string ✅
D.An empty string
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: When a codeword is absent, the decoder follows the special rule: output the previous string plus its own first character. This constructs the new entry that will later be added to the dictionary, preserving the algorithm’s consistency.

Q5. If the frequency of a symbol in a Huffman tree is increased, what is the most likely effect on the length of its codeword?

A.The codeword length increases
B.The codeword length stays the same ✅
C.The codeword length decreases
D.The codeword length becomes unpredictable
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Increasing a symbol's frequency makes it more likely to be merged earlier with other low‑frequency nodes, moving it closer to the root. Consequently, the path from root to that leaf shortens, reducing the number of bits required to represent the symbol.

Q6. Which of the following sequences correctly describes the steps to construct a Huffman coding table from a set of symbol frequencies?

A.Sort frequencies → Build tree → Assign bits → Generate table
B.Assign bits → Build tree → Sort frequencies → Generate table
C.Generate table → Sort frequencies → Build tree → Assign bits
D.Build tree → Generate table → Sort frequencies → Assign bits ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: The proper workflow is: first build the Huffman tree by repeatedly merging the two lowest‑frequency nodes; then traverse the completed tree to assign binary digits to each branch, producing the code for each symbol; finally, compile these codes into a coding table.

Q7. Using the Huffman tree where A=00, B=01, C=10, and D=11, what is the encoded bitstring for the message \ABCA\?

A.11000 ✅
B.100110
C.100100
D.11001
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Encode each character sequentially: A→00, B→01, C→10, A→00. Concatenating yields 00 01 10 00, i.e., the bitstring \00011000\. Any other arrangement would mismatch the defined codes.

Q8. In an LZW compression example, the decoder outputs \ABAB\ instead of the expected \ABBA\. Which step is most likely the source of the error?

A.Using an incorrect initial dictionary
B.Failing to add the new entry after each output
C.Misinterpreting the codeword size increase ✅
D.Skipping the special \not‑in‑dictionary\ rule
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: When the codeword size is not updated at the correct point, later codewords are read with the wrong number of bits, causing misalignment. This typically leads to the decoder interpreting subsequent codes incorrectly, producing a string like \ABAB\ instead of the intended \ABBA\.

🔗 Related Topics (MCQs)