MicroStrategy Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




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

use stacks

- bbarodia January 12, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Thanks, but the interviewer did ask for code. So can you specify what are you going to put in the stack?
Also, it seems Command Pattern is a better answer. But I am not sure how to implement it.

- oucfei January 12, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

May be like this ,

interface Action { 
 execute() ;
 Action getInverseAction() ;
}

class DrawLineAction implements Action { 
   DrawLineAction (Point p1, Point p2) {
   }

    public execute() {
    // Logic to draw a line 
   }
  
   public getInverseAction() {
        return new EraseLineAction(p1,p2) ;
   }

} 

class EraseLineAction implements Action {
EraseLineAction (Point p1, Point p2) {
}

public execute() {
   //Logic to erase a line
}

public Action getInverseAction() {
    return new DrawLineAction(p1,p2);
}

-------------------------

Once you have this setup , you can maintain a linked list . And have the index as current Action . For every line you draw you will add the Action to the list

List<Action>  m_actions = new ... 
Action m_currentAction ; 

drawObject(...)  {
    for each point { 
         Point p1 , Point p2 ;
        Action act = new DrawLineActin(p1,p2) ;
        m_actions.append(act);
       act.execute() ;
       m_currentAction = act ;
    }
}

undo() {
Action act = m_currentAction.getInverseAction();
action.execute();
m_currentAction = (Previous Action in m_actions() )
}

redo() {
   action =  (next Action of m_currentAction in m_actions) 
   action.execute() ;
   m_currentAction = action ;
}

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

Store states of the progress in a stack.

- jasmeet@iastate.edu January 14, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Look for the Memento pattern for the undo-redo operations.

- hero January 19, 2013 | 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