How to find time complixity?
You are given a matrix. The matrix elements are such that they are sorted both horizontally and vertically. Given an element of the matrix, your job is to obtain its position in an efficient manner.Example:
Latest Answer: 10 20 30 15 35 98 48 76 110Input: 76Output: 3rd row, 2nd column.First start from extreme right-top and keep on seraching until you reach extreme left-down. n=0; m=0; while(n
You have an array of size '2n' of these, 'n+1' elements are distinct and 1 element is repeated 'n' times. You must find the repeated element and say how many times it has
Latest Answer: Iterate through each bit of numbers, i.e. if we have 32-bit numbers then there will be 32 iterations. For the current bit B:Iterate through the array and count numbers C0 and C1 - how many elements contain 0 and 1 in bit B. If C0 > N, then the repeating ...
What is meant by algorithm profiling?
Latest Answer: In recent years, several very efficient exact optimization algorithms have
been developed in the computer science community. Examples are maximum flow
algorithms, minimum-cost flow techniques, matching methods, which all are graph
theoretical approaches ...
What is validation of an algorithm?
List out the characteristics of an algorithm
Bring out the importance of Algorithms in the field of Computer Science?
u are given a n*n square matrix where each element is either 0 or 1....u have to find the square submatrix with the largest length such that all the elements along the border of that square submatrix matrix
Latest Answer: You can find de length of the side of square by using your procedure. but how can you find the position? ...
Give an algorithm that calculates the distance between two text strings (only operations you can have are: delete, add, and change, one by one).
Latest Answer: Stanard approach is dynamic programming with complexity O(N*M).Let strings are A[1..N] and B[1..M]. We use array DP[0..N][0..M]. DP[i][j] stores the answer for prefixes of length i and j. DP[N][M] is the answer.DP[i][j] = i+j (if i = 0 or ...
Implement an algorithm that takes two strings as input, and returns the intersection of the two, with each letter represented at most once. Speed it up and test it.
Latest Answer: Using the longer string, build a binary tree with characters as keys. Make a pass through the other smaller string, removing those elements from the binary tree which are not present in the smaller string. The resultant tree obtained will be having the ...
View page [1] 2 3 Next >>

Go Top