Challenge: Implement a Custom Hash Table
Opgave
Swipe to start coding
In this challenge, you will implement a hash table using chaining to resolve collisions. Your implementation must support three operations:
Required Behavior
put(key, value):- Insert a key-value pair into the table.
- If the key already exists, update its value.
get(key):- Return the value for the given key.
- If the key does not exist, return
None.
delete(key):- Remove the key-value pair from the table.
- If the key does not exist, do nothing.
Chaining Requirements
- The table consists of an array of buckets.
- Each bucket stores a list of (key, value) pairs.
- Collisions are handled by appending to the appropriate list.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 1. Kapitel 4
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Suggested prompts:
Can you explain this in simpler terms?
What are the main takeaways from this?
Can you give me a real-world example?
Fantastisk!
Completion rate forbedret til 7.69
Challenge: Implement a Custom Hash Table
Stryg for at vise menuen
Opgave
Swipe to start coding
In this challenge, you will implement a hash table using chaining to resolve collisions. Your implementation must support three operations:
Required Behavior
put(key, value):- Insert a key-value pair into the table.
- If the key already exists, update its value.
get(key):- Return the value for the given key.
- If the key does not exist, return
None.
delete(key):- Remove the key-value pair from the table.
- If the key does not exist, do nothing.
Chaining Requirements
- The table consists of an array of buckets.
- Each bucket stores a list of (key, value) pairs.
- Collisions are handled by appending to the appropriate list.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 1. Kapitel 4
single