Skip to content

Commit 992a7da

Browse files
committed
Add class 8 topics, resources, and challenges: sets and circular buffers
1 parent c2b179f commit 992a7da

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

Class8.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## Class 7: Sets & Circular Buffers
2+
3+
### Topics
4+
- Abstract data types: [set], [multiset (bag)][multiset]
5+
- Concrete data structures: [hash table], [circular buffer (circular queue, ring buffer)][circular buffer]
6+
- [Set operations]
7+
8+
### Challenges
9+
- Implement `Set` class (set with hash table) with the following [set operations] as instance methods and properties:
10+
- `__init__(elements=None)` - initialize a new empty set structure, and add each element if a sequence is given
11+
- `size` - property that tracks the number of elements in constant time
12+
- `contains(element)` - return a boolean indicating whether `element` is in this set
13+
- `add(element)` - add `element` to this set, if not present already
14+
- `remove(element)` - remove `element` from this set, if present, or else raise `KeyError`
15+
- `union(other_set)` - return a new set that is the union of this set and `other_set`
16+
- `intersection(other_set)` - return a new set that is the intersection of this set and `other_set`
17+
- `difference(other_set)` - return a new set that is the difference of this set and `other_set`
18+
- `is_subset(other_set)` - return a boolean indicating whether `other_set` is a subset of this set
19+
- Write unit tests for to ensure the `Set` class is robust
20+
- Include test cases for each class instance method
21+
- Annotate all instance methods with complexity analysis of running time and space (memory)
22+
- Compare the behaviors of your `Set` class to those of the [Python `set` type]
23+
24+
### Stretch Challenges
25+
- Implement `CircularBuffer` class with dynamic array
26+
- Write unit tests for to ensure the `CircularBuffer` class is robust
27+
- Include test cases for each class instance method
28+
- Annotate `enqueue` and `dequeue` methods with running time complexity analysis
29+
30+
31+
[set]: https://en.wikipedia.org/wiki/Set_(abstract_data_type)
32+
[multiset]: https://en.wikipedia.org/wiki/Set_(abstract_data_type)#Multiset
33+
[set operations]: https://en.wikipedia.org/wiki/Set_(abstract_data_type)#Operations
34+
[hash table]: https://en.wikipedia.org/wiki/Hash_table
35+
[circular buffer]: https://en.wikipedia.org/wiki/Circular_buffer
36+
[Python `set` type]: https://docs.python.org/3/library/stdtypes.html#set

ReadMe.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
| 5 | Wednesday, November 1 | [Lists, Stacks & Queues](Class5.md) |
1717
| 6 | Friday, November 3 | [Call Routing Project](Class6.md) |
1818
| 7 | Monday, November 6 | [Maps & Hash Tables](Class7.md) |
19-
| 8 | Wednesday, November 8 | Set & Circular Buffer |
19+
| 8 | Wednesday, November 8 | [Sets & Circular Buffers](Class8.md) |
2020
| 9 | Friday, November 10 | Trees |
2121
| 10 | Monday, November 13 | Tree Traversals |
2222
| 11 | Wednesday, November 15 | Iterative Sorting Algorithms |

0 commit comments

Comments
 (0)