Skip to content

Commit c648c8f

Browse files
committed
Added more to RadixTree's README
1 parent f11d617 commit c648c8f

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

Radix-Tree/README.markdown

+23-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,35 @@ The RadixTree class itself has one member variable, root, of type Root. The Root
1111

1212
Typical operations on a radix tree include lookup, insertion, deletion, find predecessor, find successor, and find all strings with common prefix. The running time of lookup, insertion, and deletion is O(k) where k is the length of the key. This is different from most trees because these operations usually run in O(logn) time where n is the number of nodes in the tree.
1313

14-
### Find(_ str: String) -> Bool
14+
### RadixTree.find(_ str: String) -> Bool
1515

1616
The find function returns true if the String you are searching for is in the tree and false if it is not. Every RadixTree contains at the very least one String ("") so find("") will always return true. A String is considered "in the tree" if the String you are searching for is a concatenation of Edge labels while traversing downwards or a prefix of that concatenation. For example, if you look at the example tree above, find("roma") will return true because it is a prefix of the traversal "r"->"om"->"an". On the other hand, find("romans") will return false.
1717

18-
### Insert(_ str: String) -> Bool
18+
### RadixTree.insert(_ str: String) -> Bool
1919

2020
The insert function returns true if the String you are trying to insert was successfully inserted into the RadixTree and false if the String is already in the tree. Similarly to find(""), insert("") will always return false because an empty RadixTree contains "" by default.
2121

22+
### RadixTree.remove(_ str: String) -> Bool
23+
24+
THIS IS NOT IMPLEMENTED YET
25+
26+
### Root.level() -> Int
27+
28+
The level function returns how far down in the tree the Root or Edge in question is. A Root object will always return 0. A child of the Root will return 1, a child of a child of the root will return 2, etc.
29+
30+
### RadixTree.height() -> Int
31+
32+
The height function returns an Int equal to the highest level in the Tree. An empty tree will return 0.
33+
34+
### RadixTree.printTree()
35+
36+
The printTree function was used to visualize the tree itself. This function is a little buggy and not perfect yet but gets the job done thus far.
37+
38+
### sharedPrefix(_ str1: String, _ str2: String) ->
39+
40+
The sharedPrefix function is a non-member function in the RadixTree.swift file. It takes in two String objects and returns the shared prefix between them. For example,
41+
sharedPrefix("apples", "oranges") will return "" and sharedPrefix("court", "coral") will return "co". This function is used in the implementation of the find, insert, and remove functions.
42+
2243
## See Also
2344

2445
[Radix Tree - Wikipedia](https://en.wikipedia.org/wiki/Radix_tree)

0 commit comments

Comments
 (0)