Professional Documents
Culture Documents
1.Which is the parameter that is added to every non static member function when it is
called?
Ans:- this pointer
class some
{
public:
~some()
{
cout<<"some's destructor"<<endl;
}
};
void main()
{
some s;
some.~some();
}
Ans:- Error member identifier expected at s.~some() statement
11. What is the type of the algorithm used in solving the 8 queens problem?
Ans:- Backtracking
16. In selecting the pivot for Quicksort, which is the best choice for optimal
partitioning:
a. the first element of the array
b. the last element of the array
c. the middle element of the array
d. the largest element of the array
e. the median of array
Ans:-
Null Branches
Ans:- 20+1=21
29. Supposewe are sorting an array of eight integers using quicksort, and we have just
finished the first partitioning with array looking like this:
2 5 1 7 9 12 11 10
which statement is correct?
a.the pivot could be either the 7 or the 9
b.the pivot could be the 7, but it is not the 9
c.the pivot is not 7, but it could be the 9
d.neither the 7 nor the 9 is the pivot
Ans:- a
Ans: (n1)^n2
x = unsafe (f(&x));
printf (“%d”, x);
x = safe (f(&x));
printf (“%d”, x);
}
6. Assuming that a pointer takes 2 bytes of memory, what would be the output for the
following program
void main(int argc, char argv[])
{
int a=4, b=-2;
char *cp= “abcdef”;
int grade[5] = {3, 2, 1, 0, -1};
printf(“a.%d\n”, -b/a);
printf(“b.%d\n”, ++a + b++);
printf(“c.%d\n”, *grade+2);
printf(“d.%d\n”, cp[3]);
printf(“e.%d\n”, strlen(cp));
printf(“f.%d\n”, sizeof(cp));
}
Ans: printf(“a.%d\n”, -b/a); a.0
printf(“b.%d\n”, ++a + b++); b.3
printf(“c.%d\n”, *grade+2); c.1
printf(“d.%d\n”, cp[3]); d.101
printf(“e.%d\n”, strlen(cp)); e.6
printf(“f.%d\n”, sizeof(cp)); f.2
Ans: ERROR
Ans: value: :1
value: :2
10. In the given binary tree, using array you can store the node at 4 at which location?
1
11. Convert the expression ((A+B) * C-(D-E)^(F+G)) to equivalent Prefix and Postfix
notations.
Ans: Prefix: ^ - * + ABC – DE + FG
Postfix: AB + C * DE - - FG + ^
D T
B M X
A C L K Y
P
(a) What is the result of a postorder traversal of the above tree?
Ans: ACBDIPKMYXTG
(b) What is the result of a inorder traversal of the above tree?
Ans: ABCDGIMKPXY
(c) Is the above tree a binary search tree? Why or why not?
Ans: Yes, since it has 2 or less than 2 child node of each node.
13. What is the order of each of the following tasks? (Choose from O(1), O(log2 n),
O(n), O(n log2 n), O(n2), O(2n); each order may appear more than once.)
(a) Pooping an item off a stack containing n items.
(b) Performing a Towers of Hanoi algorithm with n disks.
(c) Using quick sort to sort an array of n integers, in the average case.
(d) Using quick sort to sort an array of n integers, in the worst case.
(e) Inserting a single item into a binary search tree containing n items, in the
average case.
(f) Performing a bubble sort on an array of n integers, in the worst case.
(g) Displaying all n elements in a sorted linked list.
(h) Performing a binary search of a sorted array of n strings, in the worst
case.
1. ab*a A. a
2. (ab)*a B. abe
3. [a-e]{2,4} C. bbacd
4. [a-e][a-e]{4,5} D. abbbbba
15. Write a query to get the same rows from two tables A and B
Ans: select * from Sailors s, Boats b where s.sid=b.bid.
16. Write a query to list the maximum salary in such departments which have more
than two employees from table EMP which has columns empno, ename, deptno,
salary.
17. Write a query to list the ename and his manager name from table Emp which has
columns empno, ename, mgrno
Ans: select e1.ename, e2.ename from emp e1,e2 where e1.mgrno=e2.empno.
18. Write a query to produce the following output empno, ename, deptname from two
tables emp (empno, ename, deptno) and dept (deptno, deptname)
Ans: select empno, ename, deptname from emp e, dept d where e.deptno=d.deptno;
19. Write a query to find the max salary from emp (empno, ename, salary) without
using max function.
8
1
3
1
1 6
0
5
9
1
1 search, starting from vertex 1, and if
If this graph is searched by depth-first
neighbours are searched in numerical order, what will be the order in which the nodes
are visited? (Note: If you use an explicit stack for depth-first search, then the nodes
are visited when they come off the stack, so they have to pushed in reverse numerical
order to be searched in numerical order)
Section C
1. A person with some money spends 1/3 for cloths, 1/5 of the remaining for food and
1/4 of the remaining for travel. He is left with Rs.100/-. How much did he have with
him in the beginning?
Ans: x(1-(1/3+1/5+1/4))=100
Rs.461.50/-
2. Grass in lawn grows equally thick and in uniform rate. It takes 24 days for 70 cows
and 60 days for 30 cows to eat the whole of the grass. How many cows are needed to
eat the grass in 96 days?
Ans: 18
3. There is a safe with 5 digit number as the key. The 4th digit is 4 greater than the 2nd
digit, while the 3rd digit is 3 less than the 2nd digit. The 1st digit is thrice the last digit.
There are 3 pairs whose sum is 11.
Ans: 29256
4. In Mr. Mehta’s family, there are one grandfather, one grandmother, two fathers,
two mothers, one father-in-law, one mother-in-law, four children, three grandchildren,
one brother, two sisters, two sons, two daughters, and one daughter-in-law. How
many members are there in Mr Mehta’s family? (Give minimal possible number)
Ans:
5. Anshul was studying for his examinations and the lights went off. It was around
1:00 AM. He lighted two uniform candles of equal length but one thicker than the
other. The thick candle is supposed to last six hours and the thin one two hours less.
When he finally went to sleep, the thick candle was twice as long as the thin one. For
how long did Anshul study in candle light?
Ans: 3 hrs.
7. The difference between the compound interest payable half yearly and the simple
interest on a certain sum lent out at 10% p.a for 1 year is Rs.25. What is the sum?
(a) Rs.15000 (b) Rs.12000 (c) Rs.10000 (d) None of these
Ans:
8. What is the smallest number by which 2880 must be divided in order to make it
into a perfect square?
(a) 3 (b) 4 (c) 5 (d) 6
Ans: (c) 5
9. A father is 30 years older than his son, however, he will be only thrice as old as the
son after 5 years. What is father’s present age?
(a) 40 yrs (b) 30 yrs (c) 50 yrs (d) None of these
Ans: (a) 40 yrs
10. 5 men or 8 women do equal amount of work in a day. A job requires 3 me and 5
women to finish the job in 10 days. How many woman are required to finish the job in
14 days?
(a) 10 (b) 7 (c) 6 (d) 12
(11-15) Verbal Based
I felt the wall of the tunnel shiver. The master alarm squealed through my earphones.
Almost simultaneously, Jack yelled down to me that there was a warning light on…
Fleeting but spectacular sights snapped into and out of the view, the snow, the shower
of debris, the moon, looming close and big, the dazzling sunshine for once unfiltered
by layers of air. The last twelve hours before re-entry were particularly bone-chilling.
During this period, I had to go up into the command module. Even after the fiery re-
entry and splashing down in 810 water in the south pacific, we could still see our
frosty breath inside the command module.
11. Which one of the following reasons would one consider as more possible for the
warning lights to be on?
a. There was a shower of debris.
b. Jack was yelling.
c. A catastrophe was imminent.
d. The moon was looming close and big.
Ans: b.
12. The statement that the dazzling sunshine was “for once unfiltered by layers of air”
means
a. That the sun was very hot.
b. That there was no strong wind.
c. That the air was unpolluted.
d. None of the above.
Ans:
13. The word ‘Command Module’ used twice in the given passage indicates perhaps
that it deals with,
a. An alarming journey.
b. A commanding situation.
c. A journey into outer space.
d. A frightful battle.
Ans: