Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please fully answer these two questions: 7. Suppose that the equal_lists functio

ID: 3746818 • Letter: P

Question

Please fully answer these two questions:
7. Suppose that the equal_lists function (page 49 of Sebesta) is called with the lists ((A) B (C ((D)) E)) and ((A) B (C ((D)) E)) as the arguments. How many calls of equal_lists will be performed altogether, including the original call and all recursive calls?
8. The following program is written in Dart, the new programming language from Google:
import 'dart:math' as math; class Point { num x, y; Point(this.x, this.y); Point scale(factor) => new Point(x * factor, y * factor); num distance() => math.sqrt(x * x + y * y); } void main() { var p = new Point(2, 3).scale(10); print(p.distance()); }
(a) Explain the meaning of the word num. (b) Translate the program into Java, making as few changes as possible. Use int as the type of x, y, and factor; use double as the return type of distance. Your answer should be a complete Java program that produces the same output as the original Dart program. 7. Suppose that the equal_lists function (page 49 of Sebesta) is called with the lists ((A) B (C ((D)) E)) and ((A) B (C ((D)) E)) as the arguments. How many calls of equal_lists will be performed altogether, including the original call and all recursive calls?
8. The following program is written in Dart, the new programming language from Google:
import 'dart:math' as math; class Point { num x, y; Point(this.x, this.y); Point scale(factor) => new Point(x * factor, y * factor); num distance() => math.sqrt(x * x + y * y); } void main() { var p = new Point(2, 3).scale(10); print(p.distance()); }
(a) Explain the meaning of the word num. (b) Translate the program into Java, making as few changes as possible. Use int as the type of x, y, and factor; use double as the return type of distance. Your answer should be a complete Java program that produces the same output as the original Dart program.
7. Suppose that the equal_lists function (page 49 of Sebesta) is called with the lists ((A) ( ((D)) E) ) and ( (A) B (C ((D)) E)) as the arguments. How many calls of equal_lists will be performed altogether, including the original call and all recursive calls? 8. The following program is written in Dart, the new programming language from Google: import 'dart:math' as math; class Point ( num x, y; Point (this.x, this.y); Point scale (factor)>new Point (x *factor, y * factor); num distance() math.sqrt (x *x+ y * y); void main() ( var p -new Point (2, 3).scale (10); print (p.distance)) (a) Explain the meaning of the word num. (b) Translate the program into Java, making as few changes as possible. Use int as the e of x, y, and factor; use double as the return type of distance. Your answer should be a complete Java program that produces the same output as the original Dart program

Explanation / Answer

7)

There are totally 5 calls for the equal_lists function, among which 1 is original call and others 4 are recursive calls

1 call is original

then a call will be done for equal_lists(A,A) and since it is true another call is done

equal_lists(nextelement(A),nextelement(A))

now again equal_lists(B,B) calls

equal_lists(B,B) and since it is true it makes another call

  equal_lists(nextelement(B),nextelement(B))

and again equal_lists(C,D) calls

equal_lists(C,D) since it is false no more calls will be done and it returns NIL

simply

One for Main List ((A (B)) (C))

2nd for (A (B))

3rd for (B)

4rth for (C)

please upvote. thank you