64.6k views
5 votes
Help

A 1D signal of up to 20,000 samples is considered.
Using data structures specific to simple chained lists, determine the number of zero passes of the signal. The signal goes through 0 if it changes its sign from one sample to another. 0 is not considered a sign change.
The use of STL is prohibited. Any data structure in the STL or function in the STL used will lead to a 0-point solution.
The use of vectors is prohibited. Any static (T V [N]) or dynamic (T * V = new T [N]) vector structure used will lead to the 0 score of the solution.
Input data:
N number of samples signal samples
Output data:
the number of passes through zero
Example:
Input data:
10
1 3 -2 -6 4 10 1 -5 4 1 Output data:
4
Explanation:
There are 4 sign changes between two consecutive samples:
3 -2 -> sign change (first zero crossing)
-6 4 -> sign change (second zero crossing)
1 -5 -> sign change (third zero crossing)
-5 4 -> sign change (fourth zero crossing)

User Bongeh
by
4.7k points

1 Answer

5 votes

Answer:

er of passes through zero

Example:

Input data:

10

1 3 -2 -6 4 10 1 -5 4 1 Output data:

4

Step-by-step explanation:

There are 4 sign changes between two consecutive samples:

3 -2 -> sign change (first zero crossing)

-6 4 -> sign change (second zero crossing)

Step-by-step explanation:

er of passes through zero

Example:

Input data:

10

1 3 -2 -6 4 10 1 -5 4 1 Output data:

4

Step-by-step explanation:

There are 4 sign changes between two consecutive samples:

3 -2 -> sign change (first zero crossing)

-6 4 -> sign change (second zero crossing)er of passes through zero

Example:

Input data:

10

1 3 -2 -6 4 10 1 -5 4 1 Output data:

4

Step-by-step explanation:

There are 4 sign changes between two consecutive samples:

3 -2 -> sign change (first zero crossing)

-6 4 -> sign change (second zero crossing)er of passes through zero

Example:

Input data:

10

1 3 -2 -6 4 10 1 -5 4 1 Output data:

4

Step-by-step explanation:

There are 4 sign changes between two consecutive samples:

3 -2 -> sign change (first zero crossing)

-6 4 -> sign change (second zero crossing)er of passes through zero

Example:

Input data:

10

1 3 -2 -6 4 10 1 -5 4 1 Output data:

4

Step-by-step explanation:

There are 4 sign changes between two consecutive samples:

3 -2 -> sign change (first zero crossing)

-6 4 -> sign change (second zero crossing)

User Casey Kuball
by
5.2k points