[Show all top banners]

Overhaulin
Replies to this thread:

More by Overhaulin
What people are reading
Subscribers
:: Subscribe
Back to: Kurakani General Refresh page to view new replies
 COmputer Science Help
[VIEWED 3840 TIMES]
SAVE! for ease of future access.
Posted on 05-17-11 9:33 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

 I have a prolog program to write and was wondering if anyone out there could please please help me. I have done almost half of it and am stuck. i would be really thankful to anyone who would be wiling to help me.
Thanks in advance.

The program is about correctly deleting the values from a binary search tree while maintaing the search tree property.
The search tree properties are as follows:

1. If there are no childrenand the value to delete does not match the value in teh node, then ignore the delete request.
2. If val to del is greater than the val at the node, then delete ot from rt subtree
3. If the value to del is less than the value at the node, then delete it from left subtree.
4. If val u wish to delete is a  node with no left subtree, then you may delete the node by replacing it with its right subtree.
5. If the val you wish to delete is a node with no rt. subtree, then yoy may delete the node by replacing it with its left subtree.
6. If the val you wish to delete is in a node with both a left and rt ubtree, then you may delete the node by getting the left most value of the right subtree,call this A and then replacing the value in the node by A and deleting A from the right subtree.

I have written the codes for the first 3:

1. delTree(Val,node(N,nil,nil),node(N,nil,nil)) :- Val \= N.
2. delTree(Val,node(N,L,R),node(N,L,DR)):- Val > N, delTree(Val,R,DR).
3. delTree(Val,node(N,L,R),node(N,DL,R)):- Val< N, delTree(Val,L,DL).

Thanks in advance






 
Posted on 05-17-11 9:38 PM     [Snapshot: 1]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

In addtion: * * You may have to write an additional predicate called getLeftmost(T,Val) which gives a tree, T, will respond with the left most value , Val, in that tree to write the codes for no.6.
 
Posted on 05-18-11 1:07 PM     [Snapshot: 179]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Does Anyone have any idea on this. Please Any help would be appreciated.

Thanks in advance.


 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 90 days
Recommended Popular Threads Controvertial Threads
TPS Re-registration
What are your first memories of when Nepal Television Began?
निगुरो थाहा छ ??
Basnet or Basnyat ??
Sajha has turned into MAGATs nest
NRN card pros and cons?
Will MAGA really start shooting people?
Democrats are so sure Trump will win
मन भित्र को पत्रै पत्र!
Top 10 Anti-vaxxers Who Got Owned by COVID
काेराेना सङ्क्रमणबाट बच्न Immunity बढाउन के के खाने ?How to increase immunity against COVID - 19?
TPS Work Permit/How long your took?
Breathe in. Breathe out.
3 most corrupt politicians in the world
Dementia Joe has been selected to become the next President
Trumpism project 2025 everyone should read https://www.project2025.org/
आज बाट तिहारको सेल सकियो
चितवनको होस्टलमा १३ वर्षीया शालिन पोखरेल झुण्डिएको अवस्था - बलात्कार पछि हत्याको शंका - होस्टेलहरु असुरक्षित
शीर्षक जे पनि हुन सक्छ।
Disinformation for profit - scammers cash in on conspiracy theories
Nas and The Bokas: Coming to a Night Club near you
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters