Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Consider the following Prolog facts and rules:
insert(X, L, [X|L]).
insert(X, [H|L], [H|L1]) :- insert(X, L, L1).
permute([], []).
permute([H|T], P) :- permute(T, P1), insert(H, P1, P).
Draw the Prolog trees corresponding to the following queries; show the rule and substitution used
at each step:
(a)
?- permute([a,b], Y).
Y = [a, b] ;
Y = [b, a] ;
false.
(b) Show the part of the tree with solutions and explain why the tree is infinite:
?- permute(Y, [a,b]).
Y = [a, b] ;
Y = [b, a] ;
...
(c) Explain the effect of the cut in the tree.
?- not(permute(Y, [])).
false.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- For words like these, where can you get definitions? Why are they so crucial when it comes to parsing trees?arrow_forwardjava code to ExpressionTreeOp represents an element in an expression tree.arrow_forwardWrite an Algorithms for Data structures for checking whether the queue is Full and Empty.arrow_forward
- The first step in building a parse tree is to break up the expression string into a list of tokens. There are four different kinds of tokens to consider: left parentheses, right parentheses, operators, and operands. We know that whenever we read a left parenthesis we are starting a new expression, and hence we should create a new tree to correspond to that expression. Conversely, whenever we read a right parenthesis, we have finished an expression. We also know that operands are going to be leaf nodes and children of their operators. Finally, we know that every operator is going to have both a left and a right child.Using the information from above, we can define four rules as follows: 1. If the current token is a '(', add a new node as the left child of the current node, and descend to the left child. 2. If the current token is in the list ['+','-','/','*'], set the root value of the current node to the operator represented by the current token. Add a new node as the right child of…arrow_forwardFor words like these, where can you get definitions? Why are they so crucial when it comes to parsing trees?arrow_forward4. Determine the sentence that represent this parse tree digit 4. digit digit a. (4+5)*3 b. (3+4)*5 c.3*4+5 d. 3*5+4arrow_forward
- 1. Draw the recursion tree generated when calling hanoi (3, 1, 3). The first parameter is numDisks, the second is the number of the fromPeg, and the last is the toPeg. Each node in the tree should include the function name and three parameters described above. hanoi (3, 1, 3) is the root node in the drawing.arrow_forwardpart 1. draw the recursive call tree for the following function when its called with a(7) int a (int n) { if (n % 4== 0) { return n+1;} else { return a(n-1) + a (n*4); } } part 2. what is the returning value?arrow_forwardExplore the concept of Binary Expression Trees and their role in evaluating mathematical expressions. How can you construct and evaluate expressions using binary expression trees?arrow_forward
- 2. method. Assume that T(1) (1). Solve the following recurrences using the recursion tree d. T(n) = 4T(n/2) + n e. T(n) = 2T(n-2) +1 f. T(n)= T(n/2) +T(n/3) + narrow_forwardSolve the binary expression for the numerical answer and draw its respective expression tree 8 7 – 6 5 4 3 + + + 2 1 / * +arrow_forwardL={anbman | n,m=1,2,3....} is given. Draw the derivation tree for the string aaaabbbaaaa.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education