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
1501
#Algorithms #DFS How to find if a directed graph G is strongly connected using DFS in one pass?
I know, Kosaraju algorithm and there's one other algorithm which involves reversing of G and using DFS, but two times, but there's some algorithm which uses DFS only time, but I can't be able find that algorithm. Someone please share that.
I know, Kosaraju algorithm and there's one other algorithm which involves reversing of G and using DFS, but two times, but there's some algorithm which uses DFS only time...
iarnav
427
views
iarnav
asked
May 13, 2018
Algorithms
graph-theory
algorithms
depth-first-search
graph-algorithms
+
–
0
votes
1
answer
1502
Doubt
Consider a stack is used to evaluate fully parenthesized arithmetic expression from left to right. Each opperand is placed on the stack and operators operate on top two elements of the stack. The minimum size of stack required to evaluate given expression is ________.
Consider a stack is used to evaluate fully parenthesized arithmetic expression from left to right. Each opperand is placed on the stack and operators operate on top two e...
Na462
287
views
Na462
asked
May 10, 2018
Programming in C
algorithms
+
–
0
votes
2
answers
1503
Doubt
Consider A be a 2-dimensional array declared as follows: A[15] [15] of integers. Assume each integer take 1B. The array stored in row major order and first element of array is stored at location 1000, then the address of element a[10] [6] is ________ B.
Consider A be a 2-dimensional array declared as follows: A[15] [15] of integers. Assume each integer take 1B. The array stored in row major order and first element of arr...
Na462
232
views
Na462
asked
May 10, 2018
Programming in C
algorithms
+
–
1
votes
1
answer
1504
Time complexity
show how to sort n number in the range [0,n^2-1] in O(n)time?
show how to sort n number in the range [0,n^2-1] in O(n)time?
once_2019
317
views
once_2019
asked
May 8, 2018
Algorithms
time-complexity
algorithms
+
–
1
votes
1
answer
1505
Sorting
Which of the following sorting techniques have minimum number of comparision in best case? 1. Insertion Sort 2. Selection Sort 3. Merge Sort 4. Heap Sort 5.Quick Sort The answer is insertion sort but my doubt is in insertion sort algo. inside the for loop the while ... in best case.Wont it have O(n^2) Comparisons.Becasue comparisons will be done in all the cases weather its sorted or not.
Which of the following sorting techniques have minimum number of comparision in best case?1. Insertion Sort2. Selection Sort3. Merge Sort4. Heap Sort5.Quick Sort The answ...
Na462
2.5k
views
Na462
asked
May 6, 2018
Algorithms
sorting
algorithms
+
–
0
votes
1
answer
1506
Doubt
Consider f (n), g(n) and h(n) be function defined as follows: Which of the following represents correct asymptotic solution for f (n) + [g(n) × h(n)]? A . Omega(n^3) B. O(n^4) C. Theta(n^4) D. O(n^3) What should be the correct way of solving such questions ?
Consider f (n), g(n) and h(n) be function defined as follows:Which of the following represents correct asymptotic solution for f (n) + [g(n) × h(n)]?A . Omega(n^3)B. ...
Na462
761
views
Na462
asked
May 6, 2018
Algorithms
algorithms
asymptotic-notation
+
–
0
votes
2
answers
1507
BITS HD
To sort the following numbers which algorithm will suit the best (i) 1 to 100 integers (ii) 0 to 1000000 integers a)bucket sort for both b) (i)radix sort (ii)quick sort c) (i)quick sort (ii)merge sort d) (i) merge sort (ii)quick sort
To sort the following numbers which algorithm will suit the best (i) 1 to 100 integers (ii) 0 to 1000000 integers ...
Sayan Bose
1.5k
views
Sayan Bose
asked
May 4, 2018
Algorithms
bits-hd
algorithms
sorting
+
–
1
votes
0
answers
1508
Question
Which of the following represents the number of additions performed by above code? A 8000 B 4000 C 4020 D 28420 Solution:- Well i got the Answer but not exact answer :- Ttoal number of times loop executes = 20 * 20 * 20 = 8000 The inner condition will execute always and ... = 100*10 = 1000 (I guess here i left some Cases) So total = 17000 But sill its far away from actual answer which is D
Which of the following represents the number of additions performed by above code?A 8000B 4000C 4020D 28420Solution:- Well i got the Answer but not exact answer :- Ttoal ...
Na462
208
views
Na462
asked
May 4, 2018
Programming in C
algorithms
+
–
0
votes
0
answers
1509
Doubt
Any AVL tree of height h+1 contains strictly more nodes than any AVL tree of height h. ? Its a false statement right ? what is the correct statement then ,because if in any tree Height is inversely proportional to number of nodes. Minimum height means maximum number of ... is the correct statement is :- Any AVL tree of height h+1 contains strictly lesser nodes than any AVL tree of height h. ?
Any AVL tree of height h+1 contains strictly more nodes than any AVL tree of height h. ?Its a false statement right ? what is the correct statement then ,because if in an...
Na462
209
views
Na462
asked
May 4, 2018
Programming in C
algorithms
+
–
0
votes
0
answers
1510
Doubt
In DFS traversal every vertex of the graph is visited exactly once.? Is it correct ? According to me its True because in standard algorithm we maintain a visited datastructure to keep track of which vertex is visited and we after then skip those vertex if found again hence one vertex will never get visited again isn't it?
In DFS traversal every vertex of the graph is visited exactly once.?Is it correct ?According to me its True because in standard algorithm we maintain a visited datastruct...
Na462
577
views
Na462
asked
May 3, 2018
Programming in C
algorithms
+
–
0
votes
1
answer
1511
General Doubt
Suppose i delete the root element from the heap then i will apply the heapify() procedure on root,and suppose if i delete a random element form heap which will take O(n) time in total then the procedure is:- 1. Locate the element. 2.Swap with the ... Maxheapify(A[i]) } Am i right? And following this strategy we will find the minimum number of swaps or comparison required isnt it?
Suppose i delete the root element from the heap then i will apply the heapify() procedure on root,and suppose if i delete a random element form heap which will take O(n) ...
Na462
281
views
Na462
asked
May 3, 2018
Programming in C
general
algorithms
+
–
2
votes
0
answers
1512
Algorithm
You have an array A with n JPEG images some of which are identical. You can check if two objects are equal but you cannot compare them in any other way-i.e. you can check A[i] == A[j] and A[i] != A[j], but comparisons such as A[i] < A[j] ... of its elements are equal to each other. Use divide and conquer to come up with an O(n logn ) algorithm to determine if A has a majority element.
You have an array A with n JPEG images some of which are identical.You can check if two objects are equal but you cannot compare them in any other way—i.e. you can chec...
Kushagra Chatterjee
951
views
Kushagra Chatterjee
asked
May 2, 2018
Algorithms
algorithms
time-complexity
divide-and-conquer
+
–
1
votes
0
answers
1513
MadeEasy Test Series: Algorithms - Sorting
Please Justify Statements which are true and which are false by an Example: Consider the following statements : S1 :While performing quick sort at any iteration only 1 element can be present at its correct position. S2 : The running time of ... ' passes in order to solve the single source shortest path problem on G'. Which of the following is correct ?
Please Justify Statements which are true and which are false by an Example:Consider the following statements :S1 :While performing quick sort at any iteration only 1 ele...
Na462
1.4k
views
Na462
asked
Apr 30, 2018
Algorithms
made-easy-test-series
algorithms
sorting
bellman-ford
+
–
0
votes
1
answer
1514
MadeEasy Test Series: Algorithms - Greedy Algorithm
Consider the following graph: If the edge weight of minimum spanning tree are given and edge weight of each edge is distinct, then the minimum value of sum (a, b, c, d, e, f, g) is __________. My Strategy :- According to me a = 11 (because if we see the ... and likewise g = 11,f = 12,b = 8,e = 8,d = 9,c = 6.Hence Sum is = 65 Made Easy Solution :-
Consider the following graph:If the edge weight of minimum spanning tree are given and edge weight of each edge is distinct, then the minimum value of sum (a, b, c, d, e,...
Na462
864
views
Na462
asked
Apr 30, 2018
Algorithms
made-easy-test-series
algorithms
greedy-algorithm
+
–
0
votes
1
answer
1515
MadeEasy Test Series: Algorithms - Greedy Algorithm
Consider the following message: The number of bits required for huffman encoding of the above message are __________? My Strategy:- But the answer given is 52bits i used standard Algorithem Made Easy Solution :-
Consider the following message:The number of bits required for huffman encoding of the above message are __________?My Strategy:- But the answer given is 52bits i used st...
Na462
4.5k
views
Na462
asked
Apr 30, 2018
Algorithms
made-easy-test-series
huffman-code
greedy-algorithm
algorithms
+
–
3
votes
1
answer
1516
time complexity
$f(n)=2n^2+ n log n$ $g(n)= \dfrac{n}{logn} + log^2n$ then $f(n)\times g(n)$ is: $n^2logn$ $\dfrac{n^3}{logn}$ $n^3log^2n$ $n^2log^2n$
$f(n)=2n^2+ n log n$$g(n)= \dfrac{n}{logn} + log^2n$ then $f(n)\times g(n)$ is:$n^2logn$$\dfrac{n^3}{logn}$$n^3log^2n$$n^2log^2n$
sumit_kumar
284
views
sumit_kumar
asked
Apr 30, 2018
Algorithms
time-complexity
algorithms
+
–
6
votes
1
answer
1517
CMI2010 - 6
You are given a list of positive integers along with a sequence of operations from the set $\left \{ *,+\right \}$ .You construct expressions from these two lists so that: The numbers in the expression are drawn from the first list, without repetition and ... assume that the length of the first list is more than the length of the second list. Describe an algorithm to solve this problem.
You are given a list of positive integers along with a sequence of operations from the set $\left \{ *,+\right \}$ .You construct expressions from these two lists so that...
Sammohan Ganguly
2.4k
views
Sammohan Ganguly
asked
Apr 30, 2018
Algorithms
algorithms
descriptive
cmi2010
algorithm-design
+
–
4
votes
1
answer
1518
Minimum Spanning Tree
1) Kruskal Algorithm 2) Prims Algorithm 3) Dijkstra Algorithm 4) Bellman Ford Algorithm 5) Floyd Warshall Algorithm Among these which one works for only i) Positive edge weight ii) Negative edge weight iii) Negative weight cycle
1) Kruskal Algorithm2) Prims Algorithm3) Dijkstra Algorithm4) Bellman Ford Algorithm5) Floyd Warshall AlgorithmAmong these which one works for onlyi) Positive edge weight...
srestha
3.2k
views
srestha
asked
Apr 30, 2018
Algorithms
minimum-spanning-tree
algorithms
graph-algorithms
+
–
0
votes
3
answers
1519
#Algorithms #MST Doubt in MST Questions.
Question 1) The shortest-path tree computed by Dijkstra's algorithm is necessarily an MST? Question2 ) Prim's algorithm works with negative weighted edges?
Question 1) The shortest-path tree computed by Dijkstra's algorithm is necessarily an MST?Question2 ) Prim's algorithm works with negative weighted edges?
iarnav
1.6k
views
iarnav
asked
Apr 29, 2018
Algorithms
algorithms
minimum-spanning-tree
graph-algorithms
+
–
0
votes
1
answer
1520
SELF_DOUBT(MST)
What important point we keep in mind while finding the #(number) of spanning tree ?? from the given graph
What important point we keep in mind while finding the #(number) of spanning tree ?? from the given graph
air1ankit
499
views
air1ankit
asked
Apr 29, 2018
Algorithms
algorithms
minimum-spanning-tree
graph-connectivity
+
–
0
votes
1
answer
1521
Spanning trees
Suppose that a graph G has a minimum spanning tree already computed. How quickly can we update the minimum spanning tree if we add a new vertex and incident edges to G?
Suppose that a graph G has a minimum spanning tree already computed. How quickly can we update the minimum spanning tree if we add a new vertex and incident edges to G?
Durgesh Singh
951
views
Durgesh Singh
asked
Apr 29, 2018
Algorithms
algorithms
graph-theory
minimum-spanning-tree
+
–
0
votes
1
answer
1522
Self Doubt
How can we distinguish b/w back edge, the forward edge and cross edge in BFS or DFS traversal in Graphs?
How can we distinguish b/w back edge, the forward edge and cross edge in BFS or DFS traversal in Graphs?
Durgesh Singh
273
views
Durgesh Singh
asked
Apr 29, 2018
Algorithms
algorithms
graph-theory
graph-search
+
–
1
votes
2
answers
1523
ISI-2017-PCB-C6
Let $A = \{a_1,a_2, \dots ,a_n\}$ be an array of $n$ distinct numbers. The array may not be sorted. The first element $a_1$ is said to be a blip if $a_1 > a_2$. Similar, the last element an is said to be a blip if $a_n > a_{n-1}$. Among the ... $O(\log n)$ time algorithm for finding a blip in $A$. Justify the complexity of your algorithm.
Let $A = \{a_1,a_2, \dots ,a_n\}$ be an array of $n$ distinct numbers. The array may not be sorted. The first element $a_1$ is said to be a blip if $a_1 a_2$. Similar, t...
Tesla!
1.0k
views
Tesla!
asked
Apr 28, 2018
Algorithms
isi2017
algorithms
algorithm-design
descriptive
+
–
1
votes
1
answer
1524
#Algorithms #MST No of MST's possible?
In a connected weighted graph with n vertices, all the edges have same positive integer weights. Then, the maximum number of minimum weight spanning trees in the graph is? My take - If it's a cyclic graph and just with one cycle in G then we ... and it's not a complete Graph) then you get more than n MST's where n is the number of nodes in G.
In a connected weighted graph with n vertices, all the edges have same positive integer weights. Then, the maximum number of minimum weight spanning trees in the graph is...
iarnav
2.6k
views
iarnav
asked
Apr 28, 2018
Algorithms
algorithms
minimum-spanning-tree
+
–
0
votes
2
answers
1525
#Algorithms #MST Self Doubt.
Let G be a connected simple graph with non distinct edge weights. Now, e be the lightest edge in G. So, does this edge e is present in every MST of G? My take - when all edge weights are same then lightest edge e won't be there.
Let G be a connected simple graph with non distinct edge weights. Now, e be the lightest edge in G. So, does this edge e is present in every MST of G?My take - when all e...
iarnav
404
views
iarnav
asked
Apr 28, 2018
Algorithms
algorithms
minimum-spanning-tree
+
–
0
votes
1
answer
1526
Time Complexity
int lcs_length(char * A, char * B) { if (*A == '\0' || *B == '\0') return 0; else if (*A == *B) return 1 + lcs_length(A+1, B+1); else return max(lcs_length(A+1,B), lcs_length(A,B+1)); } what is worst case time complexity of $\text{lcs_length}$ if size of $A$ is $m$ and size of $B$ is $n$? O($2^{m+n}$) O($2^{n}$) O($2^{mn}$) O($2^{max(m,n)}$) none of these
int lcs_length(char * A, char * B) { if (*A == '\0' || *B == '\0') return 0; else if (*A == *B) return 1 + lcs_length(A+1, B+1); else return max(lcs_length(A+1,B), lcs_le...
hacker16
415
views
hacker16
asked
Apr 28, 2018
Algorithms
time-complexity
recursion
algorithms
+
–
0
votes
1
answer
1527
#Algorithms #MST Variance of Gate 2018 MST Question.
Original question - https://gateoverflow.in/204122/gate2018-47 Consider the following undirected graph G: Choose a value for x that will minimize the number of minimum weight spanning trees (MWSTs) of G. The number of MWSTs of G for this ... would be what would be minimum value of x for which we get minimum MST's then x=1 would be correct.
Original question - https://gateoverflow.in/204122/gate2018-47Consider the following undirected graph G:Choose a value for x that will minimize the number of minimum weig...
iarnav
595
views
iarnav
asked
Apr 28, 2018
Algorithms
algorithms
minimum-spanning-tree
+
–
0
votes
0
answers
1528
Recursion Tree
What is the max height of recursion tree of recurrence $c(100,50)$? here, the recursive function is defined as $c(n,k) = c(n-1,k-1) + c(n,k-1)$ terminating condition $c(n,n) = 1, c(n,0) = 1$.
What is the max height of recursion tree of recurrence $c(100,50)$?here, the recursive function is defined as$c(n,k) = c(n-1,k-1) + c(n,k-1)$terminating condition$c(n,n) ...
hacker16
483
views
hacker16
asked
Apr 28, 2018
Algorithms
algorithms
recursion
dynamic-programming
+
–
0
votes
1
answer
1529
Cormen 3rd edition Exercise 4.4.9
Use a recursion tree to give an asymptotically tight solution to the recurrence T(n) =T(an)+T((1-a)n)+cn, where a is constant in the range 0<a<1 and c>0 is also a constant.
Use a recursion tree to give an asymptotically tight solution to the recurrenceT(n) =T(an)+T((1-a)n)+cn, where a is constant in the range 0<a<1 and c>0 is also a constant...
Neha_16
6.0k
views
Neha_16
asked
Apr 27, 2018
Algorithms
algorithms
asymptotic-notation
+
–
1
votes
1
answer
1530
Time Complexity
Please find the time complexity of the following code:-int i,s1; i=1,s1=1; while(s1<=n) { i++; s1+=s1+i; printf("Hope"); }
Please find the time complexity of the following code:-int i,s1;i=1,s1=1; while(s1<=n) { i++; s1+=s1+i; printf("Hope"); }
Devshree Dubey
4.5k
views
Devshree Dubey
asked
Apr 27, 2018
Algorithms
algorithms
time-complexity
+
–
Page:
« prev
1
...
46
47
48
49
50
51
52
53
54
55
56
...
118
next »
Email or Username
Show
Hide
Password
I forgot my password
Remember
Log in
Register