I have to make a binary search tree using Prolog that contains the following features: insert, search, pre-order, in-order and post-order. My problem is that I don't even know where to begin. I've tried looking online for information, but I don't understand enough for anything to make sense to me. I have a working BST in python and I thought I would be able to somehow translate that into Prolog but I'm not having any luck with it. If anyone could give me any pointers on how to even start this, it would be much appreciated!!
Asked
Active
Viewed 408 times
0
-
Are you in a class for Prolog? Then what has the teacher taught you? – Guy Coder Dec 13 '18 at 18:24
-
@GuyCoder I'm not in a class for Prolog, we were just told to create a BST in an OO based language and a Logic based language. We haven't been taught anything. – Chilly Dec 13 '18 at 18:26
-
1I would suggest focusing on a small subset of the problem instead of trying to port existing code to Prolog. For example, in Prolog how would one represent a node in a tree? Try starting there and building up. – Brandon Tweed Dec 13 '18 at 18:26
-
have you ever wrote any code in Prolog? do you know what Prolog terms are? – Will Ness Dec 13 '18 at 18:46
-
@WillNess no, I’m afraid I haven’t. I’m doing a semester at a different university as part of my course and I’ve got no choice in the matter unfortunately. I don’t really know anything about Prolog, trying to learn but it’s proving very difficult for me! – Chilly Dec 13 '18 at 18:48
-
then it is beyond my comprehension how is it expected of you to learn a semester worth of material on your own for this one assignment, in a day or two. do you know what unification is? – Will Ness Dec 13 '18 at 18:49
-
@WillNess I was told the majority of the marks are going for the comparing and contrasting of the two different implementations, but I still need to submit code for it - it makes no sense to me either, trust me! I do not know what unification is, no. – Chilly Dec 13 '18 at 18:51
-
you're welcome to try reading e.g. [a few of my recent Prolog answers](https://stackoverflow.com/search?tab=newest&q=user%3a849891%20%5bprolog%5d), where I tried to talk about very basic stuff concisely (not the last one, start with the one before last, and the one linked inside it). see how it's going, feel free to ask for clarifications as needed. – Will Ness Dec 13 '18 at 18:57
-
@WillNess ah thank you!! I’ll have a look at them and see what they do for me, I really appreciate your help :) – Chilly Dec 13 '18 at 18:59
-
1but this whole situation isn't right. your teachers clearly expect someone else to do their job for them (for you). – Will Ness Dec 13 '18 at 19:00
-
@WillNess I completely agree with you but unfortunately I can’t really do anything about it. The joys of being a foreign student.. – Chilly Dec 13 '18 at 19:29
-
1Related question: [Procedural and declarative reading of facts and predicates in Prolog](https://stackoverflow.com/q/53797814/1243762) – Guy Coder Dec 16 '18 at 11:36