more paper 1 stuff Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

How does a hash function contribute to the performance of a hash table

A

A hash function maps keys to indices in the hash table, ensuring even distribution of elements and efficient retrieval

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Define an associative array and explain its relationship to dictionaries

A

An associative array is another term for a dictionary, where each key is associated with a value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Explain how a priority queue can be implemented using an array

A

A priority queue can be implemented using arrays where elements are sorted based on their priority levels, allowing efficient insertion and removal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Discuss the impact of hash collisions on the performance of a hash table

A

Hash collisions can degrade performance by increasing lookup time and necessitating collision resolution techniques like chaining or open addressing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Explain how dynamic arrays handle resizing when they run out of space.

A

Dynamic arrays resize by allocating a larger block of memory, copying existing elements, and deallocating the old memory block, ensuring efficient resizing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Discuss the advantages and disadvantages of using a dictionary for key-value storage

A

ADV:
- Fast Lookup Time: Dictionaries offer constant-time (O(1)) average-case lookup time for retrieving values based on their keys.
- Flexible Key Types: Dictionaries allow keys to be of various types, including strings, integers, tuples
- Dynamic Resizing: Many dictionary implementations automatically resize themselves as more elements are added,

DISADV:
- Memory Overhead: Dictionaries can consume more memory compared to other data structures
- Hash collisions
-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly