EMC Interview Question Software Engineer / Developers

  • emc-interview-questions
    0
    of 0 votes
    9
    Answers

    Given a sorted array with repeated nos e.g

    1,2,2,7,7,7,7,9,9...

    Find first occurence of any given value.

    - newGeek on June 03, 2008 Report Duplicate | Flag
    EMC Software Engineer / Developer Algorithm



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

Given: array is of integers.

- newGeek on June 03, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This has been already discussed , we can do it with the help of Hash Map...with a complexity of o(1)

- Anonymous on June 09, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Hi,
can you please share link to the solution. I could not figure out o(1) solution. Are you sure about that? Isnt it o(log n)?

- Algos_are_fun on June 17, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

move in the step of power of ...
2,4,8, 16, 32,.. --> 2^i
moment u find a number less then or equal the required number stop.
if(num <= arr[2^i])
break
Apply binary search between the current index 2^i and 2^(i-1)

solution O(log n)

- Anonymous on August 21, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

but i think he wants the first occurrence of the number.
so i think we need to apply binary search to find the number and then move left or right to find the first occurrence.

- Guest on May 01, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

moron piece of shit solution

- Anonymous on September 20, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

yeah ...the above solution is much better than hashing as hashing takes a preprocessing time of O(n) and space complexity of O(n) .

- Anonymous on August 30, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Why 2^i ? please explain.

- Anonymous on November 26, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

We can directly apply binary search on this array because it is sorted.
Suppose an sorted array A[1..n].
In every step of binary search, we don't return if A[mid]==key.
Instead, we use this conditional statement:
if (key<=A[mid]) high=mid-1
else low=mid+1.
At last, we return value of low when low>high;
Time complexity is O(logN);

- Hong Sun on September 06, 2011 | Flag Reply


Add a Comment
Name:

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

Books

is a comprehensive book walking you through every aspect of getting a job at a top tech company, while focuses on software engineering interviews.

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