Two sticks and matchbox, measure exactly 45 minutes by burning these sticks


Question: You have two sticks and matchbox. Each stick takes exactly an hour to burn from one end to the other. The sticks are not identical and do not burn at a constant rate. As a result, two equal lengths of the stick would not necessarily burn in the same amount of time.  How would you measure exactly 45 minutes by burning these sticks?

Answer: This puzzle used to be asked in Wall Street interviews long time ago. It is very rare for this question to be asked now but it is a very good question to help you think a little outside the normal thought process.

The answer is really simple. Since the sticks do not burn at a constant rate, we can not use the length of the stick as any sort of measurement of time. If we light a stick, it takes 60 minutes to burn completely. What if we light the stick from both sides? It will take exactly half the original time, i.e. 30 minutes to burn completely.

0 minutes – Light stick 1 on both sides and stick 2 on one side.
30 minutes – Stick 1 will be burnt out. Light the other end of stick 2.
45 minutes – Stick 2 will be burnt out.

If you have any interesting questions, feel free to email them to support@goforexam.in

Aptitude Question - what is the proportion of boys to girls in the country?


Question: In a country where everyone wants a boy, each family continues having babies till they have a boy. After some time, what is the proportion of boys to girls in the country? (Assuming probability of having a boy or a girl is the same)

Answer: This is a very simple probability question in a software interview. This question might be a little old to be ever asked again but it is a good warm up.

Assume there are C number of couples so there would be C boys. The number of girls can be calculated by the following method.
Number of girls = 0*(Probability of 0 girls) + 1*(Probability of 1 girl) + 2*(Probability of 2 girls) + …
Number of girls = 0*(C*1/2) + 1*(C*1/2*1/2) + 2*(C*1/2*1/2*1/2) + …
Number of girls = 0 + C/4 + 2*C/8 + 3*C/16 + …
Number of girls = C
(using mathematical formulas; it becomes apparent if you just sum up the first 4-5 terms)

Thus the proportion of boys to girls is 1 : 1.

Finding the sub-array with the largest sum.


Question: You are given an array with integers (both positive and negative) in any random order. Find the sub-array with the largest sum.

Answer: This is an all-time favorite software interview question. The best way to solve this puzzle is to use Kadane’s algorithm which runs in O(n) time. The idea is to keep scanning through the array and calculating the maximum sub-array that ends at every position. The sub-array will either contain a range of numbers if the array has intermixed positive and negative values, or it will contain the least negative value if the array has only negative values. Here’s some code to illustrate.
 
void maxSumSubArray( int *array, int len, int *start, int *end, int *maxSum )
{
    int maxSumSoFar = -2147483648;
    int curSum = 0;
    int a = b = s = i = 0;
    for( i = 0; i < len; i++ ) {
        curSum += array[i];
        if ( curSum > maxSumSoFar ) {
            maxSumSoFar = curSum;
            a = s;
            b = i;
        }
        if( curSum < 0 ) {
            curSum = 0;
            s = i + 1;
        }
    }
    *start = a;
    *end = b;
    *maxSum = maxSumSoFar;
}
 
Think you have a better solution? We'd love to read your comments!

Reverse a Linked-list. Write code in C.


Question : Reverse a Linked-list. Write code in C.

Answer: There are multiple ways to go about this. Let’s first look at a recursive solution.
 
Node * reverse( Node * ptr , Node * previous)
{
    Node * temp;
    if(ptr->next == NULL) {
        ptr->next = previous;
        return ptr;
    } else {
        temp = reverse(ptr->next, ptr);
        ptr->next = previous;
        return temp;
    }
}
reversedHead = reverse(head, NULL);

Now for a non-recursive solution.

 
Node * reverse( Node * ptr )
{
    Node * temp;
    Node * previous = NULL;
    while(ptr != NULL) {
        temp = ptr->next;
        ptr->next = previous;
        previous = ptr;
        ptr = temp;
    }
    return previous;
}
 

If anyone has any modifications or a better methods, please post it up. Comments are always welcome.

TCS Aptitude test, Placement Questions with Solution



1) If log 0.317=0.3332 and log 0.318=0.3364 then find log 0.319 ?
Sol: log 0.317=0.3332 and log 0.318=0.3364, then
log 0.319=log0.318+(log0.318-log0.317) = 0.3396

2) A box of 150 packets consists of 1kg packets and 2kg packets. Total weight of box is 264kg. How many 2kg packets are there ?
Sol: x= 2 kg Packs
y= 1 kg packs
x + y = 150     .......... Eqn 1
2x + y = 264   .......... Eqn 2
Solve the Simultaneous equation; x = 114
so, y = 36
ANS :  Number of 2 kg Packs = 114.

3) My flight takes of at 2am from a place at 18N 10E and landed 10 Hrs later at a place with coordinates 36N70W. What is the local time when my plane landed?

Options: a)6:00 am b) 6:40am c) 7:40 d) 7:00 e) 8:00
Sol: The destination place is 80 degree west to the starting place. Hence the time difference between these two places is 5 hour 20 min. (=24hr*80/360).
When the flight landed, the time at the starting place is 12 noon (2 AM + 10 hours).
Hence, the time at the destination place is 12 noon - 5:20 hours = 6: 40 AM

4) A plane moves from 9°N40°E to 9°N40°W. If the plane starts at 10 am and takes 8 hours to reach the destination, find the local arrival time ?
Sol: Since it is moving from east to west longitide we need to add both
ie,40+40=80
multiply the ans by 4
=>80*4=320min
convert this min to hours ie, 5hrs 33min
It takes 8hrs totally . So 8-5hr 30 min=2hr 30min
So the ans is 10am+2hr 30 min
=>ans is 12:30 it will reach

5) The size of the bucket is N kb. The bucket fills at the rate of 0.1 kb per millisecond. A programmer sends a program to receiver. There it waits for 10 milliseconds. And response will be back to programmer in 20 milliseconds. How much time the program takes to get a response back to the programmer, after it is sent? answer with explanation.
Sol: see it doesn't matter that wat the time is being taken to fill the bucket.after reaching program it waits there for 10ms and back to the programmer in 20 ms.then total time to get the response is 20ms +10 ms=30ms...it's so simple....

6) A fisherman's day is rated as good if he catches 9 fishes, fair if 7 fishes and bad if 5 fishes. He catches 53 fishes in a week n had all good, fair n bad days in the week. So how many good, fair n bad days did the fisher man had in the week
Ans: 4 good, 1 fair n 2 bad days
Sol: Go to river catch fish
4*9=36
7*1=7
2*5=10
36+7+10=53...
take what is given 53
good days means --- 9 fishes so 53/9=4(remainder=17)  if u assume 5 then there is no chance for bad days.
fair days means ----- 7 fishes so remaining 17 --- 17/7=1(remainder=10) if u assume 2 then there is no chance for bad days.
bad days means -------5 fishes so remaining 10---10/5=2days.
  Ans: 4 good, 1 fair, 2bad. ==== total 7 days.

x+y+z=7--------- eq1
9*x+7*y+5*z=53 -------eq2
multiply eq 1 by 9,
9*x+9*y+9*z=35 -------------eq3
from eq2 and eq3
2*y+4*z=10-----eq4
since all x,y and z are integer i sud put a integer value of y such that z sud be integer in eq 4 .....and ther will be two value y=1 or 3 then z = 2 or 1 from eq 4

for first  y=1,z=2 then from eq1 x= 4
so 9*4+1*7+2*5=53.... satisfied
now for second y=3 z=1 then from eq1 x=3
so 9*3+3*7+1*5=53 ......satisfied
so finally there are two solution of this question
(x,y,z)=(4,1,2) and (3,3,1)...

7) Y catches 5 times more fishes than X. If total number of fishes caught by X and Y is 42, then number of fishes caught by X?
Sol: Let no. of fish x catches=p
no. caught by y =r
r=5p.
r+p=42
then p=7,r=35

8) Three companies are working independently and receiving the savings 20%, 30%, 40%. If the companies work combinely, what will be their net savings?
Sol: suppose total income is 100
so amount x is getting is 80
y is 70
z =60
total=210

but total money is 300
300-210=90
so they are getting 90 rs less
90 is 30% of 300 so they r getting 30% discount

9) The ratio of incomes of C and D is 3:4.the ratio of their expenditures is 4:5. Find the ratio of their savings if the savings of C is one fourths of his income?
Sol: incomes:3:4
expenditures:4:5
3x-4y=1/4(3x)
12x-16y=3x
9x=16y
y=9x/16
(3x-4(9x/16))/((4x-5(9x/16)))
ans:12/19


10) If G(0) = -1 G(1)= 1 and G(N)=G(N-1) - G(N-2) then what is the value of G(6)?
Ans: -1
bcoz g(2)=g(1)-g(0)=1+1=2
g(3)=1
g(4)=-1
g(5)=-2
g(6)=-1

Upcoming Exams Dates and Details- Government, Bank..

Upcoming Notifications:

Banks :

Recruitment Board Post name
SBI Clerks
SBI Associate Bank PO

UPSC :

Post Date Exam Name Last Date
17/05/2014 Civil Services (Preliminary) Exam 2014 16/06/2014
17/05/2014 Indian Forest Services (Preliminary) Exam 2014 16/06/2014
21/06/2014 NDA & NA Exam (II) 2014 21/07/2014
19/07/2014 CDS Exam(II) 2014 18/08/2014

SSC :

Post Date Exam Name Last Date
24/05/2014 Stenographer (Gr C&D) Exam 2014 20/06/2014
19/07/2014 Combined Higher Secondary (10+2) Exam 2014 15/08/2014
09/08/2014 Junior Translator (CSOLS)/Jr Hindi Translator Exam 2014 05/09/2014

Indian Army :
Notification Date Name of The Course Tentative Course of Commencement
.


TNPSC :
Post Date Exam Name Tentative Vacancies
1st Week of March 2014  (To be Notified Later) Group VI Examination (Forest Apprentice) 26
3rd Week of March 2014  (To be Notified Later) Assistant Works Manager 4
2nd Week of April 2014  (To be Notified Later) Combined Civil Services Exam-II (Interview Posts) [Group-II Services] .
4th Week of April 2014 Statistical Inspector 2
2nd Week of May 2014 Group VII-B Service Exam (Executive Officer Gr-III) .
1st Week of June 2014 Group-IA (Asst Conservator of Forests) .
2nd Week of June 2014 Group VIII Service Exam (Executive Officer Gr-IV) .
3rd Week of June 2014 Research Assistant 4
1st Week of July 2014 Group IV Services Examination .
1st Week of August 2014 Combined Civil Services-III Exam (Group III-A) .
2nd Week of August 2014 Assistant Geologist 1
2nd Week of August 2014 Social Case Work Expert 3
1st Week of September 2014 Combined Civil Services Exam-IB (Group-IB Service) .
2nd Week of September 2014 Chemist 3
1st Week of October 2014 Assistant Tester 2
1st Week of November 2014 General Foreman & Technical Assistant 5
1st Week of December 2014 Combined Civil Services Examination (Group-I) .

Head First Java 2nd Edition - Popular Book

 Rs. 625 This is a book that is tailored for Java novices. Ideal for those who are interested in learning Java but have been put off by the complexities of learning the language, Head First Java explores a new way of teaching the same.

Head First Java is aimed at people who are complete novices when it comes to programming with the language, and the book makes the learning experience fun - one that?s filled with innovative and novel measures.

If you?re not a fan of wracking your brain with dull theoretical concepts that put you to sleep, Head First Java can be a welcome addition to your shelf.

The book starts from the fundamentals and progresses to extremely advanced levels, employing an easy-to-learn approach throughout. From distributed programming with RMI and network sockets, object oriented design, and object properties and methods, to graphical user interfaces, Java archives, network connectivity and Java 5.0, the book explores every facet of the programming language with mysteries, puzzles and visuals that will keep you engaged.

The unusual format is based on the theory that the brain needs stimulation to grasp complex issues. The adopted approach brings about a considerable reduction in the time required to grasp the language.

About The Author
Kathy Sierra is a well-known game developer and programming inspector. She has worked as a master trainer for Sun Microsystems. She?s also one of the founders of JavaRanch, the online community of Java programmers.

Other books of hers that she?s co-authored with Bert Bates include

  • Head First Design Patterns
  • Head First EJB
  • Head First Servlets and JSP

Bert Bates has been involved in the area of software development for more than 25 years. He has been the lead developer for many Java certification exams. He is also a consultant in the area of artificial intelligence. He has co-authored the Head First series of books with Kathy Sierra.

Table Of Contents
Introduction
I Breaking the Surface: a quick dip
2 A Trip to Objectville: yes there will be Object
3 Know Your Variables: primitives and references
4 How Objects Behave: object state affects method &Junior
5 Extra-Strength Methods: flow control operations, and more
6 Using the Java Library: so you don't have to write it all yourself
7 Better Living in Objectville: planning for the future
8 Serious Polymorphism: exploiting abstract Classes and interfaces
9 Life and Death of an Object: constructors and memory management
10 Numbers Matter: math, formatting, wrappers; and statics
11 Risky Behavior: exception handing'
12 A Very Graphic Story: intro to GUI, event handling, and inner classes
13, Work on Your Swing: layout managers to subcomponents
14 Saving Object: serialization and I/0
15 Make a Connection: networking sockets and multi-threading
16 Data Structures: collections and genetics
17 Release Your Code: packaging and deployment
18 Distributed Computing: RMI with a dash of serialize, EJE, and Jini
Appendix A: Fatal code kitchen
Appendix B: To 7th Mugs that &diet make it into the rest of the book
Index

Android device emulator shortcuts

Escape - Back button
Home - Home button
F2, PageUp - Menu button
Shift-F2, PageDown - Start button
F3 - Call/Dial button
F4 - Hangup/EndCall button
F5 - Search button
F7 - Power button
Ctrl-F3, Ctrl-KEYPAD_5 - Camera button
Ctrl-F5, KEYPAD_PLUS - Volume up button
Ctrl-F6, KEYPAD_MINUS - Volume down button
KEYPAD_5 DPAD - center
KEYPAD_4, KEYPAD_6 DPAD left, DPAD - right
KEYPAD_8, KEYPAD_2 DPAD up, DPAD - down
F8 - Toggle cell network on/off
F9 - Toggle code profiling (when -trace set)
Alt-ENTER - Toggle fullscreen mode
Ctrl-T Toggle - trackball mode
Ctrl-F11, - KEYPAD_7
Ctrl-F12, - KEYPAD_9

Categories

10th 3i InfoTech Academic Books Accenture ACIO ActiveX ADT Agricultural AIEEE Air Force Algebraic Amdocs Android Answers Application Development Aptitude Aptitude Questions Architectures ASP ATOS B.Sc B.Tech.B.E. Bank Exam BCA BE Board Exam Books break-continue Business Plan C C Programming C# C++ Campus campus interview Candidate profile Capgemini Career CDS Certification CET Challenge Circle Cisco class code Cognizant communication Company Company Profile Competitive Exams computer Computer Networks concentric circles constructor Course Credit Suisse CSS CTS Data Structure DBMS DC Deloitte difficult interview questions dimensions Distributed Computing do while dotNet Download ds Dynamic Web Development e-Admit card Educational engineering entertainment Even Odd Events exam schedule exception for loop fresher GATE general Discussion general knowledge Get Placed Government Job Hall Ticket HCL how to answer How to Prepare HR HR Interview HSC hypertext preprocessor IB IBM IBPS IIT Indian Army Information infosys Intelligence Bureau Internship interview Experience interview questions Interview Tips IntroC IntroC# IntroJava IntroPHP IT J2EE J2ME Java JavaScript jobs Language Books Language Tutorial Languages limit number of objectsJava Limit the number of objects being created in JAVA Linux Linux Administrator Linux Developer Logical Questions loops M Tech M.E. M.Tech M.Tech AND B.Tech Management Management Skills Matrices MBA mca ME microsoft mistakes Mixture Mobile Computing mock questions mock test MySql naukri NDA OOP opening Operating System Oracle paper Persistent PHP php programming php string variables PL/SQL Placement placement guide Placement Paper Placement Process preparing for placement presentation probability Problems Professional program Programming Project Engineer project idea Projects Puzzle qualities Question of the day Questions Quiz Question Recruitment Recruitment Pattern Requirement Result Resume Reviews Screen Sizes Scripting Session Skills Software Software Engineering solved papers Source Code Speed time and distance SQL SSC story Stress Interview Study Material study tips submit resume Synonym TCS Tech Mahindra tech news Technical Books Technical Interview Testing thank you letter Thought Time Table TutC++ Unix questions asked in aptitude and inteviews for MCA UPSC verbal Web Designing Web Developer Website Development What to read while loop Wipro Writing Resume

Receive Quality Tutorials Straight in your Inbox by submitting your Email ID below.