Answered step by step
Verified Expert Solution
Question
1 Approved Answer
int[] input_array1 = {200000,221937,243614,264834,285404,305135,323848,341374,357551,372235,385294,396611,406088,413642,419210,422749,424235,423663,421050,416430,409859,401412,391179,379271,365813,350944,334820,317606,299478,280620,261224,241486,221605,201781,182212,163093,144616,126963,110308,94817,80640,67915,56765,47297,39600,33744,29782,27745,27647,29479,33215,38807,46189,55277,65967,78142,91667,106393,122160,138795,156117,173937,192062,210293,228430,246274,263628,280300,296103,310858,324397,336564,347214,356217,363462,368850,372304,373764,373189,370558,365872,359148,350426,339764,327240,312947,296999,279524,260663,240574,219424,197390,174658,151421,127875,104220,80655,57378,34584,12463,-8804,-29044,-48095,-65807,-82045,-96689,-109635,-120797,-130107,-137517,-142998,-146541,-148156,-147874,-145746,-141840,-136246,-129067,-120425,-110457,-99315,-87159,-74166,-60516,-46401,-32014,-17555,-3224,10782,24265,37033,48902,59695,69244,77395,84007,88952,92121,93419,92772,90121,85432,78685,69884,59052,46229,31478,14879,-3470,-23454,-44942,-67791,-91840,-116922,-142856,-169457,-196529,-223877,-251301,-278602,-305581,-332044,-357804,-382680,-406501,-429107,-450350,-470098,-488233,-504655,-519279,-532043,-542900,-551825,-558812,-563875,-567049,-568386,-567960,-565861,-562197,-557093,-550687,-543132,-534593,-525246,-515275,-504870,-494227,-483545,-473025,-462863,-453257,-444397,-436467,-429642,-424087,-419955,-417385,-416501,-417411,-420205,-424956,-431717,-440521,-451384,-464299,-479239,-496161,-514998,-535669,-558071,-582088,-607585,-634417,-662422,-691430,-721259,-751723,-782626,-813770}; In this assignment, you are going to find peaks of a function. Peak of a function is defined as follows: Given
int[] input_array1 = {200000,221937,243614,264834,285404,305135,323848,341374,357551,372235,385294,396611,406088,413642,419210,422749,424235,423663,421050,416430,409859,401412,391179,379271,365813,350944,334820,317606,299478,280620,261224,241486,221605,201781,182212,163093,144616,126963,110308,94817,80640,67915,56765,47297,39600,33744,29782,27745,27647,29479,33215,38807,46189,55277,65967,78142,91667,106393,122160,138795,156117,173937,192062,210293,228430,246274,263628,280300,296103,310858,324397,336564,347214,356217,363462,368850,372304,373764,373189,370558,365872,359148,350426,339764,327240,312947,296999,279524,260663,240574,219424,197390,174658,151421,127875,104220,80655,57378,34584,12463,-8804,-29044,-48095,-65807,-82045,-96689,-109635,-120797,-130107,-137517,-142998,-146541,-148156,-147874,-145746,-141840,-136246,-129067,-120425,-110457,-99315,-87159,-74166,-60516,-46401,-32014,-17555,-3224,10782,24265,37033,48902,59695,69244,77395,84007,88952,92121,93419,92772,90121,85432,78685,69884,59052,46229,31478,14879,-3470,-23454,-44942,-67791,-91840,-116922,-142856,-169457,-196529,-223877,-251301,-278602,-305581,-332044,-357804,-382680,-406501,-429107,-450350,-470098,-488233,-504655,-519279,-532043,-542900,-551825,-558812,-563875,-567049,-568386,-567960,-565861,-562197,-557093,-550687,-543132,-534593,-525246,-515275,-504870,-494227,-483545,-473025,-462863,-453257,-444397,-436467,-429642,-424087,-419955,-417385,-416501,-417411,-420205,-424956,-431717,-440521,-451384,-464299,-479239,-496161,-514998,-535669,-558071,-582088,-607585,-634417,-662422,-691430,-721259,-751723,-782626,-813770};In this assignment, you are going to find peaks of a function. Peak of a function is defined as follows: Given an array of function values, f[0], f[1], ... f[n] if f[ij is greater than its left and right neighbors, i.e., f[i-1] and f[i+1), then f[i] is considered as peak at position i with a value of f[i]. Function values will be given to you as an integer array. You should write a method, named findPeaks, which accepts an input integer array containing function values, and should return an output array which contains peak values. Size of the output array should be equal to the number of peaks in the input function. If there are no peaks, your method should return null. findPeaks method signature should be like this: public static int[] findPeaks (int[] input_array) In Figure 1, a sample function is illustrated with three peak points, denoted by the orange points. The output of your program should be like this: There are 3 peak points. Peak values (y coordinates) are: 34302 29111 13906 If there are no peak points, your program should output: There are no peak points
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