Write a function named checkInterval(cir_arr, size, start, interval) which takes a circular array, its size, start index and an interval variable as parameters. The function checks for negative values at each interval from the start index and if a negative value is found it is replaced with its positive value. The function should print the modified array at the end. The element at the start index is considered to be the first element. Note: Assume that 0 represents empty spaces in the array. [You are not allowed to use any additional array/list or any built-in functions except len(), range()].

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

write it in python(hand written) ..

Question | Midterm Question | CSE2 X
E CSE220 Midterm (Fall 2021)
New Tab
x +
docs.google.com/forms/d/e/1FAlpQLSeTEvIB3|2LFPhufH2ftHX40lekwnvgdgyR27zKsQROQaeoCQ/formResponse
Question 1
Write a function named checkInterval(cir_arr, size, start, interval) which takes a circular
array, its size, start index and an interval variable as parameters. The function checks for
negative values at each interval from the start index and if a negative value is found it is replaced
with its positive value. The function should print the modified array at the end. The element at
the start index is considered to be the first element.
Note: Assume that 0 represents empty spaces in the array.
[You are not allowed to use any additional array/list or any built-in functions except len(), range()].
Sample Input
Sample Output
Explanation
cir_arr=[0,0,-2,4,3,-3,- cir_arr=[0,0,-2,4,3,3,-
5,-6,-7,-10,0,0]
Here, index 2 value is considered as the 1st element and
interval is 2. If the 2nd, 4th, 6th and 8th elements are
negative, they will be replaced with it's positive value.
Hence the 4th (-3), 6th (-6) and 8th (-10) values are
replaced with corresponding positive values.
5,6,-7,10,0,0]
Interval=2
Size = 8
Start = 2
cir_arr=[0,10,-20,3,-
30,-5,-23,70,0,0]
cir_arr=[0,10,-20,3,-30,- | Here, index 1 value is considered as the first element
5,23,70,0,0]
and interval is 3. If the 3rd,6th elements are negative,
they will be replaced with it's positive value. Hence the
6th value (-23) is replaced with corresponding positive
value.
Interval=3
Size = 7
Start = 1
Transcribed Image Text:Question | Midterm Question | CSE2 X E CSE220 Midterm (Fall 2021) New Tab x + docs.google.com/forms/d/e/1FAlpQLSeTEvIB3|2LFPhufH2ftHX40lekwnvgdgyR27zKsQROQaeoCQ/formResponse Question 1 Write a function named checkInterval(cir_arr, size, start, interval) which takes a circular array, its size, start index and an interval variable as parameters. The function checks for negative values at each interval from the start index and if a negative value is found it is replaced with its positive value. The function should print the modified array at the end. The element at the start index is considered to be the first element. Note: Assume that 0 represents empty spaces in the array. [You are not allowed to use any additional array/list or any built-in functions except len(), range()]. Sample Input Sample Output Explanation cir_arr=[0,0,-2,4,3,-3,- cir_arr=[0,0,-2,4,3,3,- 5,-6,-7,-10,0,0] Here, index 2 value is considered as the 1st element and interval is 2. If the 2nd, 4th, 6th and 8th elements are negative, they will be replaced with it's positive value. Hence the 4th (-3), 6th (-6) and 8th (-10) values are replaced with corresponding positive values. 5,6,-7,10,0,0] Interval=2 Size = 8 Start = 2 cir_arr=[0,10,-20,3,- 30,-5,-23,70,0,0] cir_arr=[0,10,-20,3,-30,- | Here, index 1 value is considered as the first element 5,23,70,0,0] and interval is 3. If the 3rd,6th elements are negative, they will be replaced with it's positive value. Hence the 6th value (-23) is replaced with corresponding positive value. Interval=3 Size = 7 Start = 1
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY