Texas Instruments Interview Question






Comment hidden because of low score. Click to expand.
3
of 3 vote

code 1 is going to b better as..
no of comparisions in 1 are = 100 + 100*10000=1000100
100 for each increment of i and (10000*100) for each i we have 10000 k comparisions

but in code 2 total no. of comparisions are 10000 + 10000*100=1010000 > 1000100

- ashish kumar dey August 21, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

First one will be better.. Suppose we want to generate a delay. Inner loop suppose introduces a delay of 1 sec.. We can directly manipulate the overall delay by specifying i may be 10 or 100 for 10 sec or 100 sec delay resp.

- Harjot Singh September 16, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

it Depends on what goes in <lines of code> and what you are accessing inside this.
From cache point,'2' code structure seems to be better, as read ahead scheme would be better for this.

- hari_nc February 10, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Can you explain me in more detail please.

- Tosha December 05, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

The first one. as we are doing condition check of k<10000 for only 100 times.

- Dipankar February 14, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

...but we are also doing a condition check of i<100 for 10000 times

- George October 03, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Both will take same time I guess

- Pratik K April 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

i think the 1st one because it will be lesser number of times execution will take place..

- Dennis Richie November 04, 2014 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More