Friday, August 16, 2013

Amazon–Application Support Engineer Interview

 

Face to Face  - Round 1

1) find the nth node from the last

2) Palindrome in Linked list

3) trouble shooting questions like "server is slow, need to find out the reasons why it is slow and how to make it fast"

Face to Face - Round 2

Many shell scripting questions

some trouble shooting questions

Face to Face - Round 3

Find an element in a pivoted array

troubleshooting questions : Website is slow/down. How to optimize to back end to make it up/fast.

Round 4 & 5 :

All questions related to  project (current employee / college project) , challenges faced in project, how i resolved it , strength, responsibilities etc.,

As it is support engineer role, questions were mainly in trouble shooting and very basic data structures. 

Expected working code &  test cases for all data structure questions.

Wednesday, June 12, 2013

Groupon - Front End Developer - Phone interview Questions

1. Given an array . One element is occurring more than n/2 times. Need to find the element.
O(n) solution is expected.

2. Given an linked list. Need to delete m nodes from nth node.

3. Given an array. Need to find 3 elements. Where A[i] < A[j] < A[k] and i < j < k .
both indices and array elements should satisfy the above condition.
O(n) solution is expected.

Sunday, April 21, 2013

Amazon Support Engineer - Online Test

Total 10 questions (7 MCQ & 3 Programming Questions)

7 MCQ questions includes the following sections:


1. Stacks & Queues
2. Min Heap
3. Linked List (circular Linked List)
4. DBMS Questions (DDL , dML)
5. OS questions (semaphore)
6. Aptitute Question
7. Given a program , what is the output ? (Given, virtual function questions)

3 Programming Questions:


8. Pattern Matching Question
9. Swap adjacent nodes in a linked list.
10. Write a script to print the uniq phone numbers in a folder which contains list of html files.
phone numbers can be in any format (xxxxxxxxxx , xxxxx-xxxxx , xxx-xxx-xxxx)

Online test conducted through Interviewstreet.com

Tuesday, March 26, 2013

Matrix Problems

Some matrix (2D array) problems

1. Given two matrices, perform Matrix Addition

2. Given two matrices, perform Matrix Subtraction

3. Given two matrices, perform Matrix Multiplication

4. Given two matrices, perform Matrix Division

5. Given a matrix , output the mirror of the matrix

6. Given a matrix , output 90 degree left rotation 

7. Given a matrix , output 90 degree right rotation

8. Given a matrix , make diagonal elements zero

9. Given a matrix , make elements zero except diagonal

10. Given a matrix , Make upper triangular matrix zero

11. Given a matrix , Make lower triangular matrix zero

12. Given two matrix , Check whether both are identical

13. Given a matrix , some element mXn is zero. Make the Mth row & Nth column zero.

14. Given a matrix, Adding upper & lower triangular matrix

15. Given a matrix , Swapping upper & lower triangular matrix elements

16. Given a matrix , Make the elements in the border are zero.

17. Given a matrix , Make the corner elements zero.

18. Given a matrix , perform binary search in a matrix

Sunday, March 17, 2013

Quick Sort



#include<stdio.h>
#define MAX 10
void qsort(int A[], int p, int r);
int partition(int A[], int p, int r);

main()
{
int Arr[MAX]={10,4,5,6,2,3,8,1,9,7};
int i;
qsort(Arr,0,MAX);

for(i=0;i<MAX;i++)
printf("%d ",Arr[i]);
}

void qsort(int A[], int p, int r)
{
int q;
if(p<r)
{
q=partition(A,p,r);
qsort(A,p,q-1);
qsort(A,q+1,r);
}
}

int partition(int A[], int p, int r)
{
int i , j , x,tmp;
x=A[r];
j=p;
i=p-1;
while(j<r)
{
if(A[j]<x)
{
i=i+1;
// Exchange A[i] & A[j]
tmp=A[j];
A[j]=A[i];
A[i]=tmp;
}
j++;
}
// Exchange A[i+1] & A[r]
tmp=A[i+1];
A[i+1]=A[r];
A[r]=tmp;

return i+1;
}

Output:
1 2 3 4 5 6 7 8 9 10

Time Complexity:
Best - O( n log n )
Average - O(n log n )
Worst - O( n^2)

Pair Wise Swapping in a Linked List


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

typedef struct list
{
int info;
struct list *next;
}node;

node * head;

void insert(int data);
void display();
void pairwise_swapping(node *ptr);
void swap(int *a, int *b);

void insert(int data)
{
node *ptr , *tmp;
ptr=(node*)malloc(sizeof(node));

if(ptr==NULL)
return;

(*ptr).info=data;
(*ptr).next=NULL;
if(head==NULL)
{
head=ptr;
}
else
{
tmp=head;
while((*tmp).next!=NULL)
tmp=(*tmp).next;

(*tmp).next=ptr;
}
}

void display()
{
node * ptr;

if(head==NULL)
{
printf("list is empty\n");
return;
}

for(ptr=head;ptr!=NULL;ptr=(*ptr).next)
printf("%d ",(*ptr).info);
}

void swap(int *x , int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
}

void pairwise_swapping(node *ptr)
{
node *tmp , *tmp_next;
tmp= ptr;
while (tmp!=NULL && (*tmp).next!=NULL)
{
tmp_next = (*tmp).next;
swap(&(*tmp).info , &(*tmp_next).info);
tmp=(*tmp_next).next;
}
}

main()
{
insert(1);
insert(2);
insert(3);
insert(4);
insert(5);
insert(6);
pairwise_swapping(head);
display();
}

Output:
2 1 4 3 6 5 

Friday, March 15, 2013

Merge Sort

#include<stdio.h>
#define MAX 10

void MergeSort(int Arr[],int low, int high);
void Merge(int Arr[],int low, int mid,int high);

main()
{
    int A[MAX]={9,8,7,6,5,4,3,2,1,10};
    int i;
    MergeSort(A,0,MAX-1);
    for(i=0;i<MAX;i++)
    printf("%d ",A[i]);
}

void MergeSort(int Arr[], int low, int high)
{
    int mid;
    if(low<high)
    {
        mid=(low+high)/2;
        MergeSort(Arr,low,mid);
        MergeSort(Arr,mid+1,high);
        Merge(Arr,low,mid,high);
    }
}

void Merge(int Arr[], int low, int mid, int high)
{
    int l,m,i,k;
    int temp[MAX];

    l=i=low;
    m=mid+1;

    while((l<=mid) && (m<=high))
    {
        if(Arr[l]<=Arr[m])
        {
            temp[i]=Arr[l];
            l++;
        }
        else
        {
            temp[i]=Arr[m];
            m++;
        }
        i++;
    }

    if(l>mid)
    {
        for(k=m;k<=high;k++)
        {
        temp[i]=Arr[k];
        i++;
        }
    }
    else
    {
        for(k=l;k<=mid;k++)
        {
            temp[i]=Arr[k];
            i++;
        }
    }

    for(k=low;k<=high;k++)
    Arr[k]=temp[k];
}

Time Complexity: O(n logn)

Insertion Sort ( reverse)

 

Orginal insertion sort will sort elements from starting of the array. This program will sort the elements from end of the array.

/*Insertion Sort*/

#include<stdio.h>
void insertion(int A[], int n);
void print_array(int A[],int n);
main()
{
    int arr[]={7,6,5,4,2,3,1,8,10,9}; // Input Array

    int size = (int)(sizeof(arr)/sizeof(arr[0])); //Calculate size of array

    int itr ; // Iterator

    insertion(arr,size); // Insertion function

    print_array(arr,size);
}

void print_array(int A[], int n)
{
    int itr;

    // Printing array after sorting
    for(itr=0;itr<n;itr++)
    printf("%d ",A[itr]);
}

void insertion(int A[], int n)
{
    int i , j , key;
    for(j=n-1;j>=0;j--)
    {
        key=A[j];
        i=j+1;
        while((i<=n)&&(A[i]<key))
        {
            A[i-1]=A[i];
            i=i+1;
        }
        A[i-1]=key;
    }
}

Insertion Sort (orginal)

 

/*Insertion Sort*/

#include<stdio.h>
void insertion(int A[], int n);
main()
{
    int arr[]={7,6,5,4,2,3,1,8,10,9}; // Input Array

    int size = (int)(sizeof(arr)/sizeof(arr[0])); //Calculate size of array

    int itr ; // Iterator

    insertion(arr,size); // Insertion function

    // Printing array after sorting
    for(itr=0;itr<size;itr++)
    printf("%d ",arr[itr]);
}

void insertion(int A[], int n)
{
    int i , j , key;
    for(j=1;j<n;j++)
    {
        key=A[j];
        i=j-1;
        while((i>=0)&&(A[i]>key))
        {
            A[i+1]=A[i];
            i=i-1;
        }
        A[i+1]=key;
    }
}

Output:

1 2 3 4 5 6 7 8 9 10

 

Time Complexity: O(n^2)

Tuesday, March 12, 2013

GroupOn Telephonic Interview Questions

 

Questions will be simple. But, working code is MUST. Telephonic Interview over Skype. Writing code is mandatory.

Questions are

1. Program to print the elements in a tree vertically
2. Given an input tree. Program to create a new tree which is the mirror of an input tree.
3. Root to leaf path which is having the given sum
4. Given the output of runlength encoding. Construct the array
5. Array implementation of stack & queues
6. N-stacks implement in an single array.

IBM ISL Interview

 

This interview is for AIX testing position.

Round – 1 was around 2 hours. it includes C, datastructures, OS , multithreading , Linux, Shell.

1. Difference between process & threads
2. How the following system calls will work: fork , read, open , write.
3. Difference between open & fopen.
4. A program that creates a thread.
5. A program with multi thread
6. A program with  the implementation of thread join & synchronization.

OS concepts & linux
7. Fragmentation & types
8. Paging & type  of allocation
9. Scheduling
10. Process memory layout
11. Process states
12. Difference between zombie & orphan process
13. How to find zombie & orphan process in linux using commands.
14. uses of chown , chmod, df , free, top, /proc & some other linux admin commands.
15. question s in sed , awk , grep
16. pipe & examples
17. writing simple shell scripting programs

C programs
18. Program to reverse a string (with & without recursion)
19. Program to reverse a linked list
20. Program to add two numbers (in linked list)
21. program to sort the linked list (own logic)
22. function call by value, call by reference
23. program to swap bytes in an integer
24. questions in padding
25. questions in pointers

26. what is meant by system testing
27. what all testing i have done in previous experience

Round –2 : it was around half an hour. it consists of unix & shell questions.

1. System programming questions like, using a system call in a program
2. writing makefiles
3. shell script program;
Input: hello
Output: h  e  l l  0
4. some other simple shell script programs & some command functionalities in linux

Round – 3 : It was around half an hour. It is a HR + Manager round

1. some questions about testing
2. why leaving the old company
3. why IBM ISL
4. Other general HQ questions

Saturday, February 16, 2013

Process (notes)

 

- a program in execution
- a process contains -> program counter, process stacks & data section.

- process memory layout

Command Line Aruguments

Stack
Stack grows down & Heap grows Up
Heap
Data section (includes BSS)
Text section

    CLA - command line arguments,stored at higher address
    stack - local variables & other info (return info,machine register) stored. In each recursive call, new stack frame is created.
    headp - dynamic memory allocation, shared to all process.
    BSS - Block started by symbol (uninitialized global data)
    data segment - initialized global variables
    text - contains machine instrucitons that cpu executes, shared across various instances of same program. (read only privileges, avoid rewriting)

- process states

process_state_diagram
    new - a process being created
    ready - instructions are executed
    waiting - waiting for some event
    running - waiting to be assigned to processor
    terminate(done) - process has finished

- zombie process – system is referencing the process even if process is  terminated.

- info associated with each process
    Process state
    Program counter
    CPU registers
    CPU scheduling information
    Memory-management information
    Accounting information
    I/O status information

- process queues - job , ready , device
- process scheduler
    - Long term (job) - selects which process to put in ready queue (frequent invoked - very fast)
    - Short term (cpu) - selects which process to execute & allocate CPU (infrequently invoked - very slow)
   
- context switch
    - switching from one process to another, system saves the state of the one process & load the state of new process

- processes can be independent or cooperating
- cooperating process need IPC - shared memory , message passing
    - advantage for co-operating process
        - info sharing
        - computation speedup
        - convenient
        - modularity

    - message passing
        - send /recieve
        - establish connection
        - blocking send / non-blocking
    - shared memory
        - producer consumer problem