Bloomberg LP Interview Question Financial Software Developers

  • bloomberg-lp-interview-questions
    1
    of 1 vote
    2
    Answers

    Q: Do you know what is a Binary tree? How would you go about coding for addition of a new element to Binary tree?
    A: I asked if they want a Binary Tree or a BST? When he said BST I just said we can have a recursive function in which we pass the root of the tree and see if the value to be added is smaller or bigger than the root, and depending on result, we go to left or right of the tree, assuming the left (or right) is not null. If null, just use new to create a memory location, put the value, and use the left reference of the root to link to this new memory. Simple basic stuff.

    - Aditya on April 14, 2013 in United States Report Duplicate | Flag
    Bloomberg LP Financial Software Developer Coding

Country: United States
Interview Type: Phone Interview


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

struct node{
    int info;
    struct node *leftch;
    struct node *rightch;
};


int AppendInBST(struct node **start, int num)
{
    struct node *ptr,*tmp,*par=NULL;
    tmp = (struct node*)malloc(sizeof(struct node));
    tmp->info = num;
    tmp->leftch= NULL;
    tmp->rightch = NULL;

    ptr = *start;
    while(ptr != NULL)
    {
        par = ptr;
        if(num > ptr->info)
            ptr = ptr->rightch;
        else if(num < ptr->info)
            ptr = ptr->leftch;
        else{
            printf("Duplicate Entry\n");
            return 0;
        }
    }
    if(par == NULL)
    {
        *start = tmp;
    }
    else if(par->info > num)
        par->leftch= tmp;
    else if((par->info) < num)
        par->rightch = tmp;
    return 1;
}

- Amit Khatri on August 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

How about this one? Since once mention the Btree I always think of recursive

struct node{
    int data;
    node *leftch;
    node *rightch;
    };
    
    void intoatree(struct node **root, int n){
        node *temp=new node; 
        (*temp).data=n;
        (*temp).leftch=NULL;
        (*temp).rightch=NULL;
        
        node **par;
        
        par=root;
    
        
        if(*root==NULL){
            *root=temp; //insert as the first node
        }
        else if((*(*par)).data==n){
            cout<<"duplicate input"<<endl;
            return;
        }
        else if((*(*par)).data>n){
            *par=(*(*par)).leftch;
            intoatree(par,n);
        }
        else{
            *par=(*(*par)).rightch;
            intoatree(par,n);
        }
        
    }

- code.cracker1991 on December 05, 2013 | Flag Reply


Add a Comment
Name:

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

Books

is a comprehensive book walking you through 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