<commit_before># AVL tree [![npm version](https://badge.fury.io/js/avl.svg)](https://badge.fury.io/js/avl) [![CircleCI](https://circleci.com/gh/w8r/avl.svg?style=svg)](https://circleci.com/gh/w8r/avl)

[AVL-tree](https://en.wikipedia.org/wiki/AVL_tree): **[fast](#benchmarks)**(non-recursive) and **simple**(< 500 lines of code)

![AVL-tree](https://upload.wikimedia.org/wikipedia/commons/a/ad/AVL-tree-wBalance_K.svg)

| Operation     | Average       | Worst case   |
| ------------- | ------------- | ------------ |
| Space         | **O(n)**      | **O(n)**     |
| Search        | **O(log n)**  | **O(log n)** |
| Insert        | **O(log n)**  | **O(log n)** |
| Delete        | **O(log n)**  | **O(log n)** |


## Install

```shell
npm i -S avl
```

```js
import AVLTree from 'avl';
const tree = new AVLTree();
```

Or get it from CDN
```html
<script src="https://unpkg.com/avl"></script>
<script>
  var tree = new avl();
  ...
</script>
```
Or use the compiled version 'dist/avl.js'.

## API

* `new AVLTree([comparator], [noDuplicates:Boolean])`, where `compare` is optional comparison function
* `tree.insert(key:any, [data:any])` - Insert item
* `tree.remove(key:any)` - Remove item<commit_msg>runkit playground link<commit_after># AVL tree [![npm version](https://badge.fury.io/js/avl.svg)](https://badge.fury.io/js/avl) [![CircleCI](https://circleci.com/gh/w8r/avl.svg?style=svg)](https://circleci.com/gh/w8r/avl)

[AVL-tree](https://en.wikipedia.org/wiki/AVL_tree): **[fast](#benchmarks)**(non-recursive) and **simple**(< 500 lines of code)

![AVL-tree](https://upload.wikimedia.org/wikipedia/commons/a/ad/AVL-tree-wBalance_K.svg)

| Operation     | Average       | Worst case   |
| ------------- | ------------- | ------------ |
| Space         | **O(n)**      | **O(n)**     |
| Search        | **O(log n)**  | **O(log n)** |
| Insert        | **O(log n)**  | **O(log n)** |
| Delete        | **O(log n)**  | **O(log n)** |


## Install

```shell
npm i -S avl
```

```js
import AVLTree from 'avl';
const tree = new AVLTree();
```

Or get it from CDN
```html
<script src="https://unpkg.com/avl"></script>
<script>
  var tree = new avl();
  ...
</script>
```
Or use the compiled version 'dist/avl.js'.

[Try it in your browser](https://npm.runkit.com/avl)

## API

* `new AVLTree([comparator], [noDuplicates:Boolean])`, where `compare` is optional comparison function
* `tree.insert(key:any, [data:any])` - Insert item
* `tree.remove(key:any)` - Remove item
{'fraction_non_alphanumeric': 0.25435398946942084, 'fraction_numerical': 0.004050222762251924, 'mean_word_length': 3.0625, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 15, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1103702', 'n_tokens_mistral': 965, 'n_tokens_neox': 928, 'n_words': 184}