For the following loops, state whether any dependence exists, and if so, specify the type of dependence, and whether the dependence has a fixed distance. If the distance between every pair of loop iterations that have a dependence relationship is fixed, we say the dependence has a fixed distance. For instance, the loop for i = 1, 100 a(i) = a(i+1) has a fixed distance of 1. 1. for i= 1, 100 a(i+3) - a(i) + 1 (a) dependence? YES with type – NO (b) fixed dependence distance? YES with distance = NO - 2. for i= 3, 100 a(i) = a(2i-5) + 1 (a) dependence? YES with type NO (b) fixed dependence distance? YES with distance = NO 3. for i= 1, 100 a(i) = a(i-1) + 1 (a) dependence? YES with type _ NO (b) fixed dependence distance? YES with distance = NO 4. for i= 1, 100 a(2i) = a(2i+4) + 1 (a) dependence? YES with type NO (b) fixed dependence distance? YES with distance NO 5. for i= 1, 100 a(2i) = a(2i-1) + 1 (a) dependence? YES with type – NO (b) fixed dependence distance? YES with distance = NO 6. for i- 1, 10 a(i) = a(25 - i) + 1 (a) dependence? YES with type NO (b) fixed dependence distance? YES with distance NO

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%
For the following loops, state whether any dependence exists, and if so, specify the type of dependence,
and whether the dependence has a fixed distance. If the distance between every pair of loop iterations that
have a dependence relationship is fixed, we say the dependence has a fixed distance. For instance, the loop
for i = 1, 100 a(i) = a(i+1) has a fixed distance of 1.
for i= 1, 100
a(i+3) = a(i) + 1
1.
(a) dependence?
YES with type –
NO
(b) fixed dependence distance?
YES with distance =
NO
2.
for i= 3, 100
a(i) = a(2i-5) + 1
(a) dependence?
YES with type
NO
(b) fixed dependence distance?
YES with distance =
NO
3.
for i= 1, 100
a(i) = a(i-1) + 1
(a) dependence?
YES with type -
NO
(b) fixed dependence distance?
YES with distance =
NO
4.
for i= 1, 100
a(2i) = a(2i+4) + 1
(a) dependence?
YES with type –
NO
(b) fixed dependence distance?
YES with distance =
NO
for i= 1, 100
a (2i) = a(2i-1) + 1
5.
(a) dependence?
YES with type –
NO
(b) fixed dependence distance?
YES with distance =
NO
for i= 1, 10
a(i) = a(25 - i) + 1
6.
(a) dependence?
YES with type
NO
(b) fixed dependence distance?
YES with distance =
NO
Transcribed Image Text:For the following loops, state whether any dependence exists, and if so, specify the type of dependence, and whether the dependence has a fixed distance. If the distance between every pair of loop iterations that have a dependence relationship is fixed, we say the dependence has a fixed distance. For instance, the loop for i = 1, 100 a(i) = a(i+1) has a fixed distance of 1. for i= 1, 100 a(i+3) = a(i) + 1 1. (a) dependence? YES with type – NO (b) fixed dependence distance? YES with distance = NO 2. for i= 3, 100 a(i) = a(2i-5) + 1 (a) dependence? YES with type NO (b) fixed dependence distance? YES with distance = NO 3. for i= 1, 100 a(i) = a(i-1) + 1 (a) dependence? YES with type - NO (b) fixed dependence distance? YES with distance = NO 4. for i= 1, 100 a(2i) = a(2i+4) + 1 (a) dependence? YES with type – NO (b) fixed dependence distance? YES with distance = NO for i= 1, 100 a (2i) = a(2i-1) + 1 5. (a) dependence? YES with type – NO (b) fixed dependence distance? YES with distance = NO for i= 1, 10 a(i) = a(25 - i) + 1 6. (a) dependence? YES with type NO (b) fixed dependence distance? YES with distance = NO
Expert Solution
Step 1

The dependence occurs when same element is accessed in any other iteration.

1. for i=1,100

a(i+3)=a(i)+1

in the given loop, the loop starts from writing a(4), The same element will be accessed to write a(7),

a(7)=a(4)+1

(a) There is dependence .  The dependence type is inter dependence (dependence between different loop iterations) . The direction is read after write . a(4) is written first, then it is read.

(b) Fixed dependence distance is -3.

 

2. for i=3,100

a(i)=a(2i-5)+1

Here the loop starts by writing a(3), the same element will be accessed to write a(4)

a(4)=a(8-3)+1

      =a(3)+1

(a) There is dependence .  The dependence type is inter dependence . The direction is read after write . a(3) is written first, then it is read.

(b) No fixed length dependence

 

3. for i=1,100

a(i)=a(i-1)+1

loop starts by writing a(1) and then reads it to write a(2).

(a) There is dependence .  The dependence type is inter dependence . The direction is read after write . a(1) is written first, then it is read.

(b) Yes, fixed length=-1

 

 

 

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Data Recovery Approaches
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education