Interview Question
- 0of 0 votes
AnswerGiven:
- JSDUDE June 07, 2013 in United States
Array of n objects of type Object
///<summary>
/// Given two objects, this function returns a value between 0-100 depending on the relation of the two objects
/// <param1: objToBeCompared>Any object instance which has to be compared to the objReference</param1: objToBeCompared>
/// <param2: objReference>Instance of an object against which the other instance of the Object is to be compared</param2: objReference>
/// <return>A value between 0-100</return>
///</summary>
int Compare(Object objToBeCompared, Object objReference)
Now implement a function:
///<summary>
/// Given an object array of length n, a reference object this function returns the top numberOfMatches matches based on Compare(obj, obj) function's return value
/// Start with the object(s) that return 99 and go up till you find numberOfMatches element
/// The return array doesn't have to be sorted by the Compare value
/// <param1: objects>Array of n Object from which numberOfMatches have to be selected</param1: objects >
/// <param2: ObjectToBeCompared>Object against which the other objects need to be compared to</param2: ObjectToBeCompared>
/// <param3: numberOfMatches>number of matches to be returned</param3: numberOfMatches>
/// <return>Array of numberOfMatches objects</return>
///</summary>
Object[] FindTopMatch(Object[] objects, Object ObjectToBeCompared, int numberOfMatches)| Report Duplicate | Flag | PURGE
Data Structures
It makes awfully hard reading. Can you reformat your problem description, accompanied by an example?
- liu425 June 07, 2013