Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started