Suppose that you have been asked to consider creating tree structures for something like beverages (Shown in image 1)   In this case you will need to consider writing a function to create such tree in Kotlin. Moreover, you will need to traverse the tree in at least two ways (e.g. Depth-First Traversal and Breadth-First Traversal). In addition you will need the following functionality: (a) Generic Function to search for an element in a tree (b) Delete an element from tree (c) Add element to the tree (d) Count Leaves (e) Size of the tree (f) Testing if the tree is balanced Finally, you will need to adjust the creation of the general tree to a Trie Tree. The trie (pronounced try) is a tree that specializes in storing data that can be represented as a collection, such as English words (Shown in image 2):   In this case, you will need to develop different associated function to do the followings: 1. Insert a new element in a trie 2. Test if the trie contains an element

icon
Related questions
Question
100%

Suppose that you have been asked to consider creating tree structures for something like beverages (Shown in image 1)

 

In this case you will need to consider writing a function to create such tree in Kotlin. Moreover, you will need to traverse the tree in at least two ways (e.g. Depth-First Traversal and Breadth-First Traversal). In addition you will need the following functionality:

(a) Generic Function to search for an element in a tree

(b) Delete an element from tree

(c) Add element to the tree

(d) Count Leaves

(e) Size of the tree

(f) Testing if the tree is balanced

Finally, you will need to adjust the creation of the general tree to a Trie Tree. The trie (pronounced try) is a tree that specializes in storing data that can be represented as a collection, such as English words (Shown in image 2):

 

In this case, you will need to develop different associated function to do the followings:

1. Insert a new element in a trie

2. Test if the trie contains an element

black
tea
green
hot
coffee
chai
beverages
cocoa
ginger ale
soda
cold
milk
bitter lemon
Transcribed Image Text:black tea green hot coffee chai beverages cocoa ginger ale soda cold milk bitter lemon
root
C
تا ہے۔ کو
T B.
U 0.
T.
E.
A trie containing the words CAT, CUT, CUTE, TO, and B
Transcribed Image Text:root C تا ہے۔ کو T B. U 0. T. E. A trie containing the words CAT, CUT, CUTE, TO, and B
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer