arrays - Possible Error with an item on the AP Computer Science Exam -


i took ap computer science exam year, , 1 of questions, number 16 me, appeared not have correct answer (although clear answer ap people had intended correct answer).

the question follows:

which of following cannot implemented on array sorted in descending order more efficiently on unsorted array?

a.) searching element

b.) finding median

c.) finding arithmetic mean

d.) outputting in ascending order

e.) finding largest value

while naively, 1 put answer c, pretty that answer not correct.

take example: have array containing 4503599627370496 double-precision floating point values, 1 of equal 9007199254740993, , rest of .999999. depending on where big value is, naive method of finding mean (iterating through elements, summing them up, divide total count) not yield correct value unless (1) larger elements added sum later (i.e. array sorted), (2) use higher-precision value keep track of sum (i.e. use more resources), or (3) use other method requires more resources.

and if takes more resources, definition less efficient.

also, although rather avoiding point, if don't restrict standard model computing stuff (for instance if allow quantum computers), 1 of them becomes efficient on unsorted array sorted array.

is exam question defective, or did miss here?

in example neither way yield correct answer without using other algorithms large number operations, anyway

when discussing efficiency of algorithms on large amount of data, in case, efficiency typically described asymptotic complexity of algorithm , in case of answer c both algorithms have same asymptotic complexity.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -