Interview Question for Software Engineer / Developers






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

linear congruential method :

  seed=sys.time();
  X(0)=seed ;

     while( i < n )
      {
         X(i+1)= { aX(i) + c )mod( 2^32-1 );
         i++;
       }

a=multiplier=31425621 ;
GCD( c , 2^32-1) should be 1 .

- JD February 13, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

store random numbers in a table :
Difference generator :

ran[1...100];

i=100;
while( i<100 )
{
ran[i]=( ran[i-37] - ran[i-99] )& ( 1<<32 - 1) ;

}

- JD February 13, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

store random numbers in a table :
Difference generator :

ran[1...100];

i=100;
while( i++<n )
{
ran[i]=( ran[i-37] - ran[i-99] )& ( 1<<32 - 1) ;

}

- Typo ... February 13, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

can u explain one or two iterations of this loop?

- seeker7 June 01, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Here is the code to produce a random number (less than 65535) once every second.

#include <iostream>
#include <time.h>
#include <windows.h>
using namespace std;

#define HASHSIZE 65535

unsigned hash(char *s)
{
	unsigned hashval;
	
	for (hashval = 0; *s != '\0'; s++)
		hashval = *s + 31 * hashval;
	
	return hashval % HASHSIZE;
}

void main()
{
	while(1)
	{
	    char *date;
        time_t timer;
        timer=time(NULL);
        date = asctime(localtime(&timer));
        printf("%d    ", hash(date));
		Sleep(1000);
	}
}

- Helper April 05, 2010 | 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