Assuming compress() uses a standard compression algorithm, what is true about the output size?
medium
A. Output size is larger than original due to compression overhead
B. Output size is smaller than original because compression reduces size
C. Output size is exactly the same as original
D. Output size is zero because data is fully compressed
Solution
Step 1: Understand compression effect on data
Compression algorithms reduce data size by encoding repeated patterns efficiently, but add overhead.
Step 2: Compare compressed size to original
For small payloads like this (24 bytes), standard compression (e.g., zlib/gzip) results in larger size due to header overhead.
Final Answer:
Output size is larger than original due to compression overhead -> Option A
Quick Check:
Tiny payload + overhead = larger size [OK]
Hint: Compression on tiny payloads increases size [OK]
Common Mistakes:
Thinking compression always reduces size even for tiny data
Thinking compression outputs zero length
Confusing compression with encryption
4. You have a payload optimization script that replaces keys with short aliases but the receiver cannot decode the message. What is the likely problem?
medium
A. Payload is too small to be decoded
B. Sender and receiver do not share the same key mapping
C. Compression algorithm is missing on sender side
D. Payload contains invalid JSON syntax
Solution
Step 1: Analyze sender-receiver communication
Both sides must agree on key mappings to decode short keys correctly.
Step 2: Identify mismatch cause
If receiver lacks mapping, it cannot interpret short keys, causing decoding failure.
Final Answer:
Sender and receiver do not share the same key mapping -> Option B
Quick Check:
Matching key maps = decoding success [OK]
Hint: Ensure sender and receiver share key maps [OK]
Common Mistakes:
Blaming payload size instead of mapping
Ignoring synchronization of key mappings
Assuming compression causes decoding failure
5. You want to optimize an IoT device's payload by sending only changed sensor values instead of full data every time. Which approach best achieves this?
hard
A. Send full JSON payload with all sensor data every time
B. Send compressed full payload regardless of changes
C. Send only key-value pairs for sensors whose values changed since last message
D. Send data in plain text without any optimization
Solution
Step 1: Understand incremental data sending
Sending only changed values reduces payload size and saves bandwidth.
Step 2: Identify best method for change detection
Tracking changes and sending only updated key-value pairs minimizes data sent.
Final Answer:
Send only key-value pairs for sensors whose values changed since last message -> Option C