Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This assignment requires you to write a Bash shell script wrapper.bash and a program in a general programming language, such as C or Python, called

This assignment requires you to write a Bash shell script "wrapper.bash" and a program in a general programming language, such as C or Python, called "fib-pict".

The argument for the fib-pict program should be an integer. Your program should compute fibonacci value for that integer both recursively and iteratively. Your output should be graphviz dot language "call graphs" representing the number of calls in computing each.

Here's example output for fib-pict 10:

digraph recursive { label = "Recursive"; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 4 -> 3; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 4 -> 2; 4 [ label = "fib(4) = fib(3) + fib(2)"; ] ; 5 -> 4; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 5 -> 3; 5 [ label = "fib(5) = fib(4) + fib(3)"; ] ; 6 -> 5; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 4 -> 3; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 4 -> 2; 4 [ label = "fib(4) = fib(3) + fib(2)"; ] ; 6 -> 4; 6 [ label = "fib(6) = fib(5) + fib(4)"; ] ; 7 -> 6; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 4 -> 3; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 4 -> 2; 4 [ label = "fib(4) = fib(3) + fib(2)"; ] ; 5 -> 4; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 5 -> 3; 5 [ label = "fib(5) = fib(4) + fib(3)"; ] ; 7 -> 5; 7 [ label = "fib(7) = fib(6) + fib(5)"; ] ; 8 -> 7; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 4 -> 3; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 4 -> 2; 4 [ label = "fib(4) = fib(3) + fib(2)"; ] ; 5 -> 4; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 5 -> 3; 5 [ label = "fib(5) = fib(4) + fib(3)"; ] ; 6 -> 5; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 4 -> 3; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 4 -> 2; 4 [ label = "fib(4) = fib(3) + fib(2)"; ] ; 6 -> 4; 6 [ label = "fib(6) = fib(5) + fib(4)"; ] ; 8 -> 6; 8 [ label = "fib(8) = fib(7) + fib(6)"; ] ; 9 -> 8; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 4 -> 3; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 4 -> 2; 4 [ label = "fib(4) = fib(3) + fib(2)"; ] ; 5 -> 4; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 5 -> 3; 5 [ label = "fib(5) = fib(4) + fib(3)"; ] ; 6 -> 5; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 4 -> 3; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 4 -> 2; 4 [ label = "fib(4) = fib(3) + fib(2)"; ] ; 6 -> 4; 6 [ label = "fib(6) = fib(5) + fib(4)"; ] ; 7 -> 6; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 4 -> 3; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 4 -> 2; 4 [ label = "fib(4) = fib(3) + fib(2)"; ] ; 5 -> 4; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 5 -> 3; 5 [ label = "fib(5) = fib(4) + fib(3)"; ] ; 7 -> 5; 7 [ label = "fib(7) = fib(6) + fib(5)"; ] ; 9 -> 7; 9 [ label = "fib(9) = fib(8) + fib(7)"; ] ; 10 -> 9; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 4 -> 3; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 4 -> 2; 4 [ label = "fib(4) = fib(3) + fib(2)"; ] ; 5 -> 4; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 5 -> 3; 5 [ label = "fib(5) = fib(4) + fib(3)"; ] ; 6 -> 5; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 4 -> 3; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 4 -> 2; 4 [ label = "fib(4) = fib(3) + fib(2)"; ] ; 6 -> 4; 6 [ label = "fib(6) = fib(5) + fib(4)"; ] ; 7 -> 6; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 4 -> 3; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 4 -> 2; 4 [ label = "fib(4) = fib(3) + fib(2)"; ] ; 5 -> 4; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 5 -> 3; 5 [ label = "fib(5) = fib(4) + fib(3)"; ] ; 7 -> 5; 7 [ label = "fib(7) = fib(6) + fib(5)"; ] ; 8 -> 7; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 4 -> 3; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 4 -> 2; 4 [ label = "fib(4) = fib(3) + fib(2)"; ] ; 5 -> 4; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 5 -> 3; 5 [ label = "fib(5) = fib(4) + fib(3)"; ] ; 6 -> 5; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 1 [ label = "fib(1) = 1"; ] ; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 4 -> 3; 1 [ label = "fib(1) = 1"; ] ; 2 -> 1; 0 [ label = "fib(0) = 0"; ] ; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 4 -> 2; 4 [ label = "fib(4) = fib(3) + fib(2)"; ] ; 6 -> 4; 6 [ label = "fib(6) = fib(5) + fib(4)"; ] ; 8 -> 6; 8 [ label = "fib(8) = fib(7) + fib(6)"; ] ; 10 -> 8; 10 [ label = "fib(10) = fib(9) + fib(8)"; ] ; } digraph nonrecursive { label = "Iterative"; 10 [ label = "fib(10) = 0"; ] ; 10 [ label = "fib(10) = 1"; ] ; 2 -> 1; 2 -> 0; 2 [ label = "fib(2) = fib(1) + fib(0)"; ] ; 3 -> 2; 3 -> 1; 3 [ label = "fib(3) = fib(2) + fib(1)"; ] ; 4 -> 3; 4 -> 2; 4 [ label = "fib(4) = fib(3) + fib(2)"; ] ; 5 -> 4; 5 -> 3; 5 [ label = "fib(5) = fib(4) + fib(3)"; ] ; 6 -> 5; 6 -> 4; 6 [ label = "fib(6) = fib(5) + fib(4)"; ] ; 7 -> 6; 7 -> 5; 7 [ label = "fib(7) = fib(6) + fib(5)"; ] ; 8 -> 7; 8 -> 6; 8 [ label = "fib(8) = fib(7) + fib(6)"; ] ; 9 -> 8; 9 -> 7; 9 [ label = "fib(9) = fib(8) + fib(7)"; ] ; 10 -> 9; 10 -> 8; 10 [ label = "fib(10) = fib(9) + fib(8)"; ] ; } 

Your shell script wrapper.bash should run your program, pipe its output to dot, and then following the advice on this page to create a resulting PDF file with two suitable pages.

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

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

What is cost plus pricing ?

Answered: 1 week ago

Question

1. What are the types of wastes that reach water bodies ?

Answered: 1 week ago

Question

Which type of soil has more ability to absorb water?

Answered: 1 week ago