subject

USE PROLOG Write a file name 'bstStuff. pl' For all of the below, we'll represent a Binary Search Tree in prolog the following way:
bst(L, V, R)
.. where:
we presume 'V' is a number
'L' is a 'bst' holding elements strictly less than 'V', or is empty
'R' is a 'bst' holding elements greater than or equal to 'V', or is empty
'nil' represents an empty node/subtree
e. g.:
a very small bst holding only '1' is:
bst(nil, 1, nil).
a balanced bst holding '1' through '3' is:
bst( bst(nil, 1, nil), 2, bst(nil, 3, nil)).
an imbalanced bst holding '1' through '3' is:
bst( bst( bst( nil, 1, nil), 2, nil), 3, nil).
'bstStuff. pl' should contain three definitions:
get_min(bst(L, V, R), X) where 'X' is the minimal element in the bst given. You need no more than two rules to define it, but you can use as many as you like.
get_max(A, X) where 'X' is the maximal element in the bst given. You need no more than two rules to define it, but you can use as many as you like.
is_bst(bst(L, V, R)) where the bst is tested to see if it is a correctly-formed bst. You need no more than one rule to define it, but you can use as many as you like. While using only one rule might feel a bit complex, it will make the definition much cleaner and easier to debug. Hint: think about what it means for a tree to be a bst and take a look at get_min and get_max.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:00
What is the name of the option in most presentation applications with which you can modify slide elements? 1. the option enables you to modify a slide element in most presentation applications.
Answers: 3
question
Computers and Technology, 23.06.2019 01:00
Petrică, tânăr licean în clasa a ix-a, a primit în dar de la părinţii săi un cont bancar pentru micile sale cheltuieli curente. el este pasionat de internet banking şi îşi verifică cu grijă toate tranzacţiile efectuate. pentru creşterea securităţii tranzacţiilor online, banca îi furnizează lui petrică un număr pe care el va trebui să îl modifice, obţinând un număr tan – număr de autentificare a tranzacţiei (transaction authentication number). regula de obţinere a numărului tan este următoarea: se formează cel mai mic număr par din toate cifrele numărului furnizat de bancă. cerinţă cunoscând numărul n furnizat de bancă, să se determine numărul tan obţinut de petrică. date de intrare fişierul tan.in conţine pe prima linie numărul natural n cu semnificaţia din enunţ. date de ieşire fişierul de ieşire tan.out va conţine o singură linie pe care va fi scris numărul tan cerut. restricţii • 0 < n < 18*1018 • n are cel puţin o cifră pară • numărul tan obţinut nu poate conţine zerouri nesemnificative
Answers: 2
question
Computers and Technology, 23.06.2019 05:20
What did creator markus “notch" persson initially call his game
Answers: 1
question
Computers and Technology, 23.06.2019 12:00
Using the list, you can select the number of photos that will appear on each slide. a. theme b. frame shape c. pictures in album d. picture layout
Answers: 1
You know the right answer?
USE PROLOG Write a file name 'bstStuff. pl' For all of the below, we'll represent a Binary Search T...
Questions
question
Mathematics, 20.10.2020 21:01
question
Mathematics, 20.10.2020 21:01
question
Mathematics, 20.10.2020 21:01
Questions on the website: 13722363