search
Log In

Recent questions tagged geeks-to-geeks

1 vote
1 answer
1
Which of the following condition is sufficient to detect cycle in a directed graph? (A) There is an edge from currently being visited node to an already visited node. (B) There is an edge from currently being visited node to an ancestor of currently visited node in DFS forest. (C) Every node is seen twice in DFS. (D) None of the bove here option B is right, but why not option A?
asked Dec 12, 2018 in Algorithms Gangani_Son 1.7k views
1 vote
2 answers
2
int f(int n) { static int i = 1; if (n ≥ 5) return n; n = n + i; i++; return f(n); } The value returned by f(1) is: (a) 5 (b) 6 (c) 7 (d) 8 need solution with explaination
asked May 26, 2017 in Algorithms Pranav Madhani 251 views
1 vote
2 answers
3
#include<stdio.h> void crazy(int n, int a, int b) { if (n ≤ 0) return; crazy(n-1, a, b + n); printf("%d %d %d\n", n, a, b); crazy(n-1, b, a + n); } int main() { crazy(3, 4, 5); 5 return 0; } (a) 1 4 10 (b) 3 4 5 2 4 8 1 4 10 1 8 6 2 4 8 3 4 5 1 8 6 1 5 9 1 5 9 2 5 7 2 5 7 1 7 7 1 7 7 (c) 1 4 10 (d) 3 4 5 2 4 8 1 5 9 1 8 6 2 5 7 3 4 5 1 7 7 please need solution with explaination
asked May 26, 2017 in Algorithms Pranav Madhani 319 views
0 votes
1 answer
4
#include<stdio.h> int f(int *a, int n) { if(n ≤ 0) return 0; else if(*a % 2 = = 0) return *a + f(a+1, n-1); else return *a - f(a+1, n-1); } int main() { int a[] = {12, 7, 13, 4, 11, 6}; printf("%d", f(a, 6)); return 0; } (a) -9 (b) 5 (c) 15 (d) 19 Need explanation stepwise for solution
asked May 26, 2017 in Algorithms Pranav Madhani 201 views
0 votes
2 answers
5
Which of the following is not O(n^2)? (a) (15^10) * n + 12099 (b) n^1.98 (c) n^3 / (sqrt(n)) (d) (2^20) * n
asked May 25, 2017 in Algorithms Pranav Madhani 2k views
To see more, click for the full list of questions or popular tags.
...