## Forum Posts

- 0 Answers
**Removing even/odd numbers in problem 5.7 of cracking the coding interview**Following is problem 5.7 (under Bit Manipulation) in the 5th edition of Cracking the coding interview:

- shahsunny712 May 14, 2015

An array A[1..n] contains all the integers from 0 to n except for one number which is missing. In this problem, we cannot access an entire integer in A with a single opera-tion. The elements of A are represented in binary, and the only operation we can use to access them is “fetch the jth bit of A[i]”, which takes constant time. Write code to find the missing integer. Can you do it in O(n) time?

The algorithm applied is this:

1. Start with LSB.

2. Count occurrence of 1's vs 0's.

If count(1) < count(0) it means the missing number has a 1 as it's LSB, else it has a 0.

3. Remove all numbers with LSB not matching result found in step 3.

4. Repeat steps 1 to 4, and progressively checking the next LSB in each iteration.

Can someone explain the logic behind step 3? It basically removes all odd/even numbers from the current list (depending on the bit found for the missing number) and uses the modified list in the next iteration. Why do we do this?| Flag | PURGE - 0 Answers
**Given a complete binary tree find if it is a value balanced tree or not.**A tree is called value balanced tree if for all nodes, sum of values (assume the values are integers) of nodes in left hand side is equal to sum of values in right hand side.

- JerryGoyal May 10, 2015

Given a complete binary tree find if it is a value balanced tree or not.

Test Case 1

3

1 1 1

Tree is value balanced

Test Case 2

7

3 0 -1 1 1 2 2

Tree is not value balanced

Test Case 3

15

22 2 4 -3 1 0 -4 4 4 2 2 2 2 4 4

Tree is value balanced

can it be done without creating tree data structure, solely from array?| Flag | PURGE - 0 Answers
**Check if graph is connected**Hi all I want to my method to return true if two node of un directed graph is connected,

- apurohit.in May 09, 2015

Method print yes its connected but return false ?

public static boolean isConnectedGraph(int[][] graph, int start, int end,

int visited[]) {

visited[start] = 1;

if (graph[start][end] == 1) {

System.out.println("yes its connected ....");

return true;

}

for (int i = 0; i < graph[0].length; i++) {

if (graph[start][i] == 1 && visited[i] == 0) {

visited[i] =1;

isConnectedGraph(graph, i, end, visited);

}

}

return false;

}| Flag | PURGE - 1 Answer
**Best resource to understand asymptotic analysis or time complexity.**I am having a hard time understanding the calculations for time complexity/asymptotic analysis. I tried referring possible algorithm books I could i.e. Cormen, Steven Skiena and few others. I just don't want to memorize the time complexity of every algorithm to clear the interviews, but wish to understand how to come up with the time complexity.

- ACE CA April 27, 2015

Please let me know what is the best way to learn and understand time complexity.| Flag | PURGE - 0 Answers
**Looking for interview practices**I am applying a CS developer position at major IT companies. Although I have studied many available interview questions, I would like to have more in-person practices. If you are also working towards the same goal, we would help each other to practice more for better result. We can utilize a Skype or similar. Please let me know if you are interested. Usernamepi@outlook.com

- cs April 27, 2015

Thanks.| Flag | PURGE - 0 Answers
**SQL**I have three tables as mentioned below. I need to implement a basic search functionality where user will search for a keyword which could either match 'title' (from Proposal table) or 'msNumber' or 'description' (from Project table) and should match 'stageNumber' and 'newState' from ProjectLifecycle table.

- ravicandy1234 April 27, 2015

create table Proposal (

proposalId LONG not null primary key,

title VARCHAR(75) null,

);

create table Project (

proposalId LONG not null primary key,

msNumber VARCHAR(75) null,

description VARCHAR(75) null

);

create table ProjectLifecycle (

lifecycleId LONG not null primary key,

proposalId LONG,

stageNumber DOUBLE,

newState LONG,

);

Below is the query which am using right now

SELECT

p.proposalId, p.title, pj.msNumber

FROM

Proposal p

JOIN

ProjectLifecycle pl ON pl.proposalId = p.proposalId

JOIN

Project pj ON pj.proposalId = pl.proposalId

WHERE

(p.title like '%%' or pj.msNumber like '%%')

AND

pl.newState=0

AND

(pl.stageNumber= 60.60 OR pl.stageNumber < 60.60 OR pl.stageNumber = 95.99);

The stageNumber and the newState conditions are working fine as expected but the keyword search isn't.

Please help me in finding where i'm going wrong| Flag | PURGE - 0 Answers
**trip planner problem**The input is the set of flights between various cities. It is given as a file. Each line of the file contains "city1 city2 departure-time arrival-time flight-no. price" This means that there is a flight called "flight-no" (which is a string of the form XY012) from city1 to city2 which leaves city1 at time "departure-time" and arrives city2 at time "arrival-time". Further the price of this flight is "price" which is a poitive integer. All times are given as a string of 4 digits in the 24hr format e.g. 1135, 0245, 2210. Assume that all city names are integers between 1 and a number N (where N is the total number of cities).

- ry197089 April 23, 2015

Note that there could be multiple flights between two cities (at different times).

The query that you have to answer is: given two cities "A" and "B", times "t1", "t2", where t1 < t2, find the cheapest trip which leaves city "A" after time "t1" and arrives at city "B" before time "t2". A trip is a sequence of flights which starts at A after time t1 and ends at B before time t2. Further, the departure time from any transit (intermediate) city C is at least 30 mins after the arrival at C

what approach will be best for solving this| Flag | PURGE - 0 Answers
**Hello All**I am planning to shift my Job in India (In companies like linkedIn, FlipKart, Snapdeal ,Amazon,WalMart , Microsoft.

- vishraji81 April 10, 2015

I am 12 years experience in C++ Algorithms and DataStructures . I am average in Algos. The time period I have thought I should give the interviews by next month So Can some one tell me the best strategy to prepare for the job change .| Flag | PURGE - 0 Answers
**effective parallelisation bilinear interpolation using OpenMP**I want to parallelise bilinear interpolation using OpenMP in such a way that there should be least memory access of input array. In the code below, for each iteration of i and j in output array, input data according to longitude and latitude values are read and processed.

- pritish.naik.004 April 10, 2015

input[20][20] - input array that contains data values eg{1,2,3,..,400} in 2d

lon[100][100] - longitudinal positions of each interpolation point in output array in horizontal axis not necessarily equidistant. eg. {2.34,2.65,2.74... }

lat[100][100] - latitudinal positions of each interpolation point in output array in vertical axis not necessarily equidistant.eg. {5.76,5.92,6.26... }

output[100][100] - array containing interpolated values

void interpolate(float (*lon)[100] ,float (*lat)[100] , float (*input)[100],float (*output)[100]) {

int i,j,floori,floorj;

float fractionj,fractioni;

for(j = 0; j < 100; j++)

{

for(i = 0; i < 100; i++)

{

floori = lon[i][j];

fractioni = lon[i][j] - floori;

floorj = lat[i][j];

fractionj = lat[i][j] - floorj;

output[i][j] = (1.0-fractioni)*(1.0-fractionj)*input[floori][floorj] + fractioni*(1.0-fractionj)*input[floori+1][floorj] + (1.0-fractioni)*fractionj*input[floori][floorj+1] + fractioni * fractionj *input[floori+1][floorj+1];

}

}

}

I need to divide the work in such a way that for all the interpolation points specified using lon and lat values within block of input[floori][floorj],input[floori+1][floorj],input[floori][floorj+1],input[floori+1][floorj+1] should go to one thread so that input values are read only once from memory to register for each thread.| Flag | PURGE - 0 Answers
**Amazon Onsite Interview Result**Hi

- conundrum4u April 09, 2015

I have had an Onsite interview at Amazon on March 17th(which i think went well from myside). Still didn't hear anything back from them. I have put a mail on Monday but didnt hear back from them.

1.Can you please let me know if anyone who went around the same date, heard anything back?

2. What does this delay usually mean? Is it a Red flag:(

3. Do they usually sent rejection mails or do they not?

Please let me know!

Thanks in advance!| Flag | PURGE - 0 Answers
**Resume tips**I have around about 3 yrs exprience in the field of developing iOS apps,and have developed 8+ apps. My GPA is bad,and i am not from any premier institute, So breaking all my negative beliefs,i have applied for Google and Amazon,i have tried adding whatever i could in my resume,but i am wondering what would that x-factor be that might help me

- vnhrmth April 07, 2015| Flag | PURGE - 1 Answer
**Applied for software engineer position**I have applied for multiple companies,such as google and amazon,i don't have a github account and haven't contributed to open source or created any library,i have developed 8 applications for iOS,My academics isn't that great,i was wondering if these companies would still give me a chance,if no i would want to know,how to be seen by these companies? How can i make my mark?

- vnhrmth April 07, 2015| Flag | PURGE - 2 Answers
**Need Help for preparation**Hello Everyone,

- saikat1239 April 04, 2015

I need your help to prepare data structure and algorithm question. Can anyone suggest any book that easy to understand and would take less time to prepare? I am not much confident in Java. Please advise.

Thanks| Flag | PURGE

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window