Bloomberg LP Interview Question for Software Engineer / Developers






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

Is this the same as set and reset bits using a hash table for each state of the machine

- Java Coder November 26, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use a table of function pointers and switch based on the case. make the transition accordingly.

- Ozzy May 04, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

either hash using (current_state+event)=>next state

or

use a hash where key is the current_state and value is the pointer to another 2 dimensional table where event=>next state.

- Anonymous January 12, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

/* State machine implementation
*/

#include <stdio.h>
#include <stdlib.h>

typedef enum State {S1, S2, S3, S4} State;

void f1(State *stateMachine)
{
printf("State: S1\n");
*stateMachine = S2;
}

void f2(State *stateMachine)
{
printf("State: S2\n");
*stateMachine = S3;
}

void f3(State *stateMachine)
{
printf("State: S3\n");
*stateMachine = S4;
}

void f4(State *stateMachine)
{
printf("State: S4\n");
*stateMachine = S1;
}

void (*func[4])(State *) = {f1, f2, f3, f4};

int main()
{
State stateMachine = S1;
int i = 0;
while (i < 100)
{
switch (stateMachine)
{
case S1:
func[S1](&stateMachine);
break;
case S2:
func[S2](&stateMachine);
break;
case S3:
func[S3](&stateMachine);
break;
case S4:
func[S4](&stateMachine);
break;
default:
break;
}
i++;
}
}

- Ying February 19, 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