Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ignore red x , it's the prolog build question Homework reinforces understanding of memory management (stacks and heaps) and using Java for both object oriented

Ignore red x , it's the prolog build question

image text in transcribed
Homework reinforces understanding of memory management (stacks and heaps) and using Java for both object oriented and non-OO style programming, and Prolog logic prog For questions asking for a diagram, either a. make it directly in worksheet using Word, or b. use other paint/drawing program to make the diagram and copy/paste it into the worksheet, or c. draw it by hand and take a CLEAR screenshot; write legibly! Upload it in addition to your worksheet in the same "attempt" on blackboard For any programming exercises, as normal, turn in: a. Source code of program b. Clear screenshot of running program with results showing (have a comment with your name in it) Homework Turn in a Word Doc or PDF that shows completion fo the following programs: lava OO: Complete Exercise #2 from Chapter 15 (page 290). (worth 40%) Prolog: Build upon the parent(X, Y) predicate example given in the book and class to complete Exercises #1-6 of Chapter 19 (page 410). (worth 60%) 410 Chapter 19-A First Look at Prolog Exercises Define your answers to Exercises 1 through 6 in terms of the base relations parent (X, Y), female (X), and male (X) . To test your code, define some parent facts like those in this chapter, along with appropriate female and male facts. But your solutions should be general enough to work with any set of such facts. Exercise 1 Define a mother predicate so that mother (X, Y) says that X is the mother of Y. Exercise 2 Define a father predicate so that father (X, Y) says that X is the father of Y. Exercise 3 Define a sister predicate so that sister (X, Y) says that X is a sister of Y. Be careful, a person cannot be her own sister. Exercise 4 Define a grandson predicate so that grandson (X, Y) says that X is a grandson of Y. Exercise 5 Define the first Cousin predicate so that firstCousin (X, Y) says that X is a first cousin of Y. Be careful, a person cannot be his or her own cousin, nor can a brother or sister also be a cousin. Exercise 6 Define the descendant predicate so that descendant (X, Y) says that X is a descendant of Y. Exercise 7 Define a third predicate so that third (X, Y) says that Y is the third element of the list X. (The predicate should fail if X has fewer than three ele- ments.) Hint: This can be expressed as a fact. Exercise 8 Define a first Pair predicate so that first Pair (X) succeeds if and only if X is a list of at least two elements, with the first element the same as the second element. Hint: This can be expressed as a fact. Exercise 9 Define a de13 predicate so that de13 (X, Y) says that the list Y is the same as the list X but with the third element deleted. (The predicate should fail if X has fewer than three elements.) Hint: This can be expressed as a fact

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

Unity From Zero To Proficiency Beginner A Step By Step Guide To Coding Your First Game

Authors: Patrick Felicia

1st Edition

1091872023, 978-1091872028

More Books

Students also viewed these Programming questions