Developer Program Engineer Interview Questions
- -1of 1 vote
AnswersHow can we implement a geo location plugin on any browser
- mohan.reddy63 February 15, 2013 in India| Report Duplicate | Flag | PURGE
Developer Program Engineer Algorithm - 0of 0 votes
AnswersWrite the following function
- Phoenix February 01, 2013 in United States
void drawLine(byte[] img, int len, int wid, int r, int x1, int x2)
such that you draw a line from x1 to x2 at row r.
len is the length and wid is the width of the image/canvas.
Setting a pixel on to draw the line is to set the corresponding bit on the img array
Each byte corresponds to 8 pixels, that is each pixel is a bit in the array| Report Duplicate | Flag | PURGE
Google Developer Program Engineer Coding - 0of 0 votes
AnswersDefining a tree as such that the parent node always contains the sum of children nodes.
- gccruzado January 23, 2013 in Spain
Coul be something like this):
private static int p_get_nodes_value_sum(TreeNodeCollection v_tree_original)
{
//TreeNodeCollection a_child = v_tree_original.ChildNodes;
//TODO:sum the child nodes
int a_suma = 0;
foreach (TreeNode a_child in v_tree_original)
{
if (a_child.ChildNodes.Count > 0)
a_suma += p_get_nodes_value_sum(a_child.ChildNodes);
else
a_suma += Convert.ToInt16(a_child.Value);
}
return a_suma;
}
public class TreeParentSum: TreeNode{
public TreeParentSum(TreeNode v_tree)
{
int a_sum = p_get_nodes_value_sum(v_tree.ChildNodes);
TreeNode a_node = new TreeNode("PARENTNODE", a_sum.ToString());
a_node.ChildNodes.Add(v_tree);
}
}| Report Duplicate | Flag | PURGE
Amazon Developer Program Engineer - 1of 1 vote
Answersthere are two arrays named A and B , both of them with k size, they are sorted in acsending order. could you find k-th smallest combinations of ai, bj -->(ai+bj) . 0<=i,j <k.
- yingsun1228 January 16, 2013 in United States
for example: a = {1, 3, 6} b = {4, 5, 6} then we will get 1 + 4 = 5, 1 + 5 = 6, and 1 + 6 = 7,the result is 5,6,7. does it make you understood? and could anybody do it with less time and space complexity.
Hi guys, thanks for all your suggestions and idea, and finally I get my answer and here are my c++ codes, time complexity is O(k*lgk), and space complexity is O(k):
#include<iostream>
using namespace std;
typedef struct node{
int row;
int col;
int data;
}Node, *PNode;
void swap(PNode &a, PNode &b) {
PNode temp = a;
a = b;
b = temp;
}
void adjust_min_heap(PNode *bin, int i, int k) {
int left = 2 * i + 1;
int right = 2 * i + 2;
int min_index;
if(left < k && bin[left]->data < bin[i]->data) {
min_index = left;
} else {
min_index = i;
}
if(right < k && bin[right]->data < bin[min_index]->data) {
min_index = right;
}
if(min_index != i) {
swap(bin[i], bin[min_index]);
adjust_min_heap(bin, min_index, k);
}
}
void build_min_heap(PNode *bin, int k) {
for(int i = k / 2; i >= 0; i--) {
adjust_min_heap(bin, i, k);
}
}
int *get_k_th_minimum(int *a, int *b, int k) {
PNode *bin = (PNode*)malloc(sizeof(PNode) * k);
int *result = (int*)malloc(sizeof(int) * k);
memset(result, 0, sizeof(int) * k);
int i;
int count = 0;
for(i = 0; i < k; i++) {
bin[i] = (Node*)malloc(sizeof(Node));
bin[i]->row = i;
bin[i]->col = 0;
bin[i]->data = a[i] + b[0];
}
build_min_heap(bin, k);
while(count < k) {
result[count++] = bin[0]->data;
bin[0]->col += 1;
bin[0]->data = a[bin[0]->row] + b[bin[0]->col];
adjust_min_heap(bin, 0, k);
}
for(i = 0; i < k; i++) {
free(bin[i]);
}
free(bin);
return result;
}
void main() {
int a[] = {1, 2, 4};
int b[] = {5, 9, 11};
int k = 3;
int *p = get_k_th_minimum(a, b, k);
for(int i = 0; i < k; i++) {
cout << p[i] << " ";
}
free(p);
getchar();
}| Report Duplicate | Flag | PURGE
Amazon Developer Program Engineer Algorithm - 0of 0 votes
AnswersWAP to compare string without library function in c??
- patilsanketv December 21, 2012 in United States
1)Program should be designed using Pointers
2)Most efficient i.e lesser number of loops or comparisons??| Report Duplicate | Flag | PURGE
Adobe Developer Program Engineer C - 0of 0 votes
AnswersIf we have a very big text file which contains millions of lines of code. On every line there is a one word. We also have a random generator which returns a number between 0 and 1. When we have 1 - this will corresponds to the last line of the file. When we have 0 - to the first one. We want an algorithm which tells as the word (the line) which corresponds to the generated number.
- Lyubomir December 21, 2012 in UK for Love Film| Report Duplicate | Flag | PURGE
Amazon Developer Program Engineer - 0of 0 votes
AnswersWrite an algorithm to check if a tree is binary search tree
- Lyubomir December 21, 2012 in UK for Love Film| Report Duplicate | Flag | PURGE
Amazon Developer Program Engineer Algorithm - 0of 0 votes
AnswersSuppose you have some guests arriving at a party. For each guest, you are given the arrival and departure time. When a guest arrives he is given a wine glass and when he leaves he returns that wine glass (it becomes available to be given to another guest). Find the minimum number of wine glasses needed to serve all the guests. The arrival and departure team can only be between 1800 to 2359 hours.
- yogi.rulzz December 15, 2012 in India| Report Duplicate | Flag | PURGE
Directi Developer Program Engineer Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGiven a binary tree, such that each node contains a number. Find the maximum possible sum in going from one leaf node to another.
- yogi.rulzz December 15, 2012 in India| Report Duplicate | Flag | PURGE
Directi Developer Program Engineer Algorithm - -1of 1 vote
AnswersWhy here output is not Derived Class????
- patilsanketv December 15, 2012 in India
#include <iostream>
using namespace std;
class Base {
public:
char* name;
void display() {
cout << name << endl;
}
};
class Derived: public Base {
public:
char* name;
void display() {
cout << name << ", " << Base::name << endl;
}
};
int main() {
Derived d;
d.name = "Derived Class";
d.Base::name = "Base Class";
Derived* dptr = &d;
// standard conversion from Derived* to Base*
Base* bptr = dptr;
// call Base::display()
bptr->display();
}
// OUTPUT
Base Class| Report Duplicate | Flag | PURGE
Google Developer Program Engineer C++ - 0of 0 votes
Answerssuppose you have a string like-I am a king ,
- mayankstg December 14, 2012 in India
in this string you have to write code to count the total number of words which have only single alphabet .for this string answer sholud be 2.| Report Duplicate | Flag | PURGE
Developer Program Engineer C - 0of 0 votes
AnswersHow to find length of a singly linked list with loops??
- AJ December 13, 2012 in India| Report Duplicate | Flag | PURGE
Amazon Developer Program Engineer Data Structures - 0of 0 votes
Answerswrite code in java /c for expression 5+4*(7-15) or have parenthesis in any order .
- omkumarbitsindri December 13, 2012 in India| Report Duplicate | Flag | PURGE
Amazon Developer Program Engineer - 0of 0 votes
Answershow to find the Third largest Element in an array of integers..? I suggested a logic using a buffer that can hold three elements..But it is of O(3n) complexity..Can someone give a better algorithm ?
- adam November 22, 2012 in India| Report Duplicate | Flag | PURGE
Developer Program Engineer Algorithm - 0of 0 votes
Answerwhy business logic shud not be written in stored procedure even though the database is accessible only to developer and no security issues(according to interviwer)?
- lakshmi.priyanka2007 November 20, 2012 in India| Report Duplicate | Flag | PURGE
Advisory Board Company Developer Program Engineer - 0of 0 votes
Answerswhy page load occurs first in aspx page the master page and then user control ????
- lakshmi.priyanka2007 November 20, 2012 in India| Report Duplicate | Flag | PURGE
Advisory Board Company Developer Program Engineer C# - 0of 0 votes
AnswersSupposed there are a large amount of datas in a large file(larger than 1TB), and much of them are duplicate. For example: {3,94,855,94,5323,94,....}. So, every duplicate one would have a frequency count. Design an algorithm, to find the data with the average frequency, the second highest frequncy?
- huangyingw November 17, 2012 in United States| Report Duplicate | Flag | PURGE
Developer Program Engineer Algorithm - 2of 2 votes
Answerswrite a program to perform divison operation of two numbers without using /, %, and modules operatot
- kiran November 15, 2012 in India| Report Duplicate | Flag | PURGE
ThoughtWorks Developer Program Engineer Java - 0of 0 votes
AnswersTest cases for finger print reader say in a laptop to login. Here you can swipe your finger to have a secured login. e.g. I will swipe my finger and the system will allow me to login.
- arun November 12, 2012 in India| Report Duplicate | Flag | PURGE
Microsoft Developer Program Engineer - -1of 1 vote
Answerswrite the test cases for the Swiping Pad ....??
- arun November 11, 2012 in India| Report Duplicate | Flag | PURGE
Microsoft Developer Program Engineer - 0of 0 votes
AnswersProblem Statement :
- kumar.prince6 November 11, 2012 in India
• Given an 4n X 4n Matrix, where n is a positive integer taken as input. Imagine the matrix consisting of two interleaved coils whose centers are at the centre of the matrix. Implement a java program which takes an integer (n) as input and prints the two coils in two seperate lines.
Please have a look at the below examples to get a sense of what the two coils are :
• Example 1:
• Input: 1
• Matrix:
01 02 03 04
05 06 07 08
09 10 11 12
13 14 15 16
• Output the Two Coils as:
- Coil1: 10 06 02 03 04 08 12 16
- Coil2: 07 11 15 14 13 09 05 01
• Example 2:
• Input: 2
• Matrix:
01 02 03 04 05 06 07 08
09 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24
25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48
49 50 51 52 53 54 55 56
57 58 59 60 61 62 63 64
• Output the Two Coils as:
- Coil1: 36 28 20 21 22 30 38 46 54 63 52 51 50 42 34 26 18 10 02 03 04 05 06 07 08 16 24 32 40 48 56 64
- Coil2: 29 37 45 44 43 35 27 19 11 12 13 14 15 23 31 39 47 55 63 62 61 60 59 58 57 49 41 33 25 17 09 01| Report Duplicate | Flag | PURGE
Yahoo Developer Program Engineer Arrays - 0of 0 votes
AnswersGiven an array of integers and a function Arrange(int position), the function takes the position of an element in the array as input and puts this element at the last position and arranges the array. Now the objective is to sort the array using the Arrange function minimum number of times.
- bhreddy22 November 11, 2012 in - for kindle| Report Duplicate | Flag | PURGE
Amazon Developer Program Engineer - 2of 2 votes
AnswersMcDonald’s sells Chicken McNuggets in packages of 6, 9 or 20 McNuggets. Thus, it is possible, for example, to buy exactly 15 McNuggets (with one package of 6 and a second package of 9), but it is not possible to buy exactly 16 McNuggets, since no non- negative integer combination of 6's, 9's and 20's add up to 16. To determine if it is possible to buy exactly n McNuggets, one has to find non-negative integer values of a, b, and c such that
- nishakothari62 November 03, 2012 in United States
6a+9b+20c=n
Write a function, called McNuggets that takes one argument, n, and returns True if it is possible to buy a combination of 6, 9 and 20 pack units such that the total number of McNuggets equals n, and otherwise returns False. Hint: use a guess and check approach.| Report Duplicate | Flag | PURGE
Facebook Developer Program Engineer Python - 1of 1 vote
AnswersWrite a recursive procedure, called laceStringsRecur(s1, s2), which also laces together two strings. Your procedure should not use any explicit loop mechanism, such as a for or while loop. We have provided a template of the code; your job is to insert a single line of code in each of the indicated places.
- nishakothari62 November 03, 2012 in United Statesdef laceStringsRecur(s1, s2): """ s1 and s2 are strings. Returns a new str with elements of s1 and s2 interlaced, beginning with s1. If strings are not of same length, then the extra elements should appear at the end. """ def helpLaceStrings(s1, s2, out): if s1 == '': #PLACE A LINE OF CODE HERE if s2 == '': #PLACE A LINE OF CODE HERE else: #PLACE A LINE OF CODE HERE return helpLaceStrings(s1, s2, '')
| Report Duplicate | Flag | PURGE
Facebook Developer Program Engineer Python - 0of 0 votes
Answerwhat is x86 and x64 why it is require is there any possibility that it will move forward like x 128
- patilsanketv November 02, 2012 in India| Report Duplicate | Flag | PURGE
Developer Program Engineer - 0of 0 votes
AnswerA tuple can contain a list as an element.
- paramjit1992singh November 02, 2012 in India for python basics
True
or
False| Report Duplicate | Flag | PURGE
Amdocs Developer Program Engineer - 0of 0 votes
AnswersAll O(1) functions take exactly the same amount of time to run.
- paramjit1992singh November 02, 2012 in India for python basics
True
or
False| Report Duplicate | Flag | PURGE
Amdocs Developer Program Engineer - 0of 0 votes
AnswersAfter a mutable object has been created, its identity can change.
- paramjit1992singh November 02, 2012 in India for python basics
True
or
False| Report Duplicate | Flag | PURGE
Amdocs Developer Program Engineer - 0of 0 votes
AnswerAfter a mutable object has been created, its value can change.
- paramjit1992singh November 02, 2012 in India for python basics
True
or
False| Report Duplicate | Flag | PURGE
Amdocs Developer Program Engineer