×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# FEW EXERCISE ISSUES :p

## FEW EXERCISE ISSUES :p

(OP)
Hey friends I am pretty new to Prolog .
But this problem has intrigued me for over a month now.
I do not want to use cut or any non-logical Prolog built-ins.
And I would ask anybody who understand this language , to provide me the detailed logic and how his solution would actually work.
I am interested in learning by understanding from others too instead of just working hard and not asking others.

So here's my doubt.

Consider representing student grades using the following data:
A student name is represented using a Prolog atom like bill.
A grade-tree is an ordered binary tree which is one-of the following:
[] represents the empty tree.
Represents a tree with Name a prolog atom representing a student name, Grade is a Prolog integer representing a grade and SL is a grade-tree containing only names less-than Name (using Prolog's binary relation @<) and SR is a grade-tree containing only names greater-than Name (using Prolog's binary relation @>).
Write Prolog's procedures:

Given a grade-tree GivenGradeTree, matches Grade with the grade stored for name Name in GivenGradeTree. Fails if there is no match for Name in GivenGradeTree. Should use the ordering of the tree to minimize the search.

Example log:

S1 = treeStudent(nameGrade(jim, 95), [], [])
false.

S1 = treeStudent(nameGrade(tom, 90), [], [])
S2 = treeStudent(nameGrade(tom, 85), [], [])
false.

false.

?-
I think the 3rd example fails because there is no grade for ann.

### RE: FEW EXERCISE ISSUES :p

(OP)
Guys I solved it. Please delete the post :)

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Close Box

# Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!