pop

infolinks

50 Aptitude Questions

  
1. If n = 1 + x, where x is the product of four consecutive positive integers, then which of the following is/are true?
1. n is even                2. n is prime              3. n is a perfect cube                        4. n is odd.

2. A ladder is touching a wall and the base of the ladder is 15 m away from the wall. When the ladder is pulled away from the wall by 2 m, it becomes parallel to the ground. Find the distance of the initial point of contact of the ladder and the wall from the ground.
1. 10m                        2. 8m                          3. 12m                                    4. 17 m

3. Find the number of numbers from 1 to 100 that are divisible by 2 or 3 or 5.
1. 68                           2. 74                           3. 71                           4. 103

4. In a party of 40 people, everyone shakes hands with all the other persons exactly once. What is the total number of handshakes happening?
1. 780                         2. 820                         3. 40!                          4. None of these

5. 273– 272 – 271 is the same as
1. 269                           2. 270                           3. 271                           4.272

6. How many 3 digit even numbers can be formed such that if one of the digits is 5, then the next digit is 7?
1. 5                              2. 9                              3. 365                         4. 15

7. Find the least number which when divided by 5 and 9 will leave remainders of 3 and 7 respectively.
1. 47                           2. 88                           3. 43                           4. 92

8. In a 300m race, A beats B by 24m or 6 seconds. Find the time taken by A to finish the race.
1. 75 sec                     2. 81 sec                     3. 69 sec                     4. 60 sec

9. A tank can be filled in x hours, but because of a leak, it takes 40 hours to fill the tank. Find x if the leak can empty the tank in 60 hours.
1. 30                           2. 24                           3. 36                           4. 20

10. X, Y and Z have a total of Rs.224 with them. If their shares are increased by Rs.5, 9 and 2 respectively, then the ratio of their amounts is 3:2:1. Find the original amount with Y.
1. Rs.71                      2. Rs.115                    3. Rs.38                      4. Rs.120

11. A number is decreased by 20% and then increased by 40%.Find the percentage change in the number.
1. 20                           2. 12                           3. 60                           4. 40

12. The price of 4 apples and 6 mangoes is Rs.62 and the price of 6 apples and 4 mangoes is Rs.58. Find the price of 3 apples and 5 mangoes.
1. Rs.45                      2. Rs.34                      3. Rs.60                      4. Rs.50

13. A die and a coin are tossed simultaneously. The probability that the die showing a prime number and the coin showing a head is
1. ½                             2. 1/3                          3. 2/3                          4. ¼

14. In what ratio should a class with average marks 34 be mixed with a class with average 22, so that the average of the mixed class is 31.
1. 1:3                          2. 3:1                          3. 2:5                          4. 5:7

15. Find the value of [(0.8)3 – (0.2)3]/[(0.8)2 + 0.16 + (0.2)2].
1. 1                              2. 0.6                          3. 0.64                                    4. 0.5

16. Find the number of divisors of 36 excluding 1 and 36.
1. 13                           2. 11                           3. 10                           4. 7

17. Find the greatest
1. 21/2                          2. 41/4                          3. 61/6                          4. 31/3

18. In how many ways can a person put 4 letters in 4 envelopes such that exactly three letters are in their respective envelopes?
1. 23                           2. 18                           3. 1                              4. 0

19. How many numbers can be formed between 200 and 1200, using the digits 0, 1, 2 and 3, such that there is no repetition?
1. 48                           2. 16                           3. 32                           4. 14

20. If 6x2+ 6y2 = 13xy, find x:y.
1. 2:3                          2. 3:2                          3. 1:2                          4. 4:5

21. Walking at 3/4thof his regular speed, Sanjay is 16 minutes late in reaching the office. Find the usual time that he takes to reach the office.
1. 48 min                    2. 60 min                    3. 36 min                    4. 42 min

22. A train moves at a constant speed of 120 km/hr for one km and at 40 km/hr for the next km. Find the average speed of the train.
1. 60 kmph                2. 80 kmph                3. 64 kmph                4. 90 kmph

23. A can finish a piece of work in 10, while B can finish it in 20 days. They start working together and after 5 days, A leaves the job. Find the number of days in which B will finish the remaining work.
1. 2                              2. 3                              3. 4                              4. 5


24. At what exact time between 5 and 6 will the two hands of a clock be at an angle of 1800.
1. 5.45                                    2. 5.56                                    3. 5.58                                    4. None of these

25. An integer is chosen at random from 1 to 100. Find the probability that it is a multiple of 5 or 8.
1. 3/10                                    2. 7/20                                    3. 2/5                          4. ½

26. A ship went on a voyage. After it had traveled 180 miles a plane started with 10 times the speed of the ship. Find the distance when they meet from starting point.
1. 190                         2 .200                         3. 210                         4. 220

27. Three friends divided some bullets equally. After all of them shot 4 bullets the total number of bullets remaining is equal to the bullets each had after division. Find the original number divided.
1. 24                           2. 20                           3. 16                           4. 18


28. A hotel has 10 floors. Which floor is above the floor below the floor, below the floor above the floor, below the floor above the fifth?
1. 4th                           2. 5th                           3. 6th                           4. 7th

29. Two trains starting at same time, one from Bangalore to Mysore and other in opposite direction arrive at their destination 1 hr and 4 hours respectively after passing each other. How much faster is one train from other?
1. 4 times                   2. thrice                      3. twice                      4. Cannot be determined

30. Father's age is three years more than three times the son's age. After three years, father's age will be ten years more than twice the son's age. What is the father's present age?
1. 30                           2. 33                           3. 36               4. 39


                                                     

programming interview questions 3


Problem 57 Suppose that there are 101 players entered in a ”single elimination” tennis tournament. In such a tournament any player who loses a match must drop out, and every match ends in a victory for some player - there are no ties. In each round of the tournament, the players remaining are matched into as many pairs as possible, but if there is an odd number of players left, someone receives a bye (which means an automatic vitory for this player in this round). Enough rounds are played until a single player remains who wins the tournament. How many matches are played in total?
Problem 58 The ”parity” of a number refers to whether it contains an odd or even number of 1-bits. The number has ”odd parity”, if it contains odd number of 1-bits and is ”even parity”, if it contains even number of 1-bits. Write a C function to find the parity of an unsigned integer.
Problem 59 Calculate: ab mod m for large values of a, b and m using an efficient algorithm. Value ranges: a ∈ [0,2147483647], b ∈ [2147483647], m ∈ [1,46340].
Problem 60 Lets assume we have a rat maze as represented by the following n×m matrix where S is the start location and F is the end location.
S
0
0
0
0
0
1
1
0
0
0
0
1
0
1
0
0
0
1
0
1
0
0
0
0
1
0
1
0
0
1
0
0
0
1
0
0
1
1
1
1
F
The idea (as with any rat maze) is to traverse from S to F. The matrix can have only 0 and 1 as values. 1 represents a path that can be taken and 0 represents a blocked path. We can make the following assumption: S will always be (0,0) and F will always be (n,m).
How to find the shortest (or longest) path from S to F without actually traversing all the possible paths?
Problem 61 If two of the below statements are false, what chance is there that the egg came first?
1.    The chicken came first.
2.    The egg came first.
3.    Statement I is false and Statement II is true.
Problem 62 The following program, when run,
#include < stdio.h > main()
{


int a,b,c; int count = 1 ;
for (b=c=10;a="- FIGURE?, UMKC,XYZHello Folks,\
TFy!QJu ROo TNn(ROo)SLq SLq ULo+\
UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^\
NBELPeHBFHT}TnALVlBLOFAkH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!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!! !!!!!!!!!!!!!!
!!!!!!!!!!!!
!!!!!!!!!!!!
!!!!!!!!!!!!
!!!!!!!!
!!!!!!
!!!!
Can you figure out the logic used in the program?
Problem 63 What are the next few numbers in the sequence 1, 20, 33, 400, 505, 660, 777 , 8000, 9009, 10100, 11121 ?
Problem 64 You are travelling in the jungles of Africa, when you are caught by a tribe of barbarians. They allow you to choose between death or solving their great challenge:
You are blindfolded and taken to a room, where you are asked to kneel. You feel hundreds of circular discs lying in front of you. You are told that one side of each disc is painted red, and the other, green. There are exactly 129 discs that currently are red side up. You have to divide the discs into two groups, such that each group has the same number of discs showing the red colour. Obviously, no peeking allowed.
Problem 65 Given an array of strings, you need to sort it using ”qsort” function provided by C. You may use the strcmp function provided by the C library.
#define SIZEOF(arr) ( sizeof(arr)/sizeof(arr [0])) int main()
{ char *arr[]={"abc","def","abcd"}; int i;
/*
* code to sort..
*...
*... */
for(i=0;i &lt SIZEOF(arr);i++)
printf("%s\n",arr[i]);
}
Problem 66 Here is a game one can buy in most toy stores, it’s called Hi-Q (or Brainvita). 32 pieces are arranged on a board as shown below:


X
X
X




X
X
X


X
X
X
X
X
X
X
X
X
X
O
X
X
X
X
X
X
X
X
X
X


X
X
X




X
X
X


The rules are as follows:
    In the beginning, only the centre position is unoccupied.
    A piece is allowed to move by jumping over one of it’s neighbours into an empty space.
    Diagonal jumps are not permitted.
    When a piece is jumped over, it is removed from the board.
Write an algorithm which determines a series of jumps so that all of the pieces except one are eventually removed, and the final piece ends up at the center position.
Problem 67 Suppose we wish to multiply four matrices of real numbers M1×M2×M3×M4 where M1 is 10 by 20, M2 is 20 by 50, M3 is 50 by 1, and M4 is 1 by 100. Assume that the multiplication of a p × q matrix by a q × r matrix requires pqr scalar operations, as it does in the usual matrix multiplication algorithm.
Find the optimal order in which to multiply the matrices so as to minimize the total number of scalar operations. How would you find this optimal ordering if there are an arbitrary number of matrices?
Problem 68 Describe a O(nlgn) time algorithm that, given a set S of n real numbers and another real number x, determines whether or not there exist two elements in S whose sum is exactly x.
Problem 69 Given an array of n numbers a1...an, find the second minimum number in n+lgn comparisons. You can only compare elements and you can’t assume anything about the range of values of the numbers.
Problem 70 An element in a sorted array can be found in O(lgn) time via binary search. But suppose I rotate the sorted array at some pivot unknown to you beforehand. So for instance, 1 2 3 4 5 might become 3 4 5 1 2. Now devise a way to find an element in the rotated array in O(lgn) time.
Problem 71 Write a program that will display a ”spiral” of n×n numbers, using constant space (no arrays allowed). For example, here’s what the spiral looks like for n = 10:
99            98           97           96           95           94           93           92           91           90
64                63            62           61           60           59           58           57           56           89
65                36            35           34           33           32           31           30           55           88
66                37            16           15           14           13           12           29           54           87
67                38            17           4              3              2              11           28           53           86
68                39            18           5              0              1              10           27           52           85
69                40            19           6              7              8              9              26           51           84
70                41            20           21           22           23           24           25           50           83
71                42            43           44           45           46           47           48           49           82
72                73            74           75           76           77           78           79           80           81
Problem 72 How do you efficiently find the largest repeating string and the number of times it repeats in a given string? For example, given string "abc fghi bc kl abcd lkm abcdefg", the function should return string "abcd" and the count of 2.
Problem 73 There are 4 buckets of 9 coins each. Real coins weigh one gram each, and fake coins weigh 2 grams each. Each bucket is either fake (contains only fake coins) or real (contains only real coins). Given a weighing machine, how can you determine all the buckets that are fake with just one weighing?
Problem 74 Given a binary tree, how do you verify whether it is a binary search tree?
Problem 75 Write a C function, which takes a number n and positions p1 and p2 and returns whether the the bits at positions p1 and p2 are the same or not.
Problem 76 Write a C function, which takes two numbers m and n (representing sets of elements; i’th bit is 1 if i is an element of the set), and checks whether m is a subset of n or not.
Problem 77 A majority element in an array A, of size n is an element that appears more than n/2 times (and hence there is at most one such element) Write a function which takes an array and emits the majority element (if it exists), otherwise prints NONE. Bonus: solve the problem in O(n) time.

For example, the majority element in 3 3 4 2 4 4 2 4 4 is 4, while the sequence 3 3 4 2 4 4 2 4 has no majority element.