Wireless Generation Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

We'll do this the simple way. We can define a Hashset class in C++.

class Hashset
{
  int student_id;
  public:
  int getMarks()
  {
    /*the Hash function code here takes student ID as input and returns the marks.
      H(student_id)=student_marks */

    return marks;
  }
};

GLOBAL Hashset Stduents[];

int GetTopper()
{
   Hashset H = new Hashset();
   int max=0;

   for(i=0;i<Students.length;i++)
   {
      if (Students[i].marks > max)
      max= Students[i].marks;
   }
  return max;
}


FUNCTION GetPercentileHash(Hashset x)
{
   int TOPPER =  GetTopper();
   
   return (x.GetMarks()/TOPPER) * 100;
   //will return the percentile
}

- xedgenes April 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Actually I don't think this answers the question at all for a few reasons. The question is to take an existing HashMap object that contains ID keys and Score values, and return a new HashMap with ID keys and Percentile values. Also percentile is defined as L/N where L is the # of scores below you, and N is the total # of scores.

Here's a possible algorithm to solve this:

1. Define a new class called StudentScore which contains a student id and a student score.
2. Read all entries of the hashmap into a StudentScore array that is the same size as the # of students in the hashmap
3. Sort the array by student scores (using quicksort this is n*log n average case and n^2 worst case).
4. Create a new hashmap to store percentiles
5. Iterate student score array from 0 -> length-1. Add student entries to new hashmap. Your key is the student id, and the value is i/(array.Length -1).

- HelloWorld April 07, 2011 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More