Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In Prolog help me figure out what is wrong with this delete predicate . The getMin function is working so i dont know why this
In Prolog help me figure out what is wrong with this delete predicate . The getMin function is working so i dont know why this is having issues.
\% delete/3: a predicate to delete an integer from a binary search tree \% Delete function to remove a node from a binary search tree. delete(nil, _, nil). delete(tree(X,nil,nil),X, nil). delete(tree( X, Left, nil), X, Left). delete(tree( X, nil, Right), X, Right). delete(tree(X, Left, Right), X, tree(Pred, NewLeft, RightNew)) :- getMin(Right, Pred), delete(Right, Pred, RightNew), replaceRoot(X, Pred, Left, NewLeft). delete(tree(X, Left, Right), Y, tree( X, NewLeft, Right)) :- Y
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started