Given an array of strings, print them in alphabetical (dictionary) order. If there are duplicates in input array, we need to print them only once.
Input : "abc", "xy", "bcd" Output : abc bcd xy Input : "geeks", "for", "geeks", "a", "portal", "to", "learn", "can", "be", "computer", "science", "zoom", "yup", "fire", "in", "data" Output : a be can computer data fire for geeks in learn portal science to yup zoom
Trie is an efficient data structure used for storing data like strings. To print the string in alphabetical order we have to first insert in the trie and then perform preorder traversal to print in alphabetical order.
abc bcd xy
This article is contributed by Pranav. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Sorting array of strings (or words) using Trie | Set-2 (Handling Duplicates)
- Print all possible combinations of words from Dictionary using Trie
- Count the number of words with given prefix using Trie
- Counting the number of words in a Trie
- Check if the given Trie contains words starting from every alphabet
- Print Strings In Reverse Dictionary Order Using Trie
- Sorting objects using In-Place sorting algorithm
- Count words that appear exactly two times in an array of words
- Print all possible joints of a Trie constructed from a given list of strings
- Know Your Sorting Algorithm | Set 1 (Sorting Weapons used by Programming Languages)
- Know Your Sorting Algorithm | Set 2 (Introsort- C++’s Sorting Weapon)
- Check if the given string of words can be formed from words present in the dictionary
- Count inversions in an array | Set 4 ( Using Trie )
- Auto-complete feature using Trie
- Pattern Searching using a Trie of all Suffixes
- Find shortest unique prefix for every word in a given list | Set 1 (Using Trie)
- Longest Common Prefix using Trie
- Count of distinct substrings of a string using Suffix Trie
- Boggle | Set 2 (Using Trie)
- Trie memory optimization using hash map