Cisco Systems Interview Question for Software Engineer / Developers






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

Hash entry from input queue, use %3 to decide which queue it goes into:

int hash = hashFunction(inputQueue[i])

switch(hash%3)
{
  case 0: outputQueue1.enqueue(inputQueue[i]); break;
  case 1: outputQueue2.enqueue(inputQueue[i]); break;
  case 3: outputQueue3.enqueue(inputQueue[i]); break;
}

- DN March 14, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Just a typo in "case 3" it should be "case 2"

- Psycho May 08, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

We can implement this using a queue which implements hash table.
1) We maintain a head an tail pointer.
2) A new entry is inserted into the queue based on hash index.
3) Next pointer of tail is updated to pointer to this location.
i.e. tail->next = newPointer.
4) Tail is updated to point to the new location.
tail = newPointer.

- Abhishek Soni April 21, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

This way searching in the queue takes O(1) time, enqueue takes O(1) time and dequeue takes O(1) time with little overhead of having to store a pointer variable along with the key value.

- Abhishek Soni April 21, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

what are the pointers to?

- Guest1 May 10, 2011 | Flag


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