@@ -62,10 +62,10 @@ the regular expression.
62
62
and give the minimum no of comparisons needed on an array of size N to do the
63
63
same.
64
64
65
- 17 . Given an array of size n ,containing every element from 1 to n+1, except one.
65
+ 17.Given an array of size n ,containing every element from 1 to n+1, except one.
66
66
Find the missing element.
67
67
68
- 18 . Two trains enter at the opposite sides of a tunnel of length L with speeds 'V'.
68
+ 18.Two trains enter at the opposite sides of a tunnel of length L with speeds 'V'.
69
69
A particle enters the tunnel at the same time with a speed 'v' and it vibrates in
70
70
the tunnel[ i.e. if it reaches the end of the tunnel then it comes back] . What is the
71
71
position of the particle by the time the 2 trains meet?
@@ -74,13 +74,13 @@ position of the particle by the time the 2 trains meet?
74
74
number which is repeated in O(n) time .How do you proceed with the same with
75
75
floating numbers from 0 to 1 instead of 1 to n?
76
76
77
- 20 . Design a data structure to represent the movement of a knight on a chess
77
+ 20.Design a data structure to represent the movement of a knight on a chess
78
78
board
79
79
80
- 21 . Write an algorithm to traverse a knight covering all the squares on a
80
+ 21.Write an algorithm to traverse a knight covering all the squares on a
81
81
chessboard starting at a particular point.
82
82
83
- 22 . What is wrong with this class, assuming that this is its complete interface?
83
+ 22.What is wrong with this class, assuming that this is its complete interface?
84
84
85
85
class C {
86
86
@@ -112,7 +112,7 @@ copied]. Now, the original goes out of scope, what happens to the copy? [pointer
112
112
dangles] . How would you fix it?
113
113
[ also, that delete p should be delete[ p since p was allocated with the array new]
114
114
Assuming that swap() and copy construction are part of your interface for class C,
115
- what's the cookie-cutter pattern for operator= that uses them?
115
+ whats the cookie-cutter pattern for operator= that uses them?
116
116
answer:
117
117
118
118
C& C: perator =(const C &rhs) {
@@ -124,21 +124,23 @@ return *this;
124
124
}
125
125
]]
126
126
127
- 23 . “ given two lists write a function which returns a list which is the intersection
127
+ 23.given two lists write a function which returns a list which is the intersection
128
128
of the two lists.the original lists should remain same.
129
129
(Intersection – if first list is say,1,20 3,45 and second list is 3,24 ,45,90,68 then
130
130
intersection should be 3,45 )
131
131
132
- 24 . Given two nodes of a binary tree find the closest ancestor of the two nodes.
132
+
133
+ 24.Given two nodes of a binary tree find the closest ancestor of the two nodes.
133
134
Note: consider binary tree and binary search tree also.
134
135
135
- 25 . Given an array all of whose elements are positive numbers, find the maximum
136
+
137
+ 25.Given an array all of whose elements are positive numbers, find the maximum
136
138
sum of a subsequence with the constraint that no 2 numbers in the sequence
137
139
should be adjacent in the array.
138
140
i) 3 2 7 10 should return 13 (sum of 3 and 10)
139
141
ii) 3 2 5 10 7 should return 15 (sum of 3, 5 and 7)
140
142
141
- 26 . Given a Binary Search Tree, write a program to print the kth smallest element
143
+ 26.Given a Binary Search Tree, write a program to print the kth smallest element
142
144
without using any static/global variable. You can’t pass the value k to any function
143
145
also.
144
146
0 commit comments