anaghakr89
BAN USER- 0of 0 votes
AnswersDesign a space shooter program .
- anaghakr89 in United States for Nest Labs
Note: The game includes spaceship , bullets and asteroids. Spaceship rotates in 180 degree generating bullets. The position of the bullets gets updated after certain time period every time . No Need to write the code for collision detection
Basic code in expected . Not the entire working code.| Report Duplicate | Flag | PURGE
Google Software Developer - 0of 0 votes
AnswersExplain the linear piecewise function.
- anaghakr89 in United States for Nest Labs| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 0 votes
AnswersExplain event driven programming in C with example
- anaghakr89 in United States| Report Duplicate | Flag | PURGE
Apple Software Engineer - 1of 3 votes
AnswersThe array of integers in given . The array indicates nothing but the heights of the cylinders. The robotic arm has two ends-> left and right.
- anaghakr89 in United States
The left end points to the left end of the cylinder array and right end searched for the cylinder with least height.
ex:
array = {4,5,6,7,1,2}
left end => index 0
right end =>index 0->n giving index 4 with min height
Now the entire block is rotated by 180 degree.
now the array = { 1, 7, 6, 5, 4, 2}
now the left end moves forward.
and right end will search from left index onwards till the end of the array
so left index = 1
right index => 1-> n giving index 5 as min. height
again do the block rotate .
Write the code for this particular algorithm.
However, there is one condition
1. If there are duplicates in the array then the final order of those duplicates should remain the same.
ex. If the cylinder with height 4 is appearing at index 3 and 5 in the initial array then the cylinder at index 3 should always appear before the one at index 5 in the final array.| Report Duplicate | Flag | PURGE
Google Software Developer - 0of 0 votes
AnswersWrite a C code matrix multiplication in such a way that the matrix can be read in row major form only
- anaghakr89 in United States for Touch system software| Report Duplicate | Flag | PURGE
Qualcomm SDE-2 - -1of 1 vote
AnswersThe array of integers in given . The array indicates nothing but the heights of the cylinders. The robotic arm has two ends-> left and right.
- anaghakr89 in United States
The left end points to the left end of the cylinder array and right end searched for the cylinder with least height.
ex:
array = {4,5,6,7,1,2}
left end => index 0
right end =>index 0->n giving index 4 with min height
Now the entire block is rotated by 180 degree.
now the array = { 1, 7, 6, 5, 4, 2}
now the left end moves forward.
and right end will search from left index onwards till the end of the array
so left index = 1
right index => 1-> n giving index 5 as min. height
again do the block rotate .
Write the code for this particular algorithm.
However, there is one condition
1. If there are duplicates in the array then the final order of those duplicates should remain the same.
ex. If the cylinder with height 4 is appearing at index 3 and 5 in the initial array then the cylinder at index 3 should always appear before the one at index 5 in the final array.| Report Duplicate | Flag | PURGE
Google Software Developer - 0of 0 votes
AnswersImplement Ring Buffer with read and write pointers.
- anaghakr89 in United States
For example if the Ring buffer is implemented in the form of array of integers , one should be able to read / write more than one integer at a time. In short the data read / written should be in a chunk .| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer
This is a very basic question. I doubt if anyone asks this question in interviews any more.
- anaghakr89 August 18, 2017@ChrisK : There is an answer in the question thread which is correct. That was the answer interviewer was looking for
- anaghakr89 August 18, 2017This has the o(nlogn) time complexity
Do rectify me if I am wrong .
I dont think so .. The thing that you are saying sound more like parsing the string that will be sent to the online calculator . If not can you explain it with code.
- anaghakr89 August 10, 2017If the number is square then only it will remain on . Otherwise off.
The square numbers have odd number of factors
It is related to the code shared by Mohan
- anaghakr89 August 09, 2017Thanks for sharing the code. However , I have not understood rotate(arr, 2).
What is the purpose of 2 in this ?
I was asked the same question in my interview. :)
- anaghakr89 August 07, 2017Search for run length coding .
Th code is also available on geeksforgeeks
RepI'm from India, 26 years old. I want to travel, I want a job where I can earn money ...
RepShastri Ji is well known hindi and tamil vashikaran specialist. He will give you effective and simple totke to control ...
Repammiwilson5, Personnel at BMO Harris Bank
Hi I am Ammy from Served on a research team for improved customer satisfaction survey process,Moderated focus groups to ...
Repannehbell8, Quality Assurance Engineer at Globaltech Research
Build and maintain relationships with convention vendors. Resolve issues throughout meeting event timelines.Plan room layouts and event programs, schedule ...
#include <pthread.h>
- anaghakr89 April 19, 2018#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int average;
int size = 0;
void *calcAvg(void *arg);
int numbers[] = {0,1,2,3,4,5,6,7};
pthread_mutex_t count_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t even = PTHREAD_COND_INITIALIZER;
pthread_cond_t odd = PTHREAD_COND_INITIALIZER;
void *print_even();
void *print_odd();
int count = 0;
// This is useful when the elements are not provided via array
#define COUNT_DONE 200
int main(int argc, char *argv[])
{
if(argc < 1)
exit(0);
//initialize an array of the integers to be passed
int numSize = atoi(argv[1]);
srand(time(NULL));
int *nums = (int*)malloc((numSize)*sizeof(int));
int i ;
for(i = 0; i < numSize ; i++)
{
nums[i] = (rand() % 100) + i ;
printf("%d " , nums[i]);
size++;
}
printf("\n");
//Thread Identifier
//pthread_t avgThread;
//pthread_create(&avgThread, NULL, calcAvg, (void*)nums);
pthread_t even_thread;
pthread_t odd_thread;
pthread_create(&even_thread, NULL, print_even , (void*)nums);
pthread_create(&odd_thread, NULL, print_odd, (void*)nums);
//pthread_join(avgThread, NULL);
//printf("average = %d \n",average);
pthread_join(even_thread, NULL);
pthread_join(odd_thread, NULL);
pthread_mutex_destroy(&count_mutex);
pthread_cond_destroy(&even);
pthread_cond_destroy(&odd);
free(nums);
return 0;
}
void *calcAvg(void *arg)
{
int *val_p = (int *) arg;
int sum = 0;
int i = 0;
for( i = 0; i < size; i++){
sum += val_p[i];
}
average = sum / (size);
pthread_exit(0);
}
// Print even numbers
void *print_even(void *arg)
{
int *arr_p = (int *)arg;
while(count < size)
{
// Lock mutex and then wait for signal to relase mutex
pthread_mutex_lock( &count_mutex );
//Keep looping till the condition becomes even
while( arr_p[count] % 2 == 1 )
pthread_cond_wait( &even, &count_mutex );
printf("Array value print_even: %d\n",arr_p[count]);
count++;
pthread_cond_signal( &odd );
pthread_mutex_unlock(&count_mutex);
}
pthread_exit(0);
}
// print odd numbers
void *print_odd(void *arg)
{
int *arr_p = (int*)arg;
while(count < size)
{
// Lock mutex and then wait for signal to relase mutex
pthread_mutex_lock( &count_mutex );
//Keep looping till the condition becomes odd
while( arr_p[count] % 2 == 0 )
pthread_cond_wait( &odd, &count_mutex );
printf("Array Value print_odd: %d\n", arr_p[count]);
count++;
pthread_cond_signal(&even);
pthread_mutex_unlock(&count_mutex);
}
pthread_exit(0);
}