String used in Binary Search Trees

salik

New member
Joined
Mar 29, 2016
Messages
4
Hi all, I apologize in advance if I am posting in the wrong thread as I am not very sure where I should place my questions.
Anyway, I am trying to construct a Binary Search Tree (BST) using this sentence without the quotes - 'Maths is hard and I don't want to learn any more'

Please see attached. To be honest, I am not very sure if I am doing it correctly, as I am pretty much comparing the first letter of each word, and especially on cases for 'I', as it is a one-lettered word, where or how should I done in such scenarios?

attachment.php
 

Attachments

  • BST.jpg
    BST.jpg
    30.8 KB · Views: 15
I am trying to construct a Binary Search Tree (BST)...
Are you referrring to the type of thing they're talking about here?

...using this sentence without the quotes - 'Maths is hard and I don't want to learn any more'
How does your book (or instructor) define the ordering ("less than" and "greater than") for words in a sentence? Are you supposed to work alphabetically (like Example 5.2.1 here)? (Note: As you'll see if you check a dictionary, "I" [and "i"] would come before "is".)

Thank you! ;)
 
Are you referrring to the type of thing they're talking about here?

Yes I am referring to the one as you have mentioned. However instead if dealing it in numerical terms, I am dealing with strings/characters.

I guess I was turned off when I saw those coding languages as I had thought it is somewhat similar to the BST that I was taught in my discrete maths.

How does your book (or instructor) define the ordering ("less than" and "greater than") for words in a sentence? Are you supposed to work alphabetically (like Example 5.2.1 here)? (Note: As you'll see if you check a dictionary, "I" [and "i"] would come before "is".)

My bad on this as I seems to have omitted out a part of my questions. Yes, the words needs to be placed in standard dictionary ordering
 
Last edited by a moderator:
Yes I am referring to the one as you have mentioned. However instead if dealing it in numerical terms, I am dealing with strings/characters.
So you're doing what is illustrated and explained in the second link I'd provided earlier.

Since you're working with alphabetical order, and since "I" comes before "is" (as explained earlier) and "to" comes after "maths", obviously the displayed tree is not correct. Try applying the thinking and methods explained in the two links. ;)
 
Top