Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

Question 1:

Briefly explain these main programming paradigm (Logic, Functional, Object Oriented, Procedural, Imperative and Aspect-oriented), and for each of these paradigms name at least one language that can be used for programming in that paradigm.

Note: The purpose of this question is to motivate you to conduct a short research based on the available resources on the Internet or in our university library. For answering this question you should write one short paragraph for explaining each programming paradigm. For writing those short paragraphs, you can study or use all available online resources on the Internet or all textbooks from your library, etc. Please do not copy and paste paragraphs/sentences; try to write paragraphs based on your understanding. Also, you should mention (cite) all the recourses/references that you have used in order to answer this question.

Question 2:

Which of the following pairs of terms can be unified (matched) together? Where relevant, give the variable instantiations that lead to successful unification. (note = shows unification)

healtyFood(X) = healtyFood(bread) healtyFood(bread,X) = healtyFood(Y,salad) healtyFood(bread,X,milk) = healtyFood(Y,salad,X) healtyFood(X) = Y meal(healtyFood(bread),drink(milk)) = meal(X,Y)
meal(healtyFood(bread),drink(milk)) = meal(X, drink(Water)) meal(healtyFood(bread), Y) = meal(X, drink(water)) breakfast(healtyFood(bread),egg,milk)= breakfast(healtyFood(Y),Y, Z)

Question 3:

The Purpose of this question is to write a Prolog Program which describes a directed graph (G), with the following structure (shown below) and allows us to ask some questions about this graph.

A) write all possible node and edge facts that describes the structure of this graph G such as below:

node( a ). % "a" is a node of this graph.

516_Figure.jpg

edge( a, b ). % There is an edge (directed) from node "a" to "b".

B) complete the definition all these rules.

node(X) :- % X is a node in graph G
edge( X, Y) :- % There is an directed edge from X to Y. parent( X, Y) :- % There is a directed edge from X to Y. child(X, Y) :- % Y is parent of X.
path( X, Y) :- % find a directed path from node X to node Y. length_of_path( X, Y):- % Length of a path (directed) from X to Y. connected( X, Y):- % There is a directed path from X to Y, or from Y to X undirected_edge( X, Y) :- /* There is an edge (ignoring the directions) from X to Y or from Y to X */
undirected_path( X, Y) :- /* find a path (ignoring the directions) from node X to node Y. */

C) Create a knowledge base (KB) based on all the facts and rules you have written in parts (A), and (B), and save it in a prolog program file called "my_grapghG.pl", and show a printout of your file here.

D) Run this Prolog program, and write 4 queries about each of those rules that you have created in part B in order to test those rules, and show your queries and their results, and test the correctness of your results. (Note: you should write and test two ground quires (one with positive and one with negative answer) and two non-ground quires for each of the rules that you have created in Part B.)

E) add the following rule to your program, and test it and describe its function?

tpath(Node1,Node2):-edge(Node1, SomeNode), edge(SomeNode,Node2).

Question 4:

Assume we have the following knowledge base in a Prolog program:

man(jack). man(peter). woman(rebeca). woman(julia). woman(maria). hasWand(rebeca). hasWand(maria). hasWand(jack). quidditchPlayer(jack).
quidditchPlayer(rebeca). quidditchPlayer(maria).

quidditchPlayer(peter). playsAirGuitar(julia). playsAirGuitar(adam). playsAirGuitar(rebeca). playsAirGuitar(mary). playsAirGuitar(jack). wizard (jack).
hasBroom(X) :- quidditchPlayer(X).
warlock(X) :- man(X), hasBroom(X), hasWand(X).
witch(X) :- woman(X), hasBroom(X), hasWand(X).
wizard(X):- warlock(X) ; witch(X). % note: semicolon was used here

A) Determine type of each of the following queries (ground/non- ground), and explain what will Prolog respond for each of these queries (write all the steps of unifications and resolutions for each query)?

 -wizard(jack).
 -witch(jack).
 -warlock(jack).
 -witch(maria).
 -warlock(Y).
 -witch(Y).
 -wizard(X).
 -hasBroom(X).
 -playsAirGuitar(Y), witch(Y).

B) Implement your facts & rules as a Prolog program and test all quires in part B.

Question 5:

Write the following rules for lists in a Prolog program and try corresponding queries for each case.

A) my_length(List, Nr). % find the length of a given list.

?- my_length([a,b,[c,d], e, [f, g]],R).
?- my_length( [ [ ], [ ] ], R).
?- my_length( [ [ [ ] ] ], R).
?- my_length([a,b,[c,d],e],4).

B) my_append(L1,L2,New_list). % append two given lists L1, L2, and return a new list.

?- myappend([a,b],[c],R).
?- myappend( _ ,[e,s],[f,o,x,e,s]).
?- myappend(X,[e,s],[f,o,x,e,s]).
?- myappend(X,Y,[a,b,c]).

C) mymember(X, L). % test if X is a member of list L.

?- mymember( a, [ [ ], a, b, c, f]).
?- mymember( X, [ [ ], a, b, c, f]).
?- mymember( [m k], [ [m k], a, b, c, f]).
?- mymember( X, [ [ ], [ [ ] ] , a, b, c, f]).

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M92061040

Have any Question?


Related Questions in Programming Language

Question - create a microsoft word macro using vba visual

Question - Create a Microsoft Word macro using VBA (Visual Basic for Applications). Name the macro "highlight." The macro should highlight every third line of text in a document. (Imagine creating highlighting that will ...

Task arrays and structsoverviewin this task you will

Task: Arrays and Structs Overview In this task you will continue to work on the knight database to help Camelot keep track of all of their knights. We can now add a kingdom struct to help work with and manage all of the ...

Overviewthis tasks provides you an opportunity to get

Overview This tasks provides you an opportunity to get feedback on your Learning Summary Report. The Learning Summary Report outlines how the work you have completed demonstrates that you have met all of the unit's learn ...

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

Question 1 what is hadoop explaining hadoop 2 what is

Question: 1. What is Hadoop (Explaining Hadoop) ? 2. What is HDFS? 3. What is YARN (Yet Another Resource Negotiator)? The response must be typed, single spaced, must be in times new roman font (size 12) and must follow t ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Php amp session managment assignment -this assignment looks

PHP & SESSION MANAGMENT ASSIGNMENT - This assignment looks at using PHP for creating cookies and session management. Class Exercise - Web Project: Member Registration/Login This exercise will cover adding data connectivi ...

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As