How many switch cases are needed to find the maximum of 3 numbers?
What is the best case time complexity of Insertion sort?
What kind of algorithm is the 0/1 knapsack problem?
For the given array arr = {2, 6, 1}, what is the pivot returned after partitioning?
Which of the following problems is not solved using a backtracking algorithm?
Which data structure requires the least time complexity to give the sum of a subarray of an array?
Given an array arr = {45, 75, 88, 90, 94, 99, 200} and a key = 99, what are the mid values (corresponding array elements) in the first and second levels of recursion in binary search?
You are given infinite coins of denominations c1, c2, c3,...,cn and a sum S. The coin change problem is to find the minimum number of coins required to get the sum S. This problem can be solved using which algorithm?
Consider the following recursive implementation used to find the length of a string:
#include<stdio.h>
int recursive_get_len(char *s, int len)
{
if(s[len] == 0)
return 0;
return 1 + recursive_get_len(s, len+1);
}
int main()
{
char *s = "abcdef";
int len = recursive_get_len(s,0);
printf("%d",len);
return 0;
}
Consider the following recursive implementation to find the sum of digits of a number:
#include<stdio.h>
int recursiveSumOfDigits(int n)
{
if(n == 0)
return 0;
return (n % 10) + recursiveSumOfDigits(n / 10);
}
int main()
{
int n = 1201;
int ans = recursiveSumOfDigits(n);
printf("%d",ans);
return 0;
}
OnSite
1 Openings
FullTime
Posted 17 days ago