Skip to content

Commit 2b2bfbd

Browse files
authored
Create README.md
1 parent 921e491 commit 2b2bfbd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lab 2 : binary search tree/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Lab 2: BSTMap
2+
3+
The `BSTMap` class is a `map` structure based on Binary Search Trees (BST).
4+
5+
## 1. Get the value in BSTMap given a key
6+
7+
The function `get` in [BSTMap.h](BSTMap.h#L103) returns the value of a given search key in the `BSTMap`. For example, suppose we have a map `m = {"sumomo": 1, "momo": 2, "uchi": 1, "mo": 2, "no": 2}`. A call to `m.get("momo")` should return `2` and a call to `m.get("uchi")` will return `1`.
8+
Created a private recursive function, e.g. `getHelp` for the `get` function.
9+
10+
11+
## 2. Remove a key-value pair from the BSTMap given a key
12+
13+
The function `remove` in [BSTMap.h](BSTMap.h#L111) deletes the key-value pair in the `BSTMap` given a key. For example, suppose we have a map `m = {"sumomo": 1, "momo": 2, "uchi": 1, "mo": 2, "no": 2}`. A call to `m.remove("momo")` removes the pair `"momo": 2` and the resulting `m = {"sumomo": 1, "uchi": 1, "mo": 2, "no": 2}`. Another call to `m.remove("uchi")` will remove the pair `"uchi": 1` and make `m = {"sumomo": 1, "mo": 2, "no": 2}`.
14+
15+
16+
## 3. Build and test
17+
18+
A sample test case is given in [main.cpp](main.cpp).

0 commit comments

Comments
 (0)