An algorithm is a sequence of well-defined steps that defines an abstract solution to a problem. Use this tag when your issue is related to algorithm design.

learn more… | top users | synonyms (2)

0
votes
1answer
25 views

getting heap corruption and program crashing

I have written following to solve following problem "Given a list of unsorted numbers, can you find the numbers that have the smallest absolute difference between them? If there are multiple pairs, ...
0
votes
0answers
25 views

Matrix of 0s and 1s. Minimize number of operations

I came across this problem at codechef long ago but I'm unable to locate it now. I'm at my wits' end in trying to solve this problem. You are given a matrix containing only 0s and 1s. An operation OP ...
1
vote
1answer
22 views

Recurrence relation . Please tell me where I went wrong

I was asked to solve the following recurrence relation in my homework question , T(n) = T(√n) + T(n - √n) + cn This is how I solved the same and also got the right answer. But there is an obvious ...
0
votes
1answer
23 views

recurrence relation involving big O notation

The solution of the recurrence relation T(n) = 2T(n/2) + O(n^2) is given as Big theta of n^2. How do we get this solution. The way I solved it :- the height of the recurrence tree is logn. And we ...
1
vote
2answers
85 views

How to balance between two arrays such as the difference is minimized?

I have an array A[]={3,2,5,11,17} and B[]={2,3,6}, size of B is always less than A. Now I have to map from every element B to sizeof A elements of such that the total difference abs(Bi-Ai) becomes ...
0
votes
1answer
41 views

is that possible to caculate the number of count inversions using quicksort?

i have already solved the problem using mergesort,now i am thinking is that possible to caculate the number using quicksort?i also coded the quicksort,but i dont know how to caculate here is my code: ...
1
vote
1answer
31 views

Round up to the nearest whole even number

I think a simple maths question, I'm looking for an algorithm to round up to the nearest whole even number so 4.4 = 6 5.1 = 6 2.1 = 4 1.9 = 2 etc.... If you could give me the VBA syntax that would ...
0
votes
0answers
30 views

Removing duplicates from an array using divide and conquer in O(nlogn) time

You are given an Array A of n requests for 2010 olympic tickets. The array is ordered by the time of the request so that A(1) is the first to arrive and A(2) is the second to arrive etc. Each request ...
0
votes
2answers
40 views

Why the total number of levels of the recursion tree of a merge sort is lg n + 1?

I think the question is pretty self-explanatory here but I am looking at "Introduction to Algorithms" 3rd edition page 37 and it says that the total # of levels of the recursion tree in Figure 2.5 is ...
-1
votes
1answer
22 views

Find top 10 integers among 100 different files

I am a fresher and preparing for interviews. In my recent interview I was asked a question, for which I couldn't find suitable answer. I was given some 100 files, each file is containing large ...
0
votes
2answers
65 views

What is meaning of template function arguments?

I have came across following template function, template<typename C, typename F = less<typename C::value_type>> void Sort(C& c, F f = F()){ sort(C.begin(),c.end(),f); } Now, I ...
2
votes
1answer
48 views

Sort array in Θ(n) complexity

Prove that an array A of size n can be sorted in Θ(n) when it has O(n) inversions. I don't know exactly what this question is asking. My best guess is that we use insertion sort on a ...
3
votes
1answer
66 views

How to find if a graph has a cycle?

I know this question has been asked many times in this forum and everywhere else in the internet. But before you attack me with your claws outstretched please bear with me. I am a newbie learning ...
0
votes
1answer
24 views

Amortized analysis

In the Amortized analysis. Average case running time: average over all possible inputs for one algorithm (operation). If using probability, called expected running time What is the different between ...
0
votes
0answers
26 views

algorithm to find optimized scheduling

I have 7 tasks t1-t7, each task has an execution time associated (t1 takes 1 time unit,t2 takes 5 etc). You don't have to pay for communication cost between t1 and t2 if you do them in the same ...

15 30 50 per page