From 5b6005a930aab89040573d0eb06e8e26bf44e1d7 Mon Sep 17 00:00:00 2001 From: vinitachimalgi <62709854+vinitachimalgi@users.noreply.github.com> Date: Tue, 8 Jun 2021 17:59:48 +0530 Subject: [PATCH 1/9] Add files via upload --- Dictionary-main (1).zip | Bin 0 -> 3788 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Dictionary-main (1).zip diff --git a/Dictionary-main (1).zip b/Dictionary-main (1).zip new file mode 100644 index 0000000000000000000000000000000000000000..ab4988eae008edb0c36f993e30758caeebe6bec5 GIT binary patch literal 3788 zcmaKvbyQS&AI1lVMgd(Jq`Q&s6p$Et5QmrrhDK6SLJ$e*kY*5u6c}I#=@O*75g1ZI zT0(NE7kBsFJ?r|u_nv#ty?;EPbAR{zp67fYZ8ab^A>jK#&DgE;`@^3%QUC$q;S+PW zCr*y0E?)N?OrJRNKGwwnU=={#!?pjE;r}i}EmsRQ0s#OqJOF^=Co&yHxrZ8xJPsCr z>D?bgw3w7{`XNo0P$a?Z)6}zvv|@XJV3Z!sY}iv2YJ=J8S^8GObgG+`2vNz&&V^J1 z*dHZDx;urG#URsn)<5X>c;>e;Q7FIPh=SJK8XJXe`h12~5?^Ye@1%M-)LAAoK0zHr zjPCLhaE}kAQ*BM=DhKrF8yU(#lyTB0s>EzJdy2u3{|nTB!4NJ-{e)yTWm31EKv8d5sMlcXV*W6N4|c zN2V#!7WLT#2Jf>sISv$f z`U_#h)yWX$E1{H2oEbK z(PjILBY3YfocYVqEUf6NTzQ*jzsk4LiXSP#lChQ<#R6}@T?mc(r zyhdn`zzNi%ZZ1dx<%|6Ily{OG!;fw&XupC*1T;?(3p}nMEg&5!=_-A>aj6QJ>Iskv zh*zWJ3ea)a-xF+{f?Er6g3`I7R=P_l;7r)9E)+ULExnSdrR?GM&e{pitQ1>5TfN;c z+#^eXO~FXw9*sL%{#nbo6Z-3;59Df^<6$JkE;Vo4Si9pq=%J30JIu+h)MZ1+hJ=@| z)OZnIz7MS_9%x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trees.java | 154 ++++++++++++++++++++++++++++++++++++++++++++++++ dictionary.java | 126 +++++++++++++++++++++++++++++++++++++++ node.java | 21 +++++++ 4 files changed, 354 insertions(+), 3 deletions(-) create mode 100644 Trees.java create mode 100644 dictionary.java create mode 100644 node.java diff --git a/README.md b/README.md index e674b94..7221eb4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,55 @@ -# Buffer_2.0 -Buffer_2.0 repo to submit your projects to.Repository containing folder-wise code for all submissions to Buffer : A Project Series, conducted between April, 2021 - June, 2020. +# Dictionary in Java +The following project implements a dictionary using Java. +Functionality available: +1. Adding a word to dictionary along with its meaning +2. updating a word's meaning +3. Delete a word and its meaning +4. search for a word's meaning -Each folder should contain a separate README to describe the files and project objective +Data Structure Used: +The data structure used to add words is **Trie**. It is an efficient information reTRIEval data structure. The other option to realize a +dictionary would be binary search trees, but a well balanced BST will need time proportional to M * log N, where M is maximum string +length and N is number of keys in tree.Using Trie, we can search the key in O(M) time. + +Since a dictionary is often used to search meanings of words, we chose to favor time complexity instead of space and went ahead with +tries. + +Code Design Paramters: +The trie node looks like this: +``` +public class Node +{ + char c; + boolean isWord; + Node[] children; + String meaning; + + public Node(char c) + { + this.c=c; + isWord=false; + children=new Node[26]; + } + public void setMeaning(String newMeaning) + { + this.meaning=newMeaning; + } + +} +``` +Here, each node has 26 children! thats a lot of children for a node. And a lot of space. But this much space REALLY helps us reduce +that searching time complexity from O(M * log N) down to O(M) time, where M is length of word and N is number of keys. Plus, +Tries are more space efficient when they contain a large number of short keys, because nodes are shared between keys with common +initial subsequences. So, when it comes to handling large amounts of data, trie is our obvious winner. + +Outcomes: +1. A new data structure - trie +2. + + + +References: +Data Structures and Algorithms Made Easy in Java- Book +https://thenextcode.wordpress.com/2015/04/12/trie-vs-bst-vs-hashtable/ +https://www.geeksforgeeks.org/trie-insert-and-search/ diff --git a/Trees.java b/Trees.java new file mode 100644 index 0000000..7538d1c --- /dev/null +++ b/Trees.java @@ -0,0 +1,154 @@ +package trees; +import java.util.Scanner + +public class Trie { + private Node root; + + public Trie() + { + root=new Node('\0'); + } + + public Node getRoot() { + return root; + } + + public void insert(String word,String meaning) + { + Node curr=root; + for(int i=0;i6); + + switch(choice) + { + case 1 : + System.out.println("Enter the number of words you want to insert: "); + if(sc.hasNextInt()) + { + n =sc.nextInt(); + for(int i=0;i Date: Tue, 8 Jun 2021 18:09:01 +0530 Subject: [PATCH 3/9] Delete Dictionary-main (1).zip --- Dictionary-main (1).zip | Bin 3788 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Dictionary-main (1).zip diff --git a/Dictionary-main (1).zip b/Dictionary-main (1).zip deleted file mode 100644 index ab4988eae008edb0c36f993e30758caeebe6bec5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3788 zcmaKvbyQS&AI1lVMgd(Jq`Q&s6p$Et5QmrrhDK6SLJ$e*kY*5u6c}I#=@O*75g1ZI zT0(NE7kBsFJ?r|u_nv#ty?;EPbAR{zp67fYZ8ab^A>jK#&DgE;`@^3%QUC$q;S+PW zCr*y0E?)N?OrJRNKGwwnU=={#!?pjE;r}i}EmsRQ0s#OqJOF^=Co&yHxrZ8xJPsCr z>D?bgw3w7{`XNo0P$a?Z)6}zvv|@XJV3Z!sY}iv2YJ=J8S^8GObgG+`2vNz&&V^J1 z*dHZDx;urG#URsn)<5X>c;>e;Q7FIPh=SJK8XJXe`h12~5?^Ye@1%M-)LAAoK0zHr zjPCLhaE}kAQ*BM=DhKrF8yU(#lyTB0s>EzJdy2u3{|nTB!4NJ-{e)yTWm31EKv8d5sMlcXV*W6N4|c zN2V#!7WLT#2Jf>sISv$f z`U_#h)yWX$E1{H2oEbK z(PjILBY3YfocYVqEUf6NTzQ*jzsk4LiXSP#lChQ<#R6}@T?mc(r zyhdn`zzNi%ZZ1dx<%|6Ily{OG!;fw&XupC*1T;?(3p}nMEg&5!=_-A>aj6QJ>Iskv zh*zWJ3ea)a-xF+{f?Er6g3`I7R=P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964%)9+bO1a+iWj zdIRF~#mzL2s)=4JQ5_p5-6%(_7}crZ*jtH@ Date: Tue, 8 Jun 2021 20:53:33 +0530 Subject: [PATCH 4/9] Delete Trees.java --- Trees.java | 154 ----------------------------------------------------- 1 file changed, 154 deletions(-) delete mode 100644 Trees.java diff --git a/Trees.java b/Trees.java deleted file mode 100644 index 7538d1c..0000000 --- a/Trees.java +++ /dev/null @@ -1,154 +0,0 @@ -package trees; -import java.util.Scanner - -public class Trie { - private Node root; - - public Trie() - { - root=new Node('\0'); - } - - public Node getRoot() { - return root; - } - - public void insert(String word,String meaning) - { - Node curr=root; - for(int i=0;i Date: Tue, 8 Jun 2021 20:53:47 +0530 Subject: [PATCH 5/9] Delete dictionary.java --- dictionary.java | 126 ------------------------------------------------ 1 file changed, 126 deletions(-) delete mode 100644 dictionary.java diff --git a/dictionary.java b/dictionary.java deleted file mode 100644 index e59be58..0000000 --- a/dictionary.java +++ /dev/null @@ -1,126 +0,0 @@ -package logic; -import trees.Trie; -import trees.Node; - -import java.util.Scanner; - -public class Dictionary { - public static void main(String [] args) - { - int choice = 0; - Trie Dictionary=new Trie(); - Scanner sc=new Scanner(System.in); - int n = 0; - do - { - do - { - - System.out.println("Enter your choice"); - System.out.println("1. INSERT A WORD"); - System.out.println("2. SEARCH A WORD"); - System.out.println("3. DELETE A WORD"); - System.out.println("4. UPDATE MEANING OF A WORD"); - System.out.println("5. DISPLAY WITH A PREFIX"); - System.out.println("6. DISPLAY ALL THE WORDS"); - System.out.println("0. EXIT"); - System.out.println("Enter choice : \n"); - if(sc.hasNextInt()) - { - choice = sc.nextInt(); - } - - }while(choice<0 || choice>6); - - switch(choice) - { - case 1 : - System.out.println("Enter the number of words you want to insert: "); - if(sc.hasNextInt()) - { - n =sc.nextInt(); - for(int i=0;i Date: Tue, 8 Jun 2021 20:54:01 +0530 Subject: [PATCH 6/9] Delete node.java --- node.java | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 node.java diff --git a/node.java b/node.java deleted file mode 100644 index 36cdac0..0000000 --- a/node.java +++ /dev/null @@ -1,21 +0,0 @@ -package trees; - - -public class Node { - char c; - boolean isWord; - Node[] children; - String meaning; - - public Node(char c) - { - this.c=c; - isWord=false; - children=new Node[26]; - } - public void setMeaning(String newMeaning) - { - this.meaning=newMeaning; - } - -} From 573dbfaa125c6e467a5cc5c2a17e04675a95778e Mon Sep 17 00:00:00 2001 From: vinitachimalgi <62709854+vinitachimalgi@users.noreply.github.com> Date: Tue, 8 Jun 2021 20:56:34 +0530 Subject: [PATCH 7/9] Add files via upload --- Dictionary.java | 146 ++++++++++++++++++++++++++++++++++++++++++ Node.java | 22 +++++++ Trie.java | 164 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 332 insertions(+) create mode 100644 Dictionary.java create mode 100644 Node.java create mode 100644 Trie.java diff --git a/Dictionary.java b/Dictionary.java new file mode 100644 index 0000000..8ec0563 --- /dev/null +++ b/Dictionary.java @@ -0,0 +1,146 @@ +package logic; + + +import java.util.Scanner; + +import logic.Trie; + +public class Dictionary +{ + public static void main(String [] args) + { + + int choice = 0; + Trie Dictionary=new Trie(); + Scanner sc=new Scanner(System.in); + int n = 0; + + do + { + + do + { + + System.out.println("\n\tM E N U"); + System.out.println("*******************************"); + System.out.println("1. INSERT A WORD"); + System.out.println("2. SEARCH A WORD"); + System.out.println("3. DELETE A WORD"); + System.out.println("4. UPDATE MEANING OF A WORD"); + System.out.println("5. DISPLAY WITH A PREFIX"); + System.out.println("6. DISPLAY ALL THE WORDS"); + System.out.println("0. EXIT"); + System.out.println("*******************************"); + System.out.print("Enter choice : "); + if(sc.hasNextInt()) + { + choice = sc.nextInt(); + } + + }while(choice<0 || choice>6); + + switch(choice) + { + case 1 : + System.out.print("\n Enter the number of words you want to insert : "); + + n =sc.nextInt(); + for(int i=0;i Date: Tue, 8 Jun 2021 20:58:40 +0530 Subject: [PATCH 8/9] Delete README.md --- README.md | 55 ------------------------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 7221eb4..0000000 --- a/README.md +++ /dev/null @@ -1,55 +0,0 @@ -# Dictionary in Java -The following project implements a dictionary using Java. -Functionality available: -1. Adding a word to dictionary along with its meaning -2. updating a word's meaning -3. Delete a word and its meaning -4. search for a word's meaning - - -Data Structure Used: -The data structure used to add words is **Trie**. It is an efficient information reTRIEval data structure. The other option to realize a -dictionary would be binary search trees, but a well balanced BST will need time proportional to M * log N, where M is maximum string -length and N is number of keys in tree.Using Trie, we can search the key in O(M) time. - -Since a dictionary is often used to search meanings of words, we chose to favor time complexity instead of space and went ahead with -tries. - -Code Design Paramters: -The trie node looks like this: -``` -public class Node -{ - char c; - boolean isWord; - Node[] children; - String meaning; - - public Node(char c) - { - this.c=c; - isWord=false; - children=new Node[26]; - } - public void setMeaning(String newMeaning) - { - this.meaning=newMeaning; - } - -} -``` -Here, each node has 26 children! thats a lot of children for a node. And a lot of space. But this much space REALLY helps us reduce -that searching time complexity from O(M * log N) down to O(M) time, where M is length of word and N is number of keys. Plus, -Tries are more space efficient when they contain a large number of short keys, because nodes are shared between keys with common -initial subsequences. So, when it comes to handling large amounts of data, trie is our obvious winner. - -Outcomes: -1. A new data structure - trie -2. - - - -References: -Data Structures and Algorithms Made Easy in Java- Book -https://thenextcode.wordpress.com/2015/04/12/trie-vs-bst-vs-hashtable/ -https://www.geeksforgeeks.org/trie-insert-and-search/ From b868dbbc6a37697c123abbbae278b946078dcf05 Mon Sep 17 00:00:00 2001 From: vinitachimalgi <62709854+vinitachimalgi@users.noreply.github.com> Date: Tue, 8 Jun 2021 21:00:48 +0530 Subject: [PATCH 9/9] Add files via upload --- README.md | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..7490f38 --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +# Dictionary in Java +The following project implements a dictionary using Java. +Functionality available: +1. Adding a word to dictionary along with its meaning +2. updating a word's meaning +3. Delete a word and its meaning +4. search for a word's meaning + + +### **Data Structure Used:** + +The data structure used to add words is **Trie**. Also known as **Prefix Trees**. Tries have the unique feature that the time to insert or to delete or find is almost identical because the code paths followed are most identical. It is an efficient information reTRIEval data structure. +There are other alternative data structures that can be used to build and perform these operations on a dictionary. The most significant one being BST. +We used Trie over BST for the following reasons: +* In trie looking up a key of length m takes worst case O(m) time. On the other hand a well balanced BST performs O((logn)) comparisons of keys where n is the number of elements in the tree.Hence is the worst case a BST will need time proportional to M * log N, where M is maximum string +length and N is number of keys in tree. Using Trie, we can search the key in O(M) time. +* Another huge advantage of Trie over the other considerable Data Structure HashTable is printing out all the words in alphabetical order. +* An efficient prefix search is also possible through Tries. +Since a dictionary is often used to search meanings of words, we chose to favor time complexity instead of space and went ahead with +tries. + +### **Code Design Parameters:** + +The trie node looks like this: +``` +public class Node +{ + char c; + boolean isWord; + Node[] children; + String meaning; + + public Node(char c) + { + this.c=c; + isWord=false; + children=new Node[26]; + } + public void setMeaning(String newMeaning) + { + this.meaning=newMeaning; + } + +} +``` +Here, each node has 26 children! thats a lot of children for a node. And a lot of space. But this much space REALLY helps us reduce +that searching time complexity from O(M * log N) down to O(M) time, where M is length of word and N is number of keys. Plus, +Tries are more space efficient when they contain a large number of short keys, because nodes are shared between keys with common +initial subsequences. So, when it comes to handling large amounts of data, trie is our obvious winner. + +### **Outcomes:** + +1. A new Data Structure- Trie - As students who have predominantly coded in C throughout the first two years of college, picking up a new language and a data structure that we weren't acquainted with was exciting and challenging. At a glance while Trie appeared to be a way more complex tree than the other trees, as we digged deeper we discovered the varied functionality of this data structure and why it is used more so for projects where large datasets are used. It makes their access and serach easier. +2. Understanding time and space complexitites better- We made a head to head comparsion of time complexities of varied data structures that could perform the same operations and then made an informed choice based on our observation. This has helped us greatly in understanding the paramount importance of time complexity in projects like these. The project has made us more intuitive and familair with the role of space and time complexity. +3. Working in a team along with fellow classmated beyond the classroom also has been a great experience. + +### **What's next for the project** + +We aim to improvise on the code and make in user friendly by incorporating Java Swing to enhance the real time effect. We also mean to import datasets using SQL and make the dictionary user-ready + +### **References:** + +1. Data Structures and Algorithms Made Easy in Java- Book + +2. https://thenextcode.wordpress.com/2015/04/12/trie-vs-bst-vs-hashtable/ +3. https://www.geeksforgeeks.org/trie-insert-and-search/ +4. https://www.baeldung.com/trie-java#:~:text=In%20a%20trie%2C%20every%20node,of%20the%20trie%20as%20well +5. https://gist.github.com/prettymuchbryce/3719435/868ae3231e98b3bde667a9e899157e20dd58c366 +6. https://www.geeksforgeeks.org/implement-a-dictionary-using-trie/