Problem Given a numeric array A and a numeric value n, find the linear index AND the value of A’s…

Problem Given a numeric array A and a numeric value n, find the linear index AND the value of A’s element whose distance from n is nearest among all the elements (recall that we can linearly index a 2D array just like a 1D column array). A distance between two numbers, say x and y, are measured as the absolute difference between the two X – y. Note that the qualifying element may not be unique. In such a case, we want to return the index of the first occuring nearest element, that is, the smallest index among the nearest elements. Hint If you coded if-statement correctly, then you don’t really need to worry about this at all. Examples Consider the 3×3 array [11, 13, 18; 65, 25, 31; 49. 65. 37). • n = 60: The second element (65) is the nearest from n with the distance of 160 – 65| = 5. The 6th element (65) is also the nearest but it’s not the first occuring. • n = 25. The fifth element (25) is the nearest from n with the distance of 25 – 25] = 0. . n = 12: The first element (11) is the nearest from n with the distance of 12 – 111 = 1. The fourth element (13) is also the nearest from n (12 – 131 = 1) but it’s not the first occuring. Task Write a function nearestElement that takes two input arguments (in this order: an array to be searched and the search key) and returns two output values in this order an index of the first occurring nearest element of the input array and its value) Use of the built-in function “min” or other similar built-in functions will result in not passing the automatic assessment. Hints . Don’t be fooled by the example 2D array. This problem does not need a nested loop as long as you treat the 2D array like a 10 array with linear indexing. For example, given a 2D array M, what does M give you? – Take time to understand the problem and analyze it. If you take the element-wise difference between A and n, the resulting array should only consists of distances. What would you call the elements of the distance array that corresponds to the nearest elements in A? . Remember, “The server timed out while running… most likely means that you have an infinite loop in your code.

Calculate the price
Make an order in advance and get the best price
Pages (550 words)
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
How it works
Receive a 100% original paper that will pass Turnitin from a top essay writing service
step 1
Upload your instructions
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
Pro service tips
How to get the most out of your experience with Online Academic Experts
One writer throughout the entire course
If you like the writer, you can hire them again. Just copy & paste their ID on the order form ("Preferred Writer's ID" field). This way, your vocabulary will be uniform, and the writer will be aware of your needs.
The same paper from different writers
You can order essay or any other work from two different writers to choose the best one or give another version to a friend. This can be done through the add-on "Same paper from another writer."
Copy of sources used by the writer
Our college essay writers work with ScienceDirect and other databases. They can send you articles or materials used in PDF or through screenshots. Just tick the "Copy of sources" field on the order form.
See why 20k+ students have chosen us as their sole writing assistance provider
Check out the latest reviews and opinions submitted by real customers worldwide and make an informed decision.
Impressive writing
Customer 452547, February 6th, 2021
Love this writer!!! Great work
Customer 452597, April 5th, 2021
thank you!
Customer 452947, October 21st, 2021
Very fast response and did a excellent job.
Customer 453201, May 31st, 2022
Business Studies
Thank you so much! I had to take my dog to the ER and had no time for the assignment. I really appreciate your help! I can't thank you enough! I really appreciate the work and integrity put into it. Thank you for taking it seriously and not bullshiting the paper.
Customer 452815, July 26th, 2021
Thank you so much for your help! :)
Customer 453167, May 11th, 2022
Thank you
Customer 453087, March 5th, 2022
I just need some minor alterations. Thanks.
Customer 452547, February 10th, 2021
Looks great and appreciate the help.
Customer 452675, April 26th, 2021
Business Studies
Thank you very much for a good job done and a quick turn around time.
Customer 452615, March 31st, 2021
Health Care
The writer did not follow my choice of topic (Food/Water Insecurity, Hunger, & Poverty), the paper was instead written about Climate Change in Africa. However, the paper was still great and informative. Thank you!
Customer 452777, January 28th, 2022
I am beyond eager to write this review for this writer. I received a grade of "Mastered"upon first submission on this assignment. I will shout to the rooftops ENCOURAGING you to hire him. I have used other writers but NONE have delivered such awesome work as this writer and NONE of their prices can compare to his. He does not try to "break the bank" and he works hard; it shows in the final paper and the grade. He is simply,THE BEST HERE!!
Customer 452995, November 16th, 2021
Customer reviews in total
Current satisfaction rate
3 pages
Average paper length
Customers referred by a friend
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat
Live ChatWhatsApp