Login
Register
Dark Mode
Brightness
Profile
Edit Profile
Messages
My favorites
My Updates
Logout
Webpage for Algorithms
Recent questions tagged algorithms
0
votes
0
answers
1351
DFS BFS
Please give an example i didn't get it The depth of any DFS tree rooted at a vertex is at least as much as the depth of any BFS tree rooted at the same vertex.
Please give an example i didn't get itThe depth of any DFS tree rooted at a vertex is at least as much as thedepth of any BFS tree rooted at the same vertex.
Rishav Kumar Singh
800
views
Rishav Kumar Singh
asked
Aug 2, 2018
Algorithms
depth-first-search
breadth-first-search
algorithms
+
–
1
votes
2
answers
1352
Sorting
Could a binary search tree be built using o(n lg n) comparisons in the comparison model? Explain why or why not.
Could a binary search tree be built using o(n lg n) comparisons in the comparisonmodel? Explain why or why not.
Ravi Dubey
859
views
Ravi Dubey
asked
Aug 2, 2018
Algorithms
sorting
algorithms
time-complexity
test-series
+
–
0
votes
2
answers
1353
Algorithms doubt
F(n)=n^(sin n) G(n)=n^(cos n) Why they are non comparable.
F(n)=n^(sin n)G(n)=n^(cos n)Why they are non comparable.
Shashi Shekhar 1
351
views
Shashi Shekhar 1
asked
Aug 1, 2018
Algorithms
asymptotic-notation
algorithms
+
–
2
votes
2
answers
1354
MadeEasy Test Series: Algorithms - Dynamic Programming
Consider two strings A = “abbaccda” and B = “abcaa” consider "x"be length of the longest common subsequence between A and B and “y” be the number of distinct such longest common subsequences between A and B. Then 10x+ 2y is ________.
Consider two strings A = “abbaccda” and B = “abcaa” consider "x"be length of the longest common subsequence between A and B and “y” be the number of distinct ...
talha hashim
2.1k
views
talha hashim
asked
Aug 1, 2018
Algorithms
algorithms
dynamic-programming
made-easy-test-series
longest-common-subsequence
+
–
0
votes
0
answers
1355
Master theorem rules
On which of the following recurrence relation Master Theorem cannot be applied? a) T(n)=2T(n/2)+nlogn b) T(n)=T(n/2)+1 c) T(n)=8T(n/2)+logn d) T(n)=7T(n/4)+n^2
On which of the following recurrence relation Master Theorem cannot be applied?a) T(n)=2T(n/2)+nlognb) T(n)=T(n/2)+1c) T(n)=8T(n/2)+lognd) T(n)=7T(n/4)+n^2
Sandy Sharma
801
views
Sandy Sharma
asked
Aug 1, 2018
Algorithms
algorithms
master-theorem
+
–
0
votes
2
answers
1356
time complexity
main() { int i,count; for (i=1; i<=n; i++) { for(i=1; i<=(n*n); i++) { for(i=1; i<=(n*n*n); i++) { count++; } } } } What will be the time complexity of the given program?
main() { int i,count; for (i=1; i<=n; i++) { for(i=1; i<=(n*n); i++) { for(i=1; i<=(n*n*n); i++) { count++; } } } }What will be the time complexity of the given program?
Bhunesh_Singh
314
views
Bhunesh_Singh
asked
Jul 31, 2018
Algorithms
time-complexity
algorithms
+
–
2
votes
1
answer
1357
Self doubt algorithms
In coremen it is given that $\log^kn$=$(\log n)^k$ $\log\log n$ is not equal to $\log^2n$ i understood it with example please correct me if I am wrong .
In coremen it is given that$\log^kn$=$(\log n)^k$$\log\log n$ is not equal to $\log^2n$ i understood it with exampleplease correct me if I am wrong .
Prince Sindhiya
313
views
Prince Sindhiya
asked
Jul 31, 2018
Algorithms
algorithms
logarithmic-function
+
–
3
votes
1
answer
1358
DFS Algo
Is following statement true/false? A DFS of a directed graph always produces the same number of tree edges, i.e., independent of the order in which vertices are considered for DFS. Answer is FALSE please explain
Is following statement true/false? A DFS of a directed graph always produces the same number of tree edges, i.e., independent of the order in which vertices are considere...
Rishav Kumar Singh
2.0k
views
Rishav Kumar Singh
asked
Jul 30, 2018
Algorithms
depth-first-search
algorithms
+
–
1
votes
1
answer
1359
MIT_algorithms
I don't understand How?
I don't understand How?
Rishav Kumar Singh
519
views
Rishav Kumar Singh
asked
Jul 30, 2018
Algorithms
time-complexity
algorithms
mit-quiz
+
–
1
votes
1
answer
1360
Massachusetts Institute of Technology Professors Ron Rivest and Srini Devadas
There exists a comparison sort of 5 numbers that uses at most 6 comparisons in the worst case. True or False and Why?
There exists a comparison sort of 5 numbers that uses at most 6 comparisons in the worst case.True or False and Why?
Rishav Kumar Singh
290
views
Rishav Kumar Singh
asked
Jul 29, 2018
Algorithms
algorithms
sorting
true-false
+
–
2
votes
3
answers
1361
sorting
When the recurrence relation for both are same , why they both getting different result? Q1. In a modified merge sort, the input array is splitted at a position one-third of the length(N) of the array. What is the worst case time complexity of this merge sort? ANSWER: recurrence ... is If for first case it is N(log3/2N) then for second case also it should be N(log4/3N) BUT its not. WHY?
When the recurrence relation for both are same , why they both getting different result?Q1. In a modified merge sort, the input array is splitted at a position one-third ...
Rishav Kumar Singh
1.4k
views
Rishav Kumar Singh
asked
Jul 29, 2018
Algorithms
algorithms
sorting
time-complexity
+
–
3
votes
0
answers
1362
GeeksForGeeks
Maximum Subarray Sum problem is to find the subarray with maximum sum. For example, given an array {12, -13, -5, 25, -20, 30, 10}, the maximum subarray sum is 45. The naive solution for this problem is to calculate sum of all subarrays starting with every element and return ... complexity using Divide and Conquer. A O(n) B O(nLogn) C O(Logn) D O(n2) Correct answer is B. O(nLogn) How?
Maximum Subarray Sum problem is to find the subarray with maximum sum. For example, given an array {12, -13, -5, 25, -20, 30, 10}, the maximum subarray sum is 45. The nai...
Rishav Kumar Singh
6.8k
views
Rishav Kumar Singh
asked
Jul 27, 2018
Algorithms
divide-and-conquer
algorithms
+
–
1
votes
0
answers
1363
Algorithms
Solve the recurrence relation $T(n) = T(\sqrt{n}) + n$
Solve the recurrence relation $T(n) = T(\sqrt{n}) + n$
gauravkc
688
views
gauravkc
asked
Jul 27, 2018
Algorithms
algorithms
asymptotic-notation
time-complexity
+
–
0
votes
1
answer
1364
Recurrence Relation
Solve the following recurrence relation :- N(h)=N(h−1)+N(h−2)+1
Solve the following recurrence relation :-N(h)=N(h−1)+N(h−2)+1
bts
549
views
bts
asked
Jul 27, 2018
Programming in C
recurrence-relation
time-complexity
algorithms
+
–
0
votes
0
answers
1365
How to print the row having maximum no of 1's in a bit-array ?
If we have a n*n Bit-Array in which we have only 1's and 0's filled . Constraint is that in every row , 0 comes before 1 , so how to find the index of the row which has maximum no of 1's
If we have a n*n Bit-Array in which we have only 1's and 0's filled . Constraint is that in every row , 0 comes before 1 , so how to find the index of the row which has m...
radha gogia
289
views
radha gogia
asked
Jul 26, 2018
Algorithms
algorithms
+
–
1
votes
1
answer
1366
UBC Intermediate Algorithm Design and Analysis (CPSC 320) Summer 2009
Analyze the runtime of the following piece of code. Give a bound using Θ notation. function Pesky(n) r ←0; for i ←1 to n do for j ←1 to i do for k ← j to i+j do r ←r + 1; return r;
Analyze the runtime of the following piece of code. Give a bound using Θ notation.function Pesky(n)r ←0;for i ←1 to ndo for j ←1 to ido for k ← j to i+jdo r ←r...
Rishav Kumar Singh
423
views
Rishav Kumar Singh
asked
Jul 26, 2018
Algorithms
asymptotic-notation
algorithms
+
–
3
votes
2
answers
1367
Test-series algorithms
What is the time complexity of following function fun()? Assume that log(x) returns log value in base 2. void fun() { int i, j; for (i=1; i<=n; i++) for (j=1; j<=log(i); j++) printf("GeeksforGeeks"); }
What is the time complexity of following function fun()? Assume that log(x) returns log value in base 2.void fun() { int i, j; for (i=1; i<=n; i++) for (j=1; j<=log(i); j...
Rishav Kumar Singh
3.0k
views
Rishav Kumar Singh
asked
Jul 25, 2018
Algorithms
asymptotic-notation
algorithms
test-series
+
–
1
votes
1
answer
1368
GeeksForGeeks analysis-of-algorithms-question-19-2
Consider the following two functions. What are time complexities of the functions? int fun1(int n) { if (n <= 1) return n; return 2*fun1(n-1); } int fun2(int n) { if (n <= 1) return n; return fun2(n-1) + fun2(n-1); } (A) O(2^n) for both fun1 ... O(2^n) for fun2() (C) O(2^n) for fun1() and O(n) for fun2() (D) O(n) for both fun1() and fun2()
Consider the following two functions. What are time complexities of the functions?int fun1(int n){ if (n <= 1) return n; return 2*fun1(n-1);}int fun2(int n){ if ...
Rishav Kumar Singh
6.3k
views
Rishav Kumar Singh
asked
Jul 25, 2018
Algorithms
asymptotic-notation
algorithms
+
–
1
votes
2
answers
1369
Self Doubt
<!--StartFragment --> void fun(int n, int arr[]) { int i = 0, j = 0; for(; i < n; ++i) while(j < n && arr[i] < arr[j]) j++; } In this question the inner loop runs n times at most because j is not ... wont the outer loop also run n times (incrementing and checking conditions in while) and making the total time complexity to be O(n2)?? <!--EndFragment -->
<! StartFragment >void fun(int n, int arr[]){ int i = 0, j = 0; for(; i < n; ++i) while(j < n && arr[i] < arr[j]) j++;} In this question the inne...
harishrajora
1.7k
views
harishrajora
asked
Jul 23, 2018
Algorithms
algorithms
time-complexity
+
–
0
votes
0
answers
1370
Introduction to Algorithm - Cormen
I didn't understand Big-O notation: This is CORMEN exercise problem - 3.1-2 Solution link: https://www.csee.umbc.edu/~nam1/TA/HWSols/hw1sol.pdf
I didn't understand Big-O notation: This is CORMEN exercise problem - 3.1-2Solution link: https://www.csee.umbc.edu/~nam1/TA/HWSols/hw1sol.pdf
Swapnil Naik
667
views
Swapnil Naik
asked
Jul 23, 2018
Algorithms
algorithms
asymptotic-notation
+
–
0
votes
0
answers
1371
How many times GO is printed ?
int main() { int i = -5; While(i<=5){ if(i>=0) break; else { i++; continue; } printf("GO"); } return 0; }
int main() { int i = -5; While(i<=5){ if(i>=0) break; else { i++; continue; } printf("GO"); }return 0;}
arya_stark
374
views
arya_stark
asked
Jul 23, 2018
Programming in C
algorithms
programming
+
–
0
votes
1
answer
1372
Self doubt
Is np Completeness is there in syllabus ? ,as it is not mentioned in syllabus.
Is np Completeness is there in syllabus ?,as it is not mentioned in syllabus.
Prince Sindhiya
262
views
Prince Sindhiya
asked
Jul 23, 2018
Algorithms
algorithms
syllabus
+
–
1
votes
0
answers
1373
Testbook Algorithm-1 Q6
Iterated logarithmic function is defined as Which of the following is/are TRUE ? (i) log∗n=O(log(logn)) (ii) (log∗n)!=O(logn) (iii) (log∗n)^n=O((logn)!) i and ii only i and iii only ii and iii only i, ii and iii
Iterated logarithmic function is defined asWhich of the following is/are TRUE ?(i) log∗n=O(log(logn))(ii) (log∗n)!=O(logn)(iii) (log∗n)^n=O((logn)!)i and ii onlyi a...
Sandy Sharma
182
views
Sandy Sharma
asked
Jul 23, 2018
Algorithms
algorithms
+
–
0
votes
1
answer
1374
Introduction To Algorithms
T(N) = 3T(N/4) + NlogN T(N) = 2T(N/2)+ NlogN Master theorem applicable to this ??
T(N) = 3T(N/4) + NlogNT(N) = 2T(N/2)+ NlogNMaster theorem applicable to this ??
jatin khachane 1
1.4k
views
jatin khachane 1
asked
Jul 23, 2018
Algorithms
algorithms
master-theorem
recurrence-relation
+
–
0
votes
0
answers
1375
#avl tree
what is the worst case possible height of an avl tree ??? https://www.geeksforgeeks.org/practice-questions-height-balancedavl-tree/ how does 1.44*logn comes ????
what is the worst case possible height of an avl tree ???https://www.geeksforgeeks.org/practice-questions-height-balancedavl-tree/how does 1.44*logn comes ????
vijju532
328
views
vijju532
asked
Jul 23, 2018
Algorithms
data-structures
binary-tree
algorithms
+
–
2
votes
1
answer
1376
Algorithms - Matrix Chain Ordering
How to understand the nesting of for loops in these algorithms like which for loop comes under the other ?
How to understand the nesting of for loops in these algorithms like which for loop comes under the other ?
Prince Sindhiya
526
views
Prince Sindhiya
asked
Jul 23, 2018
Algorithms
algorithms
matrix-chain-ordering
+
–
0
votes
3
answers
1377
Spanning Tree
2) An undirected graph G has n nodes. Its adjacency matrix is given by an n n square matrix whose (i) diagonal elements are 0 s and (ii) non-diagonal elements are 1 s. which one of the following is TRUE? (a) Graph G has no minimum spanning tree (MST) ... n-1 (c) Graph G has multiple distinct MSTs, each of cost n-1 (d) Graph G has multiple spanning trees of different costs Expain?
2) An undirected graph G has n nodes. Its adjacency matrix is given by an n × n square matrix whose (i) diagonal elements are 0‘s and (ii) non-diagonal elements are 1�...
pradeepchaudhary
1.1k
views
pradeepchaudhary
asked
Jul 23, 2018
Algorithms
minimum-spanning-tree
algorithms
graph-algorithms
+
–
0
votes
0
answers
1378
Cormen 2nd edition page 584(Representing shortest path)
I read this topic many times but could understand. Plz anyone precise the idea
I read this topic many times but could understand. Plz anyone precise the idea
Sandy Sharma
151
views
Sandy Sharma
asked
Jul 23, 2018
Algorithms
algorithms
bellman-ford
+
–
1
votes
2
answers
1379
What is the time complexity of Make-set function in kruskal algorithm ?
what is the time-complexity in kruskal algorithm for the overall step 2 where for each vertex Make-set function is called ? How come overall time for this step is O(v log v) ? We are performing this Operation for all the ... right because after we come out of loop we have v sets of 1 vertex each . Please explain this clearly .
what is the time-complexity in kruskal algorithm for the overall step 2 where for each vertex Make-set function is called ? How come overall time for this step is O(v lo...
radha gogia
1.2k
views
radha gogia
asked
Jul 22, 2018
Algorithms
algorithms
greedy-algorithm
+
–
1
votes
3
answers
1380
Online doubt
while solving this recursive equation: T(n)=T(n/3)+T(2n/3)+n; i tried the master theorem ignoring the less long term T(n/3) this gave me : T(n)=T(2n/3)+n; and it leads to O(n) Time complexity. And doing with recursive tree method it gave me N(logN base 3/2).. So what is wrong with master theorem approach?
while solving this recursive equation:T(n)=T(n/3)+T(2n/3)+n;i tried the master theorem ignoring the less long term T(n/3)this gave me : T(n)=T(2n/3)+n; and it leads to O(...
aaaaaaaa
541
views
aaaaaaaa
asked
Jul 22, 2018
Algorithms
algorithms
recurrence-relation
+
–
Page:
« prev
1
...
41
42
43
44
45
46
47
48
49
50
51
...
118
next »
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register