Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. True / False Imperative programming paradigm systematically decompose function into more primitive functions, stopping when all functions map to program statements. 2. True /

1. True / False Imperative programming paradigm systematically decompose function into more primitive functions, stopping when all functions map to program statements. 2. True / False The assignment statement is fundamental to Imperative Programming. 3. True / False In terms of imperative programming a language is Turing complete if, in addition to a mechanism for an assignment statement, it has control structures for sequence and conditional, and a mechanism for looping. 4. True / False A programming language is Turing complete if its programs are capable of computing any computable function. 5. True / False Data Abstract extends procedural abstraction to include data. It extends imperative notion of type by providing encapsulation of data/functions and a separation of interface from implementation. 6. True / False Pure functional programming is state-free and has no assignment statements but is still Turning complete. 7. True / False In Imperative and Object Oriented Programming, functions have lower status than variables but in functional programming, functions have same status as variables. 8. True / False Object Oriented Programming uses object decomposition, rather than functional decomposition (as used in Imperative paradigms). 9. True / False A language is Object-Oriented if it supports encapsulation with information hiding, virtual methods, and inheritance. 10. True / False In Object Oriented languages Polymorphism refers to the late binding of a call to one of several different implementations of a method in an inheritance hierarchy. 11. True / False In Object Oriented languages, Generics and Templates defines a family of classes parameterized by one or more types. 12. True / False Prolog works backwards starting from the query. 13. True / False Conjunction is denoted by a comma in Prolog. 14. True / False Prolog is nondeterministic and if asked will give you all possible answers. 15. True / False Prolog is used satisfactorily to prove theorems. 16. True / False Scheme is good at symbolic data processing, mathematical logic, game play and other fields of artificial intelligence. 17. True / False Cambridge prefix notation is used for all Scheme expressions 18. True / False In Logic programming the program declares the goals of the computation, not the method for achieving them. 19. True / False In Functional programming there is no notion of state and therefore no need for an assignment statement. 20. True / False In Functional programming there is no way to increment or decrement the value of a variable so the effect of a loop can only be achieved via recursion. 21. True / False With polymorphism the same call could evokes a different method depending on the type of the reference. 22. True / False An abstract class is one that is a method that contains no code beyond its signature. 23. True / False In OO an interface encapsulates collection of constants, abstract method signatures and may include variables, constructors, or non-abstract methods 24. True / False Reference semantics: Expression is evaluated to a value, which is copied to the target; used by object-oriented languages. 25. True / False Copy semantics: Expression is evaluated to an object, whose pointer is copied to the target; used by imperative languages 26. True / False Encapsulation is a mechanism which allows logically related constants, types, variables, methods, each to be its own separate entities. 27. True / False The order of the rules in a Prolog program is a factor in determining the number of solutions in the search space. 28. Declarative programming emphasizes: A. why not over why B. what over how C. what over where D. how over what 29. Object Oriented programming emphasizes: A. why not then why B. what then how C. what then where D. how then what 30. The quintessential programming language in the logic programming paradigm is: A. Scheme; B. Haskell; C. Gdel; D. Prolog; E. C. F. Java 31. The following programming languages are Turing complete. A. Java B. C C. Scheme D. Prolog E. all F. none

SCHEME - Give a short answer for each of the following questions. 1. If we evaluate the following expressions, as Scheme would, what would be the result? (define x 3) (define y 10) a. (list x y) b. (list 'x 'y) 2. Define a function to compute the cube of a number 3. Define a function that takes a list of numbers and returns a list of their square roots. Thus (sqrts 1.0 2.0 4.0) should return (1.0 1.41421 2.0). (Hint: the answer to the question about how to calculate a square root is a built-in function called sqrt and yes, you can use map ). 4. Finish writing the program, called 'got_milk', that is bellow. It checks a list for the word "milk". It should return true (#t) or false (#f). We can assume the list is of atoms (that it has no sub-lists). You might want to use the build-in function eq? to test for equality e.g. (eq? 'a (car '(a b))) => #t (define (got_milk alist) (cond ((null? alist) #f) )) > (got_milk '("bread", "cheese", "tomates", "milk")) =>#t 5. Write a function, called 'sum' , that sums all the elements of a list. Extra Credit, write this function so that it sums up all the elements of a list including all sub-lists.

6. Consider the following Scheme function and then determine: (define foo (list 1 2 5 6 9)) (define bar (list 0 2 5 7 9)) (define (mystery list1 list2) (cond ( (null? list1) '() ) ( (member (car list1) list2 ) (cons (car list1) (mystery (cdr list1) list2))) (else (mystery (cdr list1) list2)) )) What would be the result (what would be the output) if we ran the command below? >(mystery foo bar) =>

PROLOG - Give a short answer for each of the following questions. 1. What would be the output from ?- append([a,b,c],[one,two,three], Result). 2. Given: mother(mary, sue). mother(mary, bill). mother(sue, nancy). mother(sue, jeff). mother(jane, ron). father(john, sue). father(john, bill). father(bob, nancy). father(bob, jeff). father(bill, ron). parent(A,B) :- father(A,B). parent(A,B) :- mother(A,B). grandparent(C,D) :- parent(C,E), parent(E,D). sibling(X,Y) :- parent(P,X), parent(P,Y), X\=Y. a. Define a new relation 'cousin' that defines the relationship between any two people whose parents are siblings. b. Write a query for this expanded program that will identify all people who are cousins. For example, the cousins of Ron would be ?- (cousin ron, Who). 3. If we had the following: has_flu(rebecca). has_flu(john). has_flu(X):- kisses(X,Y),has_flu(Y). kisses(janet,john). What would the following return? ?- has_flu(janet). 4. If we had a one-way road links 6 towns. (i.e. town1----->-----town2---->----town3---->----town4--->----town5---->---town6 ) Finish writing the program that can work out if you can travel on that road and can_get from A to B. connected(town1,town2). connected(town2,town3). connected(town3,town4). connected(town4,town5). connected(town5,town6). can_get(X,Y) :- connected(X,Y). can_get(X,Y) :- connected(X,Z), can_get( _____ , _____ ). 5. Suppose that we are working with the following (yes, the names are from the movie Pulp Fiction): loves(vincent, mia). loves(marcellus, mia). loves(mia, marcellus). loves(pumpkin, huney_bunny). loves(huney_bunny, pumpkin). jealous(A,B):- loves(A,C), loves(B,C), A \= B. a. Now we pose we have the query ?- jealous(X,Y). What would we get back if we asked for all solutions? Show what would be the output. b. Would it make a difference if we removed the last A\=B ? If yes how?

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

Business Process Driven Database Design With Oracle PL SQL

Authors: Rajeev Kaula

1st Edition

1795532386, 978-1795532389

More Books

Students also viewed these Databases questions