Survey of Programming Language Concepts, cosc-3308 Lab/Assignment 4 Exercise 1. (Efficient Recurrence Relations Calculation) At slide 54 of Lecture 10, we have seen a concurrent implementation of classical Fibonacci recurrence. This is: fun (Fib X} if X==0 then 0 elseif X==1 then 1 else end end thread (Fib X-1} end + {Fib X-2} By calling Fib for actual parameter value 6, we get the following execution containing several calls of the same actual parameters. Execution of {Fib 6} F5 F4 10/27/2006 F4 F3 F2 F3: F2 F2 F1 F2 F1 F2 F1 CS2104, Lecture 7 (Fib 6) is denoted as F6,... Fork a thread Synchronize on result Running thread 56 For example, F3, that stands for {Fib 3}, is calculated independently three times (although it provides the same value every time). Write an efficient Oz implementation that is doing a function call for a given actual parameter only once. Consider a more general recurrence relation, e.g.: Fo, F1, ..., Fm-1 are known as initial values. Fn = g(Fn-1, ..., Fn-m), for any n ≥ m. For example, Fibonacci recurrence has m=2, g(x, y) = x+y, Fo=F₁=1.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 7SA
icon
Related questions
Question

OZ PROGRAMMING LANGUAGE

Survey of Programming Language Concepts, cosc-3308
Lab/Assignment 4
Exercise 1. (Efficient Recurrence Relations Calculation) At slide 54 of Lecture 10, we have seen a
concurrent implementation of classical Fibonacci recurrence. This is:
fun {Fib X}
if X==0 then 0
elseif X==1 then 1
else
thread {Fib X-1} end + {Fib X-2}
end
end
By calling Fib for actual parameter value 6, we get the following execution containing several calls of
the same actual parameters.
Execution of {Fib 6}
F6
F5
F4
10/27/2006
F4
F3
F3.
F2
F3:
F2
F2
F1
F2
F1
F2
F1
CS2104, Lecture 7
(Fib 6) is denoted as F6,...
Fork a thread
Synchronize on result
Running thread
56
For example, F3, that stands for {Fib 3}, is calculated independently three times (although it provides
the same value every time). Write an efficient Oz implementation that is doing a function call for a given
actual parameter only once.
Consider a more general recurrence relation, e.g.:
Fo, F1, ..., Fm-1 are known as initial values.
Fn = g(Fn-1,. Fn-m), for any n≥m.
For example, Fibonacci recurrence has m=2, g(x, y) = x+y, Fo=F₁=1.
Transcribed Image Text:Survey of Programming Language Concepts, cosc-3308 Lab/Assignment 4 Exercise 1. (Efficient Recurrence Relations Calculation) At slide 54 of Lecture 10, we have seen a concurrent implementation of classical Fibonacci recurrence. This is: fun {Fib X} if X==0 then 0 elseif X==1 then 1 else thread {Fib X-1} end + {Fib X-2} end end By calling Fib for actual parameter value 6, we get the following execution containing several calls of the same actual parameters. Execution of {Fib 6} F6 F5 F4 10/27/2006 F4 F3 F3. F2 F3: F2 F2 F1 F2 F1 F2 F1 CS2104, Lecture 7 (Fib 6) is denoted as F6,... Fork a thread Synchronize on result Running thread 56 For example, F3, that stands for {Fib 3}, is calculated independently three times (although it provides the same value every time). Write an efficient Oz implementation that is doing a function call for a given actual parameter only once. Consider a more general recurrence relation, e.g.: Fo, F1, ..., Fm-1 are known as initial values. Fn = g(Fn-1,. Fn-m), for any n≥m. For example, Fibonacci recurrence has m=2, g(x, y) = x+y, Fo=F₁=1.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Recurrence Relation
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning