Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This problem is motivated by the famous Four fours puzzle. An arithmetic crpression tree is a binary tree that is either a single m ber

image text in transcribed
image text in transcribed
This problem is motivated by the famous "Four fours puzzle." An arithmetic crpression tree is a binary tree that is either a single m ber or has arithmetic operations ( t o r) at its internal nodes and ambers at its leaves. The value of the tree is computed recursively by computing the value of the left subtree, the value of the right subtree, and then using the arithmetic operation at the root of that tree to combine the values of the left and right subtrees. For example, the value of the tree C. 3. 5) is 8, the value of the tree (-. 3, 5) is -2 and the value of the tree [..[., 4, 2], [-. 9. 2]] is 12. We'll use the symbol to represent division, but on your Prolog platform the operation may be // instead check if // integer division or normal division on your platform). So, the value of U. 7. 2] may be 3 or 3.5 depending on your system. Youll want to use whatever corresponds to regular division (not integer division). Now, imagine that you are given a list of arithmetic operators which is some subset of [., ,, /1, a list of integers L, an integer "target" X, and an arithmetic expression tree. The question that we ask is Does the arithmetic tree tase only the operations in the given list, cach occurrence of a number in L appears crectly once in any order), and the tree evaluates to the target value X? Here are some examples 7- solve(+,-), (1, 2, 3). 7. [+, 1, [., 3, 2]]). true 7- solve(C+,-), (1, 2, 3), 7. L., 1, L., 3, 2]]). false

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Lab Manual For Database Development

Authors: Rachelle Reese

1st Custom Edition

1256741736, 978-1256741732

More Books

Students also viewed these Databases questions