Software Developer Interview Questions
- 0of 2 votes
Answers#include <stdio.h>
- aristainterview October 19, 2016 in United States
int main( int argc, char* argv[] ){
char* string1 = "string";
char string2[] = "string";
}
#include <stdio.h>
/* Describe the code below */
struct s {
double f;
int i;
char c[3];
void *p;
int x[0];
};
int main( int argc, char ** argv ) {
struct s temp;
printf("The size of the struct is %d \n", sizeof(temp));
printf("The size of the double is %d \n", sizeof(temp.f));
printf("The size of a character array is %d \n", sizeof(temp.c));
printf("The size of a void pointer is %d \n", sizeof(temp.p));
printf("The size of a integer array is %d \n", sizeof(temp.x));
printf("The size of a integer is %d \n", sizeof(temp.i));
return 0;
}
/* What's wrong with this program? */
#include <stdio.h>
int
main( int argc, char const * argv ) {
for( int i = 0; i < argc; ++i ) {
printf("%s\n", argv[i] );
}
}
/* Can you tell me what the program will do when I run it like this:
* <prog> 1 2 3 4
*/
/*
Describe what two of these do, and how they're useful for debugging:
perf
oprofile
gprof
strace
gcov
printf
syslog
*/
#include <stdlib.h>
#include <stdio.h>
class C {
public:
void func() {
printf("func called\n");
}
virtual void virtualFunc() {
printf("virtual func called\n");
}
};
int main (int argc, char ** argv) {
C * obj = NULL;
/* What does the following print? */
obj->func();
/* What does the following print? */
obj->virtualFunc();
/* What's the difference? */
}
/* What's polymorphism? */
/* What's abstraction? */
#include <cstdlib>
#include <ctime>
#include <sys/time.h>
#include <iostream>
#include <cstdio>
using namespace std;
/* What do this do? */
int a( unsigned int i ) {
int c = 0;
while( i ) {
if( i & 1 ) { c++; }
i >>= 1;
}
return c;
}
/* What does this one do? */
int b( unsigned int i ) {
static unsigned char n[] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4};
int c = 0;
while( i ) {
c+=n[i&15];
i >>= 4;
}
return c;
}
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <string>
using namespace std;
std::string::iterator contains(char c, string s1) {
std::string::iterator i = std::find(s1.begin(), s1.end(), c);
if (i != s1.end())
return i;
else
return null;
}
int anagram ( const string s1, const string s2) {
for( int i = 0; i < s1.size(); i++) {
std::string::iterator i = ,s2.find(s1[i]);
if (i != s2.end())
s2.erase(i);
else
return false;
}
return s2.size()==0;
}
int main (int argc, char *argv[] ){
printf("%d",anagram(argv[1],argv[2]));
}
F
/ \
/ \
D M
/ \ / \
B E L P
/ \ / \
A C H S
/ \
R T
In-order traversal:
A->B->C->D->E->F->H->L->M-P->R->S->T
Requirement:
Write a function (pseudo-code is fine) that given a starting node, advances to the next in-order node in a binary tree.
Please also provide a data-structure definition of a node.
struct node
{
};
node *next_node(node *current)
{
node *next;
/* current - any node in the tree, advance to next node */
return next;
}
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
/*
vercmp compares two software version strings and returns the following:
if v1 > v2 : return 1
if v1 == v2 : return 0
if v1 < v2 : return -1
input strings are in the form "1.0.3", "2.10", "6.0.0.3", etc...
"1.0" is considered bigger than "1" and "1.10" is greater than "1.2"
*/
int vercmp( char * v1, char * v2 ) {
}
int main() {
assert( vercmp( "1.1", "1.0" ) == 1 );
assert( vercmp( "1.0", "1.1" ) == -1 );
assert( vercmp( "1.0", "1.0" ) == 0 );
assert( vercmp( "1", "1.0" ) == -1 );
assert( vercmp( "1.0", "1" ) == 1 );
return 0;
}
Describe in 5 minutes or less what one of these protocols is:
BGP
OSPF
ISIS
PIM-SM
IGMP
STP
DHCP
Could you configure a network device (EOS, Cisco, Linux, JunOS, Quagga, etc.) to
enable any of these?
Pick one of these data structures and tell me everything you know about it:
Red-black tree
B-tree
Patricia
Avl Tree
Trie
Or describe a data structure that can store a set of integers.
If you're not familiar with any of the above, tell me what you know about
one of these:
Bit vector
Binary tree
std::vector
Doubly Linked List
#!/usr/bin/python
# Write a program to num up the Nth column of integers in a file that has
# M columns in it.
What do these tools do?
tcpdump
ping
wireshark
traceroute
ifconfig
ip
netstat
What seven system calls do you use to implement a TCP server?
#include <stdio.h>
#include <stdlib.h>
#include "list.h"
/**
* Given a linked list of the structure:
struct node {
int val;
struct node* next;
};
print out the fibonacci nodes e.g. the 1st, 2nd, 3rd, 5th, 8th... nodes
up until the list ends.
*/
int main( int argc, char** argv ) {
if( argc != 2 ) {
printf( "usage fib num --you gave %d args\n", argc - 1 );
exit( 0 );
}
int nodes = atoi( argv[ 1 ] );
if( nodes < 1 ) {
printf( "num must be a positive number --you gave %d\n", nodes );
}
struct node* list = createList( nodes );
// ...
freeList( list, nodes );
}
include <stdlib.h>
#include <assert.h>
struct node {
int val;
struct node* next;
};
struct node* createList( int nodes );
struct node* freeList( struct node* list, int nodes );
struct node* createList( int nodes ) {
int i = 0;
struct node* list =
( struct node* ) malloc( sizeof( struct node ) * nodes );
assert( list );
for( i = nodes - 1; i >= 0; --i ) {
list[ i ].val = ( nodes - i ) - 1;
list[ i ].next = list + ( i - 1 );
}
list[ 0 ].next = NULL;
return &list[ nodes - 1 ];
}
struct node* freeList( struct node* list, int nodes ) {
free( &list[ 1 - nodes ] );
}
#include <stdio.h>
#include <assert.h>
#include <stdbool.h>
extern bool isPalindrome( const char * );
int main() {
assert( isPalindrome( "civic" ) == true );
assert( isPalindrome( "evitative" ) == true );
assert( isPalindrome( "radar" ) == true );
assert( isPalindrome( "stats" ) == true );
assert( isPalindrome( "abba" ) == true );
assert( isPalindrome( "aba" ) == true );
assert( isPalindrome( "aBa" ) == true );
assert( isPalindrome( "statss" ) == false );
assert( isPalindrome( "abracadabra" ) == false );
printf( "Lower case palindromes passed!\n" );
assert( isPalindrome( "ABa" ) == true );
assert( isPalindrome( "cIviC" ) == true );
printf( "Upper/lower cases examples passed!\n" );
assert( isPalindrome( "" ) == false );
assert( isPalindrome( NULL ) == false );
printf( "No string/empty string corner cases passed!\n" );
printf( "Nailed it!! Congratulations!\n" );
return ( 0 );
}
#include "caesar.h"
#include <stdlib.h>
char rotate(const char in, char pivot, int offset)
{
return pivot + (in - pivot + offset) % 26;
}
void caesar(const char *in, char *outbuf, int offset)
{
int i;
char *out = outbuf;
for (; *in; ++in, ++out) {
if (*in >= 'A' && *in <= 'Z')
*out = rotate(*in, 'A', offset);
else if (*in >= 'a' && *in <= 'z')
*out = rotate(*in, 'a', offset);
else
*out = *in;
}
*out = 0;
}
#include "caesar.h"
#include <stdlib.h>
#include <stdio.h>
int
main(int argc, char *argv[])
{
char *buf = strdup(argv[1]);
caesar(buf, buf, 13);
printf("%s\n", buf);
free(buf);
return 0;
}
struct Tree {
struct Tree * left; // for bst, check all nodes are less than parent
struct Tree * right; // for bst, check all nodes are greater than parent
int value;
}
bool isBst( Tree * tr ) {
return (tr, INT_MIN, INT_MAX);
}
bool helpIsBst(Tree * root, int min, int max) {
if (root == NULL) return 1;
return ( root->value < max && root->value > min
&& helpIsBst(root->left, min, root->value)
&& helpIsBst(root->right, root->value, max));
}
Example BST:
*
* 8
* / \
* 4 12
* / \ / \
* 1 7 11 20
*/
struct node {
int value;
struct node *left, *right, *parent;
}
/* print the bst in-order */
void printBst( struct node *n ) {
}
struct node * findMin( struct node *n ){
}
struct node * findNext( struct node *n ) {
}
void foo( struct node *root) {
for( struct node * n = findMin(root); n; n = findNext(n) ) {
printf( "%d ", n->value );
}
}
#include <cstdio>
// 10
// / \
// 5 16
// / \ / \
// 3 11 14 17
struct node {
int value;
node * left;
node * right;
node * parent;
node( int value, node * left, node * right, node * parent=NULL ) : value( value ), left( left ), right( right ), parent( parent ) {}
};
// Test functions
void connect_parents( node * n, node * parent ) {
if( n ) {
n->parent = parent;
connect_parents( n->left, n );
connect_parents( n->right, n );
}
}
node * construct_tree() {
node * root = new node(
10,
new node( 5,
new node( 3, NULL, NULL ),
new node( 9, NULL, NULL ) ),
new node( 16,
new node( 14, NULL, NULL ),
new node( 17, NULL, NULL ) ) );
connect_parents( root, NULL );
return root;
}
int main() {
node * root = construct_tree();
// for( node * n = find_min( root ); n; n = find_next( n ) ) {
// printf( "%d\n", n->value );
return 0;
}
1. Create account for interviewee
$ tempaccount <username>
2. Login to recruit.arista.com as interviewee
$ ssh username@recruit.arista.com # passwd=aristarecruit
3. Install interview questions into temp account
$ cp ~bterrell/screeningQuestions.gz .
$ tar xvfz screeningQuestions.gz
$ rm screeningQuestions.gz
4. Start tmux on my shell with two panes
$ cp ~bterrell/.tmux.conf ~/.
$ tmux new -s interview
- ctrl+\, "-" to split panes
5. Meet with interviewee (or telecon)
$ ssh username@recruit.arista.com # passwd=aristarecruit
$ tmux attach -t interview"
- switch panes with ctrl+\, <up-or-down arrow>
#include <stdio.h>
#include <stdlib.h>
/* Example BST:
*
* 8
* / \
* 4 12
* / \ / \
* 1 7 11 20
*/
typedef struct node {
int value;
struct node *left, *right, *parent;
} node_t;
struct node * findMin( struct node *n ) {
for(; n && n->left; n = n->left) ;
return n;
}
struct node * findNext( struct node *n ) {
if(n->right) {
return findMin(n->right);
}
else {
for(; n->parent; n=n->parent) {
if(n->parent->left == n) {
return n->parent;
}
}
return NULL;
}
}
/* print the bst in-order */
void printBst( struct node *n ) {
if(n->left) {
printBst(n->left);
}
printf("%d ", n->value);
if(n->right) {
printBst(n->right);
}
void printBstNR( struct node *root) {
node_t* n;
for( n = findMin(root); n; n = findNext(n) ) {
printf( "%d ", n->value );
}
}
node_t* insertNode(node_t** root, int newval)
{
node_t *n;
if(!(*root)) {
n = (node_t*)calloc(1, sizeof(node_t));
n->value = newval;
*root = n;
}
else if(newval < (*root)->value) {
n = insertNode(&((*root)->left), newval);
if((*root)->left == n) n->parent = *root;
}
else {
n = insertNode(&((*root)->right), newval);
if((*root)->right == n) n->parent = *root;
}
return n;
}
int main()
{
node_t* root = NULL;
int data[] = { 8, 4, 12, 1, 7, 11, 20 };
int i, len = sizeof(data) / sizeof(int);
for(i=0; i < len; i++) insertNode(&root, data[i]);
printf("\ntraversal w/o recursion: ");
printBstNR(root);
printf("\ntraversal w/o recursion: ");
printBstNR(root);
printf("\ntraversal w/ recursion: ");
printBst(root);
printf("\n");
return 0;
}
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <string>
using namespace std;
int anagram ( const string s1, const string s2) {
for( int i = 0; i < s1.size(); i++) {
int x = s2.find(s1[i]);
if (x != string::npos)
s2.erase(x);
else
return false;
}
return s2.size()==0;
}
int main (int argc, char *argv[] ){
printf("%d",anagram(argv[1],argv[2]));
}| Report Duplicate | Flag | PURGE
Arista Networks Software Developer - -1of 1 vote
Answers#include <stdlib.h>
- aristainterview October 19, 2016 in United States
#include <assert.h>
extern int find( int *, int );
int main( int argc, char *argv[] ) {
int o[4][5] = { { 4,6,7,8,9 },
{ 4,5,7,8,9 },
{ 4,5,6,8,9 },
{ 4,5,6,7,9 } };
int e[5][6] = { { 4,6,7,8,9,10 },
{ 4,5,7,8,9,10 },
{ 4,5,6,8,9,10 },
{ 4,5,6,7,9,10 },
{ 4,5,6,7,8,10 } };
int i;
for( i=0; i < 4; i++ )
assert( find( o[ i ], 5 ) == i + 5 );
for( i=0; i < 5; i++ )
assert( find( e[ i ], 6 ) == i + 5 );
printf ("I'm a winner\n");
return 0;
}
#include <stdlib.h>
//
// find( ... )
//
// find takes and array of sorted consecutive positive ints where
// one number is missing and returns the missing number
// find should return 0 on all error conditions
//
// [ 1, 2, 3, 4, 6, 7, 8, 9 ] -> return 5
// [ 11, 12, 13, 15, 16, 17 ] -> return 14
//
/* What's wrong with this program? */
#include <stdio.h>
int
main( int argc, char const * argv ) {
for( int i = 0; i < argc; ++i ) {
printf("%s\n", argv[i] );
}
}
/* Can you tell me what the program will do when I run it like this:
* <prog> 1 2 3 4
*/
/*
Describe what two of these do, and how they're useful for debugging:
perf
oprofile
gprof
strace
gcov
printf
syslog
*/
int main( int argc, char* argv[] ){
char* string1 = "string";
char string2[] = "string";
}
#include <stdio.h>
class C {
public:
void func() {
printf("func called\n");
}
virtual void virtualFunc() {
printf("virtual func called\n");
}
};
int main (int argc, char ** argv) {
C * obj = NULL;
/* What does the following print? */
obj->func();
/* What does the following print? */
obj->virtualFunc();
/* What's the difference? */
}
/* What's polymorphism? */
* What's abstraction? */‘
/* What's a virtual function table? */
/* What's a smart pointer? */
/* What's a copy constructor? */
* Tell me what this expression does: */
/* cout << 3; */
/* What could it do? */
/* Have you ever seen OOP inside a Unix kernel? */
/* What's C++0X? */
/* What is const? */
/* What is name mangling? */
/* What does "extern C" do? */
/* What's std::map? */
write( 1, c, strlen(c) );
/* What does this do? */
printf( "%s", c );
/* What's the difference? */
/* What does malloc do? */
/* What does the '-9' mean in 'kill -9'? */
/* What would kill -11 do? */
/* What's a zombie process? */
/* What does fork return? */
/* What is the return value of main used for? */
* What is select used for? Have you ever heard of epoll? */
struct s {
double f;
int i;
char c[3];
void *p;
int x[0]; }; int main( int argc, char ** argv ) { }
/* How big is a float? */
/* write a program to tell me how big a float is */
/* can you use gdb to show me how big a float is? */
/* How many bytes will structure s take? */
/* Write a quick program to tell me the size of structure s */
/* Does this match what you expected? */
/* What does this do?
#define ABC(x) aaa ## x
ABC(b)
*/
/* How are 1d arrays laid out in C ? */
/* What does the compiler do when you have a statement a[ 5 ] */
/* How do you create dynamically allocated arrays in C and how does the complier generate the memory access for a[ 5 ] */
/* How are 2d arrays laid out in C */
/* How do you create a dynamically allocated 2d array in C such that something like:
int **a = get2dArray( 5, 6)
a[ 2 ][ 3] = 5;
would work properly.*/
/* How would you extend it to create an N dimensional array. Something like:
getNdArray( int n, int * dim)
where n = the number of dimensions, and dim is the actual dimensions.
so you could create a 3d array of size 3,4,5 as
int dim[] = [ 3, 4, 5 ];
int ***a = getNdArray( 3, dim );struct s {
double f;
int i;
char c[3];
void *p;
int x[0];
};
int main( int argc, char ** argv ) {
struct s s1;
printf("%i\n", sizeof(s1.f));
printf("%i\n", sizeof(s1.i));
printf("%i\n", sizeof(s1.c));
printf("%i\n", sizeof(s1.p));
printf("%i\n", sizeof(s1.x));
printf("%i\n", sizeof(s1));
}*/
#include <ctime>
#include <sys/time.h>
#include <iostream>
#include <cstdio>
using namespace std;
/* What do this do? */
int a( unsigned int i ) {
int c = 0;
while( i ) {
if( i & 1 ) { c++; }
i >>= 1;
}
return c;
}
/* What does this one do? */
int b( unsigned int i ) {
static unsigned char n[] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4};
int c = 0;
while( i ) {
c+=n[i&15];
i >>= 4;
}
return c;
}
/* Which one do you think would run faster? */
/* Write a small program that uses the gettimeofday function to
* benchmark these functions.
*
* int gettimeofday(struct timeval *tv, struct timezone *tz);
*
* struct timeval {
* time_t tv_sec; // seconds
* suseconds_t tv_usec; // microseconds
* };
*
* The tz argument can be NULL in this case.
*/
int main( int argc, char **argv ) {
}
#include <ctime>
#include <sys/time.h>
#include <iostream>
#include <cstdio>
using namespace std;
/* What do this do? */
int a( unsigned int i ) {
int c = 0;
while( i ) {
if( i & 1 ) { c++; }
i >>= 1;
}
return c;
}
/* What does this one do? */
int b( unsigned int i ) {
static unsigned char n[] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4};
int c = 0;
while( i ) {
c+=n[i&15];
i >>= 4;
}
return c;
}
/* Which one do you think would run faster? */
/* Write a small program that uses the gettimeofday function to
* benchmark these functions.
*
* int gettimeofday(struct timeval *tv, struct timezone *tz);
*
* struct timeval {
* time_t tv_sec; // seconds
* suseconds_t tv_usec; // microseconds
* };
*
* The tz argument can be NULL in this case.
*/
int main( int argc, char **argv ) {
struct timeval t1 = {0, 0};
struct timeval t2 = {0, 0};
PROJECT = find
CC = gcc
OBJ = find.o main.o
all: $(PROJECT)
.c.o:
$(CC) -I. -g -c $<
$(PROJECT): $(OBJ)
$(CC) $(OBJ) -o $(PROJECT)
clean:
rm -f find find.o main.o
/*
* describe the code below
*/
struct s {
double f;
int i;
char c[3];
void *p;
int x[0];
};
int main( int argc, char ** argv ) {
struct s new_s;
size_t size = sizeof(new_s.f);
size_t size_i = sizeof(new_s.i);
size_t size_c = sizeof(new_s.c);
size_t size_p = sizeof(new_s.p);
size_t size_x = sizeof(new_s.x);
int size_s = (int) sizeof(new_s);
int total = (int) size + size_i + size_c + size_p + size_x;
printf ("Total: %d", total);
printf ("Struct size: %d", size_s);
return 0;
}
/* How are 1d arrays laid out in C ? */
/* What does the compiler do when you have a statement a[ 5 ] */
/* How do you create dynamically allocated arrays in C and how does the complier generate the memory access for a[ 5 ] */
/* How are 2d arrays laid out in C */
/* How do you create a dynamically allocated 2d array in C such that something like:
int **a = get2dArray( 5, 6)
a[ 2 ][ 3] = 5;
would work properly.*/
/* How would you extend it to create an N dimensional array. Something like:
getNdArray( int n, int * dim)
where n = the number of dimensions, and dim is the actual dimensions.
so you could create a 3d array of size 3,4,5 as
int dim[] = [ 3, 4, 5 ];
int ***a = getNdArray( 3, dim );
*/| Report Duplicate | Flag | PURGE
Arista Networks Software Developer - -1of 1 vote
Answers#ifndef STACK_H
- aristainterview October 19, 2016 in United States
#define STACK_H
typedef struct my_stack_ {
unsigned char *buf;
size_t elem_count;
size_t elem_size;
size_t buf_size;
} my_stack_t;
typedef struct my_stack_ my_stack_t;
my_stack_t * my_stack_init(size_t elem_size);
void my_stack_push(my_stack_t *stack, void *elem);
int my_stack_pop(my_stack_t *stack, void *elem);
size_t my_stack_depth(my_stack_t *stack);
void my_stack_push(my_stack_t *stack, void *elem)
{
assert(stack && elem);
size_t offset = stack->elem_count * stack->elem_size;
if(offset >= stack->buf_size) {
size_t new_size = stack->buf_size * 2;
unsigned char *p = realloc(stack->buf, new_size);
stack->buf = p;
}
stack->elem_count++;
memcpy(stack->buf + offset, elem, stack->elem_size);
}
#endif
struct node {
int value;
struct node * next;
};
struct node * mylist;
mylist
[--]--
|
|
---->[ 3, --]---->[ 2, --]---->[ 1, X]
remove_matches( mylist, 2 );
mylist
[—]—:
|
| -----------------------
| | |
| | v
---->[ 3, | ] [ 2, --]---->[ 1, X]
mylist
[--]--
|
|
---->[ 3, --]---->[ 1, X]| Report Duplicate | Flag | PURGE
Arista Networks Software Developer - 0of 0 votes
AnswersApparently DESCO asked it. It was faulty, and I am fixing it. The physics was wrong. A mono pole is an abstract magnet with either the north or the south pole of the magnet.
[ en.wikipedia.org/wiki/Magnetic_monopole ]
Imagine you are given such *n* monopoles, all of the same type, say North type. Thus, all of these repel one another. The force of repulsion follows inverse square law :
[ en.wikipedia.org/wiki/Inverse-square_law ]
That is, given two such monopoles with a distance *r* between them, the force of repulsion between them is given by :F = ( 1.0 ) / ( r ** 2 )
Now, suppose you are also given an array of *n* number of positions over X axis, like : [ 0, 1, 4, 10 , 21 , .. ] where you need to place the monopoles ( imagine they are hold tight there, and do not move away ).
- NoOne October 18, 2016 in United States
After placement, you are given another monopole, of different type S, say. Find positions to place the monopole so that it is stable.
Fixes from the original question :
[geeksforgeeks.org/d-e-shaw-interview-experience-set-19-on-campus/ ]
1. Monopoles exhibit inverse square law, not inverse law.
2. It is impossible to have stable configuration using same type monopole, so one must use another type, repulsion is not stable, attraction is.
( Terrible physics mistakes )
PS. Do not try to do binary search here. Binary search assumption is underlying linearity of the structure, thus, effectively there are proportionate elements in left and right. In the classic cases of sorted array, the expectation is 50/50. But here due to non linearity (inverse square) , it won't work.| Report Duplicate | Flag | PURGE
Deshaw Inc Software Developer Algorithm - 1of 1 vote
AnswersFind the shortest path between a start node and end node in a undirected +ve weighted graph.
You are allowed to add at max one edge between any two nodes which are not directly connected to each other.
ex:
From | To | Weight
1 2 2
1 4 4
2 3 1
3 4 3
4 5 1
start node = 1, end node = 5.
extra edge weight = 2.
- JerryGoyal October 15, 2016 in United States1----(2)----2 | | | | (4) (1) | | | | 5-(1)-4----(3)----3 In this case answer would be 3 (from 1 - > 5 - > 4) Solution: 1----(2)----2 /| | / | | (2)/ (4) (1) / | | / | | 5-(1)-4----(3)----3
| Report Duplicate | Flag | PURGE
Google Software Developer Algorithm - 0of 0 votes
AnswersAs you know, Computers were invented to solve practical business problems, we tend to ask practical applied questions. One of the key areas where we want to apply computers is simulation. As most of the people working in software are Engineers, here is the problem. It is called 3 body problem.
- NoOne October 15, 2016 in India
3 Bodies with masses [ m1, m2, m3 ] are initially positioned in the 3 points in the space, thus, having positions [ P1, P2, P3 ].
Observe that each Pi is nothing but [ xi, yi, zi ].
Once the initial condition is set, definitely gravity would work and they would start falling against each other. Write code to simulate this problem. Imagine G, the constant of gravity as 1.
How do you go about simulating it?
Hint : feynmanlectures.caltech.edu/I_09.html see 9.5
Face to face. Pen and Paper. Panel Interview, 2 person Panel. 60 Minutes. For Engineers only, was specifically told about it.| Report Duplicate | Flag | PURGE
Software Developer Algorithm Computer Science Graphics Math & Computation Programming Skills - 0of 0 votes
AnswersGiven a convex polygon ( is planer as opposed to a polytope) and a point one had to tell if the point lies inside the polygon or outside the polygon.
- NoOne October 14, 2016 in India
To understand convexity : mathopenref.com/polygonconvex.html
Thus the question comprise of 3 sub problems :
1. How to store a polygon.
2. How to define inside and outside of a polygon.
3. How to solve the actual one, given 1,2 ?| Report Duplicate | Flag | PURGE
Deshaw Inc Software Developer Algorithm - 1of 1 vote
AnswersLet's say I have a word "I love chicken", I can break the number of characters in each word, like so: [1] [4] [7]
- J@sper October 11, 2016 in United States
[1,4] [4,7], [1,4,7].
Now let's say I have a max = 5. The phrases with equal or fever than 5 characters are "[I], [love], and [I, love]. The longest phrase is [I,love], which contains 2 words.
Complete the Length function given. It has 2 parameters:
1) An array of integers, named array
2) A maximum number, named max.
int Careercup( int [] array, int max) {
}
Example test case 1:
[3,1,2,3]
4
Output expected : 2| Report Duplicate | Flag | PURGE
Google Software Developer Arrays - 1of 1 vote
AnswersGiven infinite supply of coins of denominations 25, 10, 5 and 1, find the distinct number of ways to use the coins to sum up to the given value
- mikewhity October 10, 2016 in United States
Find the best algorithm with the best time complexity| Report Duplicate | Flag | PURGE
Akamai Software Developer - 0of 0 votes
AnswersWrite a program to print pascal triangle using binomial formula.
- D PRAVEEN KUMAR October 06, 2016 in India| Report Duplicate | Flag | PURGE
Skill Subsist Impulse Ltd Software Developer C - 0of 0 votes
AnswersWrite a program to check a given matrix is Idempotent or not.
- D PRAVEEN KUMAR October 06, 2016 in India| Report Duplicate | Flag | PURGE
Skill Subsist Impulse Ltd Software Developer C - -1of 1 vote
AnswersWrite a program to check a given matrix is involutive or not.
- D PRAVEEN KUMAR October 06, 2016 in India| Report Duplicate | Flag | PURGE
Skill Subsist Impulse Ltd Software Developer C - -1of 1 vote
AnswersWrite a program to check a given matrix is orthogonal or not.
- D PRAVEEN KUMAR October 06, 2016 in India| Report Duplicate | Flag | PURGE
Skill Subsist Impulse Ltd Software Developer C - 0of 0 votes
AnswerWrite a program to check a given matrix is A symmetric matrix or not.
- D PRAVEEN KUMAR October 06, 2016 in India| Report Duplicate | Flag | PURGE
Skill Subsist Impulse Ltd Software Developer C - 0of 0 votes
AnswersWrite a program to find the number of ways can one climb a staircase with 'n' steps, taking one or two steps at a time.
- D PRAVEEN KUMAR October 06, 2016 in India| Report Duplicate | Flag | PURGE
Skill Subsist Impulse Ltd Software Developer C - 0of 0 votes
AnswersWrite a program to add the following
- D PRAVEEN KUMAR October 04, 2016 in India
¼+2/4+3/4+5/3+6/3+...| Report Duplicate | Flag | PURGE
HTC Global Services Software Developer C++ - 0of 0 votes
AnswersWrite a program to get the user name and age
- D PRAVEEN KUMAR October 04, 2016 in India
Condition:
The name should be more than six characters and it shouldn’t contain any other characters than alphabet(like !,@,#,$,^,& these are not to be present)
The age of the employee must between 18-35| Report Duplicate | Flag | PURGE
HTC Global Services Software Developer C++ - 1of 1 vote
AnswersGet an 0. From user and display it’s prime factor
- D PRAVEEN KUMAR October 04, 2016 in India
Example 24 is 2,2,2,3 and 55 is 5,11| Report Duplicate | Flag | PURGE
HTC Global Services Software Developer C++ - 0of 0 votes
AnswersIn a college library fines are issued according to the following condition
- D PRAVEEN KUMAR October 04, 2016 in India
If return books exceeds the due date
Up to 5 days 20rs fine
6-10 days 50rs fine
>10 days 100rs fine
More than 30 days membership will be cancelled
Get the due date from the user and calculate| Report Duplicate | Flag | PURGE
HTC Global Services Software Developer C++ - 0of 0 votes
AnswersWrite a program to get a string and to convert the 1st letter of it to uppercase ?
- D PRAVEEN KUMAR October 04, 2016 in India| Report Duplicate | Flag | PURGE
HTC Global Services Software Developer C++ - 0of 0 votes
AnswerWrite a program to create a sentence at runtime and count number of vowels in it ?
- D PRAVEEN KUMAR October 04, 2016 in India| Report Duplicate | Flag | PURGE
HTC Global Services Software Developer C++ - 0of 0 votes
AnswersWrite a program to calculate the following i want a c++program for this condition 1+4+9+16+….+100
- D PRAVEEN KUMAR October 04, 2016 in India| Report Duplicate | Flag | PURGE
HTC Global Services Software Developer C++ - 0of 0 votes
AnswersWrite a class stringOperation to check whether the characters entered by the user are same or not
- D PRAVEEN KUMAR October 04, 2016 in India| Report Duplicate | Flag | PURGE
HTC Global Services Software Developer C++ - 0of 0 votes
Answerswrite default and parameterized constructor accepting two variables
- D PRAVEEN KUMAR October 04, 2016 in India| Report Duplicate | Flag | PURGE
HTC Global Services Software Developer Java - 0of 0 votes
Answerswrite a program to count number of prime number between two numbers entered by the user
- D PRAVEEN KUMAR October 04, 2016 in India| Report Duplicate | Flag | PURGE
HTC Global Services Software Developer C - 0of 0 votes
Answerswrite a function called reverse to print the reverse of the digit entered by the user.
- D PRAVEEN KUMAR October 04, 2016 in India| Report Duplicate | Flag | PURGE
HTC Global Services Software Developer C - 0of 0 votes
Answerwrite a program to implement following logic
- D PRAVEEN KUMAR October 04, 2016 in India
If the price of the book in between 100 to 500 book is “Normal Book”
If the price is between 501 and 5000 book is “Costly book”
If greater than 5000 than book is “precious book”| Report Duplicate | Flag | PURGE
HTC Global Services Software Developer C - 0of 0 votes
Answerwrite a program to add all the non-diagonal elements of a 2D array.
- D PRAVEEN KUMAR October 04, 2016 in India| Report Duplicate | Flag | PURGE
HTC Global Services Software Developer C