diff --git a/README.md b/README.md
index a9fb686..3e4d36c 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# string-dsa [](https://travis-ci.com/thsubaku9/string-dsa) [](https://coveralls.io/github/thsubaku9/string-dsa?branch=main)
+# string-dsa [](https://travis-ci.com/thsubaku9/string-dsa) [](https://coveralls.io/github/thsubaku9/string-dsa?branch=main)  
> String oriented Data Structures and Algorithms library for JavaScript
## Installation
@@ -18,6 +18,7 @@ List of supported Data Structures and Algorithms are :
- [Edit/Levenshtein Distance](https://github.com/thsubaku9/string-dsa/blob/main/src/edit_distance.js)
- [Knuth Morris Pratt](https://github.com/thsubaku9/string-dsa/blob/main/src/search/kmp.js)
- [Rabin Karp](https://github.com/thsubaku9/string-dsa/blob/main/src/search/rabin_karp.js)
+- [Trie](https://github.com/thsubaku9/string-dsa/blob/main/src/Trie.js)
## Utilization
To utilize in Node.Js:
@@ -26,6 +27,17 @@ To utilize in Node.Js:
const stringDSA = require('string-dsa');
```
+To utilize in Vanilla Js:
+
+```sh
+# follow cloning steps
+$ npm run prod
+$ cp ./dist/string-dsa.js /YOUR/DIRECTORY/FILENAME.js
+```
+
+```html
+
+```
## Development Steps
Cloning:
diff --git a/package-lock.json b/package-lock.json
index 580cb77..98d39aa 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "string-dsa",
- "version": "0.2.3",
+ "version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/package.json b/package.json
index 3988c89..b5df213 100644
--- a/package.json
+++ b/package.json
@@ -1,14 +1,14 @@
{
"name": "string-dsa",
- "version": "0.3.1",
- "description": "String Data Structures and Algorithm Library in JavaScript",
+ "version": "1.0.0",
+ "description": "String Data Structures and Algorithms Library in JavaScript",
"main": "src/index.js",
"files": [
"dist",
"src"
],
"scripts": {
- "coverage": "nyc mocha --recursive",
+ "coverage": "nyc mocha --recursive",
"dev": "webpack -d",
"test": "mocha --recursive",
"test:coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
@@ -23,7 +23,8 @@
"String Data Structures",
"Bloom Filter",
"Custom Sort",
- "Levenshtein Distance"
+ "Levenshtein Distance",
+ "Trie"
],
"author": "Kaustubh J ",
"license": "ISC",
diff --git a/src/Trie.js b/src/Trie.js
new file mode 100644
index 0000000..bb46044
--- /dev/null
+++ b/src/Trie.js
@@ -0,0 +1,140 @@
+"use strict";
+
+/**Class implementation of Trie */
+class Trie{
+ /**
+ * Instantiate your Trie class
+ */
+ constructor(){
+ this._rootNode = new Object();
+ this._rootNode["$"] = false;
+ }
+
+ /**
+ *
+ * @param {String} searchTerm search term to be inserted into the trie
+ */
+ insertSingle(searchTerm){
+ //use the root node, if current element isn't there add it; go down the node and iterate over the word
+ let currNode = this._rootNode;
+ for (let j=0; j{
+
+ const myT = new Trie();
+ const st1 = "can"
+ const st2 = "candy"
+ const st3 = "ban"
+ const searchSpace = "can the real candy ban?"
+ const resultPos = [ [ 0, 2 ], [ 13, 15 ], [ 13, 17 ], [ 19, 21 ] ]
+ it("should insert a bunch of keys",() => {
+ myT.insertList([st1,st2,st3])
+ assert.deepStrictEqual(myT.listAllElements(),[st1,st2,st3])
+ });
+
+ it("should find correct locations of searchSpace",() => {
+ const res = myT.find(searchSpace)
+ assert.deepStrictEqual(res,resultPos)
+ });
+
+ it("remove given keys", () => {
+ myT.removeList([st2,st3])
+ assert.deepStrictEqual(myT.listAllElements(),[st1]);
+ myT.insertList([st2,st3])
+ })
+})
\ No newline at end of file