Question: (4). // a[ ] is an array of size n X = a[0]; y = 1; Z = 1; for i = m 1

(4). // a[ ] is an array of size n X =a[0]; y = 1; Z = 1; for i = m 1to n-1 if (a[i] != (a[i-1])){ } else { z = 1;

(4). // a[ ] is an array of size n X = a[0]; y = 1; Z = 1; for i = m 1 to n-1 if (a[i] != (a[i-1])){ } else { z = 1; Z = z + 1; if (z > y) { y = Z; x = a[i]; } } return x; } (5). // a[ ] is an array of size n int x =a[0]; int y = 1; for i = 1 to n-1 { if (a[i] == a[i-y]) { x = a[i]; y = y + 1; } } return x; Express the running time of each code segment as a function of n using the big-Oh notation. You need to justify your answers. If you show only answers without justification, no points will be given even though your answers are correct.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!