Skip to content

Commit

Permalink
Fix typos
Browse files Browse the repository at this point in the history
- Data Structures ln47 remove "'"
- Range Deletion in Splay Tree ln28 'avobe' → 'above'
- Range Deletion in Splay Tree ln18 'tree from' → 'tree structure' (more appropriate phrase)
  • Loading branch information
se030 committed Jul 29, 2023
1 parent 44ca5f8 commit f34c75c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions design/data-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ JSON-like data strucutres are used when editing JSON-like documents.

- `Primitive`: represents primitive data like `string`, `number`, `boolean`, `null`, etc.
- `Object`: represents [object type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) of JavaScript. Just like JavaScript, you can use `Object` as [hash table](https://en.wikipedia.org/wiki/Hash_table).
- `Array`: represents [array type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) of JavaScript. You can also use `Array` as [list](https://en.wikipedia.org/wiki/List_(abstract_data_type)).
- `Array`: represents [array type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) of JavaScript. You can also use `Array` as [list](<https://en.wikipedia.org/wiki/List_(abstract_data_type)>).
- `Text`: represents text with style attributes in rich text editors such as [Quill](https://github.com/yorkie-team/yorkie-js-sdk/blob/main/examples/quill.html). Users can express styles such as bold, italic, and underline to text content. Of course, it can represent just a plain text in text-based editors such as [CodeMirror](https://github.com/yorkie-team/yorkie-js-sdk/blob/main/examples/index.html). It supports collaborative editing; multiple users can modify parts of the contents without conflict.

JSON-like data structures can be edited through proxies. For example:
Expand Down Expand Up @@ -79,8 +79,8 @@ Common data structures can be used for general purposes.

- [`SplayTree`](https://en.wikipedia.org/wiki/Splay_tree): A tree that moves nodes to the root by splaying. This is effective when user frequently access the same location, such as text editing. We use `SplayTree` as an index tree to give each node a weight, and to quickly access the node based on the index.
- [`LLRBTree`](https://en.wikipedia.org/wiki/Left-leaning_red%E2%80%93black_tree): A tree simpler than Red-Black Tree. Newly added `floor` method finds the node of the largest key less than or equal to the given key.
- [`Trie`](https://en.wikipedia.org/wiki/Trie): A data structure that can quickly search for prefixes of sequence data such as strings. We use `Trie` to remove nested events when the contents of the `Document`' are modified at once.
- [`Trie`](https://en.wikipedia.org/wiki/Trie): A data structure that can quickly search for prefixes of sequence data such as strings. We use `Trie` to remove nested events when the contents of the `Document` are modified at once.

### Risks and Mitigation

We can replace the data structures with better ones for some reason, such as performance. For example, `SplayTree` used in `RGATreeList` can be replaced with [TreeList](https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/list/TreeList.html).
We can replace the data structures with better ones for some reason, such as performance. For example, `SplayTree` used in `RGATreeList` can be replaced with [TreeList](https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/list/TreeList.html).
12 changes: 7 additions & 5 deletions design/range-deletion-in-splay-tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: delete-range-in-splay-tree
target-version: 0.2.12
---

---

# Range Deletion in Splay Tree
Expand All @@ -14,7 +15,7 @@ Using the feature of a splay tree that changes the root freely, `splay.DeleteRan

### Goals

The function `DeleteRange` should separate all nodes exactly in the given range as a subtree. After executing the function, the entire tree from and weight of every node must be correct just as when the nodes were deleted one by one.
The function `DeleteRange` should separate all nodes exactly in the given range as a subtree. After executing the function, the entire tree structure and weight of every node must be correct just as when the nodes were deleted one by one.

## Proposal Details

Expand All @@ -24,8 +25,7 @@ From the property of indexed BST, all nodes with a smaller index than the root a

And also, Splay Tree can change the root freely to use `Splay`.

Then using the properties, when we want to delete the range from index `L` to `R` we can make the shape of tree like the figure avobe to `Splay(L-1)` then `Splay(R+1)`.

Then using the properties, when we want to delete the range from index `L` to `R` we can make the shape of tree like the figure above to `Splay(L-1)` then `Splay(R+1)`.

![delete-range-in-splay-tree-2](./media/range-deletion-in-splay-tree-2-separation.png)

Expand All @@ -39,10 +39,10 @@ func (t *Tree[V]) DeleteRange(leftBoundary, rightBoundary *Node[V]) {
t.cutOffRight(leftBoundary)
return
}

t.Splay(leftBoundary)
t.Splay(rightBoundary)

// refer case 2 of second figure
if rightBoundary.left != leftBoundary {
t.rotateRight(leftBoundary)
Expand All @@ -51,9 +51,11 @@ func (t *Tree[V]) DeleteRange(leftBoundary, rightBoundary *Node[V]) {
}

```

Sometimes the tree shapes like case 2 after `Splay`s because of the zig-zig case of `Splay`. But it simply changes to the same shapes as case 1 in one rotation for `L-1`.

Then now to cut off the right child(subtree) of `L-1`, we can separate all nodes in the given range to be deleted.

### Risks and Mitigation

`DeleteRange` does not consider the occurrence of new nodes due to concurrent editing in the range to be deleted. They should be filtered before using `DeleteRange`, and `DeleteRange` should be executed continuously in the smaller ranges that do not include them.
Expand Down

0 comments on commit f34c75c

Please sign in to comment.