Skip to content

Commit 0cfd81d

Browse files
committed
Fix images with union
1 parent 8ce99ee commit 0cfd81d

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

Union-Find/Images/AfterUnion.png

341 Bytes
Loading

Union-Find/Images/BeforeUnion.png

300 Bytes
Loading

Union-Find/README.markdown

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public mutating func setOf(element: T) -> Int? {
6767

6868
1. First, we check if current index represent a node that is root. That means we find number that represent the set of element we search for.
6969

70-
2. Otherwise we recursively call our method on parent of current node. And then we do **very important thing**: we cache index of root node, so when we call this method again it will executed faster because of cached indexes. Without that optimization method's complexity is **O(n)** but now in combination with the size optimization (we'll look at that in Union section) it is almost **O(1)**.
70+
2. Otherwise we recursively call our method on parent of current node. And then we do **very important thing**: we cache index of root node, so when we call this method again it will executed faster because of cached indexes. Without that optimization method's complexity is **O(n)** but now in combination with the size optimization (I'll cover that in Union section) it is almost **O(1)**.
7171

7272
3. We return our cached root as result.
7373

@@ -116,7 +116,7 @@ Union with optimizations also takes almost **O(1)** time.
116116

117117
As always, some illustrations for better understanding
118118

119-
Before calling `unionSetsContaining(4, and: 7)`:
119+
Before calling `unionSetsContaining(4, and: 3)`:
120120

121121
![BeforeUnion](Images/BeforeUnion.png)
122122

@@ -128,7 +128,7 @@ Note that during union caching optimization was performed because of calling `se
128128

129129

130130

131-
There are also helper method to just check that two elements is in the same set:
131+
There is also helper method to just check that two elements is in the same set:
132132

133133
```swift
134134
public mutating func inSameSet(firstElement: T, and secondElement: T) -> Bool {

0 commit comments

Comments
 (0)