Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You have a stream of data represented by a series of non- negative integers. The risk value of the data is determined by the number

You have a stream of data represented by a series of non- negative integers. The risk value of the data is determined by the number of adjacent indexes where the numbers have different parity (i.e. different remainders when divided by 2). Additionally, some data is lost and indicated by '0' values. You can replace the '0' values with any positive integer.

You are also given an array called Arr, which represents the stream of data and is a size of N.

Calculate the minimum risk value achievable by substituting '0's with positive integers.

Function description

Complete the function Parity(). This function takes the following 2 parameters and returns the required answer.

N: Represents the size of the stream of data

Arr. Represents the stream of data

Input format for custom testing

Note: Use this input format if you are testing against custom input or writing code in a language where we don't provide boilerplate code

The first line contains an integer N which represents the size of the stream of data.

The second line contains N space- separated integers which represent the stream of data

Output format

45

Print the minimum risk value possible after changing '0's with any positive integer.

Constraints

1 N 100

0

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

Visual Basic 4 Ole Database And Controls Superbible

Authors: Michael Hatmaker, C. Woody Butler, Ibrahim Malluf, Bill Potter

1st Edition

1571690077, 978-1571690074

More Books

Students also viewed these Databases questions