Answer:
The following is the answer to this question:
Explanation:
In the binary digit
is equal to 0 bit
is equal to 1 bit
is equal to 10
Similarly,
=11
Thus,
is equal to
,
,
,
,
,
,
,
,
,
,
Answer:
Explanation:
The following code is written in Java and creates the recursive function to find the longest common substring as requested.
static int lengthOfLongestSubsequence(String X, String Y) {
int m = X.length();
int n = Y.length();
if (m == 0 || n == 0) {
return 0;
}
if (X.charAt(m - 1) == Y.charAt(n - 1)) {
return 1 + lengthOfLongestSubsequence(X, Y);
} else {
return Math.max(lengthOfLongestSubsequence(X, Y),
lengthOfLongestSubsequence(X, Y));
}
}
Explanation:
software must be used by well trained staff.
Answer:
See explaination
Explanation:
Keep two iterators, i (for nuts array) and j (for bolts array).
while(i < n and j < n) {
if nuts[i] == bolts[j] {
We have a case where sizes match, output/return
}
else if nuts[i] < bolts[j] {
this means that size of nut is smaller than that of bolt and we should go to the next bigger nut, i.e., i+=1
}
else {
this means that size of bolt is smaller than that of nut and we should go to the next bigger bolt, i.e., j+=1
}
}
Since we go to each index in both the array only once, the algorithm take O(n) time.