0
0
Redisquery~20 mins

Set vs sorted set for membership in Redis - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Redis Set Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Difference in membership check performance

Which Redis data structure provides the fastest membership check for a single element?

ABoth have the same performance since they store elements similarly.
BSorted Set, because it maintains elements in order for quick binary search.
CSet, because it uses a hash table for O(1) membership checks.
DNeither supports membership checks efficiently; use a list instead.
Attempts:
2 left
💡 Hint

Think about how each data structure stores elements and how that affects lookup speed.

query_result
intermediate
1:30remaining
Check membership in a Redis Set

Given a Redis Set named fruits containing apple, banana, and cherry, what is the output of the command SISMEMBER fruits banana?

Anil
B1
C0
DError
Attempts:
2 left
💡 Hint

Remember what SISMEMBER returns when the element exists in the set.

📝 Syntax
advanced
2:00remaining
Valid command to check membership in a Sorted Set

Which of the following Redis commands correctly checks if the member user42 exists in the Sorted Set online_users?

AZMEMBER online_users user42
BSISMEMBER online_users user42
CZRANK online_users user42
DZSCORE online_users user42
Attempts:
2 left
💡 Hint

Think about which command returns a score or indication of membership for sorted sets.

optimization
advanced
2:30remaining
Choosing data structure for frequent membership checks with ordering

You need to frequently check if elements exist and also retrieve them in a sorted order by score. Which Redis data structure is best suited?

ASorted Set, because it supports fast membership checks and maintains order.
BSet, because it has faster membership checks and you can sort on retrieval.
CList, because it maintains order and supports membership checks efficiently.
DHash, because it stores key-value pairs and supports membership checks.
Attempts:
2 left
💡 Hint

Consider both membership check speed and the need to keep elements sorted.

🔧 Debug
expert
3:00remaining
Why does this membership check fail on a Sorted Set?

You run the command SISMEMBER online_users user42 on a Sorted Set online_users and it returns an error even though user42 exists. Why?

ABecause <code>SISMEMBER</code> only works on Sets, not Sorted Sets.
BBecause the Sorted Set is empty.
CBecause <code>user42</code> is not a member of the Sorted Set.
DBecause <code>SISMEMBER</code> requires a score argument for Sorted Sets.
Attempts:
2 left
💡 Hint

Check command compatibility with data types.