subject
Computers and Technology, 09.07.2021 01:30 bnnn

Lists Write the following predicates on lists.

β€’ equal/2 meaning that both given lists are equal:

?- equal([3, 5, 2, 1], [3, 5, 2, 1]).

true

?- equal([3, 5, 2, 1], [1, 2, 3, 5]).

false

?- equal(bob, bob).

false

β€’ contains/2 meaning that the list contains an element:

?- contains([3, 5, 2, 1], 2).

true

?- contains([3, 5, 2, 1], 4).

false

β€’ reverse/2 meaning the first list is the reverse of the second.

?- reverse([3, 5, 2, 1], X).

X = [1, 2, 5, 3]

?- reverse (bob, X).

false

β€’ sum/2 meaning the second member is the sum of elements in the first.

?- sum([3, 5, 2, 1], S).

S = 11

?- sum([], S).

S = 0

Binary trees
We will create a data structure that represents binary trees. Each node will be represented as bt(L, E, R), where L is the left subtree, R is the right subtree, and E is the element at the given note. An empty tree is denoted as the atom nil.

β€’ Write the predicate binary_treee/1, that returns true if the argument is a binary tree:
?- binary_treee(nil)
true
?- binary_tree(bt(nil, 3, nil))
true
?- binary_tree(bt(bt(nil, 4, bt(nil, 5, nil)), 3, nil))
true
?- binary_tree(bt(nil, 3))
false

β€’ Write the predicate in_order/2, that returns the list of arguments ordered by the in-order traversal (left-to-right: https://www. geeksforgeeks. org/tree-traversals-inorder-preorde r-and-postorder/ ):
?- in_order(bt(bt(nil, 4, bt(nil, 5, nil)), 3, nil), L)
L = [4, 5, 3]

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 20:00
Need asap assignment directions: think of an organization (business, religious institution, volunteer organization, sports team) with which you have been involved. imagine outfitting it with an it infrastructure. prepare a plan for what you would do to support outfitting it. draw a map of a network connecting all the individuals, give them pcs and printers, and lay out the design as best you can. the purpose is to begin working with these concepts, not to build a perfect network.
Answers: 2
question
Computers and Technology, 23.06.2019 05:30
Sally is editing her science report about living things. she needs to copy a paragraph from her original report. order the steps sally needs to do to copy the text to her new document.
Answers: 1
question
Computers and Technology, 23.06.2019 11:00
This chapter lists many ways in which becoming computer literate is beneficial. think about what your life will be like once you’re started in your career. what areas of computing will be most important for you to understand? how would an understanding of computer hardware and software you in working from home, working with groups in other countries and contributing your talents.
Answers: 1
question
Computers and Technology, 23.06.2019 11:30
The most accurate readings that you can take on an analog vom are when the meter's pointer is at the a. center scale. b. extreme right. c. near right. d. extreme left.
Answers: 1
You know the right answer?
Lists Write the following predicates on lists.

β€’ equal/2 meaning that both given lists a...
Questions
question
Mathematics, 24.02.2021 23:40
question
Arts, 24.02.2021 23:40
question
Mathematics, 24.02.2021 23:40
question
Mathematics, 24.02.2021 23:50