Computers and Technology

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.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 21:00, briannaleiigh
Kirk found a local community college with a two-year program and he is comparing the cost with that of an out-of-state two-year school. what is the expected total cost for one year at the local community college if kirk lives at home? what is the expected total cost for one year at the out-of-state school if kirk lives on campus?
Answers: 2
image
Computers and Technology, 22.06.2019 21:50, dijaflame67
Answer the following questions regarding your system by using the commands listed in this chapter. for each question, write the command you used to obtain the answer. a. what are the total number of inodes in the root filesystem? how many are currently utilized? how many are available for use? b. what filesystems are currently mounted on your system? c. what filesystems are available to be mounted on your system? d. what filesystems will be automatically mounted at boot time?
Answers: 1
image
Computers and Technology, 23.06.2019 20:30, cristalcastro901
If an appliance consumes 500 w of power and is left on for 5 hours, how much energy is used over this time period? a. 2.5 kwh b. 25 kwh c. 250 kwh d. 2500 kwh
Answers: 1
image
Computers and Technology, 24.06.2019 01:00, cheycheybabygirl01
How can the temperature of a room be raised by 5degreesf?
Answers: 1
Do you know the correct answer?
USE PROLOG Write a file name 'bstStuff. pl' For all of the below, we'll represent a Binary Search T...

Questions in other subjects:

Konu
Mathematics, 11.09.2020 14:01
Konu
Mathematics, 11.09.2020 14:01
Konu
Mathematics, 11.09.2020 14:01
Konu
Physics, 11.09.2020 14:01
Konu
Mathematics, 11.09.2020 14:01
Konu
Physics, 11.09.2020 14:01
Konu
Mathematics, 11.09.2020 14:01
Konu
Mathematics, 11.09.2020 14:01
Konu
Mathematics, 11.09.2020 14:01
Konu
Mathematics, 11.09.2020 14:01