Click here to Skip to main content
16,005,120 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: Binary tree Pin
Alan Balkany22-May-17 4:09
Alan Balkany22-May-17 4:09 
QuestionWhat is the best/good sorting+pipelining strategy for my situation ? Pin
Member 1307259520-Mar-17 16:40
Member 1307259520-Mar-17 16:40 
To begin, I have the set of K values S={v_1, ..., v_K}. I want to pick the smallest value, replace it with another value, and again pick the smallest -- do this K times. So, initially, my best set B is empty, and I want to perform :

Step 1. Find minimum of S. Say it has index n. B=[B, v_n] (i.e., append v_n to B)

Step 2. Update S by replacing v_n with another value (not important how that other value is computed).

Repeat Steps 1 and 2 till B has K values.

I believe a reasonable way to do this is to first construct a min-heap from the initial S (KlogK complexity), and then I can (take out the root + insert new element) for (K-1) times. Assuming taking out root and insertion both are logK complexity, total complexity would be KlogK + 2(K-1)log(K) = (3K-2)logK.

As a next step, once I have the set B, I want to compute some function f(b) for each b in B, and repeat the above procedure with the set {f(b)} instead of the set S. In other words, taking the set {f(b)} as S now, I would like to perform the above described procedure. Brute force way -- I could first use up (3K-2)logK units of time to find B, then compute the set {f(b)}, and then use another (3K-2)logK units of time on {f(b)}. But, it is quite apparent I can do better by pipelining. Essentially, as soon as I start getting entries of B, I can compute f(.) for the available entries, and do some of the sorting operations.

Can you suggest a good/optimal way for the overall problem ?
Questionco-occurrence matrix Pin
Member 130454587-Mar-17 21:33
Member 130454587-Mar-17 21:33 
AnswerRe: co-occurrence matrix Pin
Richard MacCutchan7-Mar-17 23:09
mveRichard MacCutchan7-Mar-17 23:09 
AnswerRe: co-occurrence matrix Pin
Pete O'Hanlon7-Mar-17 23:19
mvePete O'Hanlon7-Mar-17 23:19 
GeneralRe: co-occurrence matrix Pin
Richard MacCutchan7-Mar-17 23:53
mveRichard MacCutchan7-Mar-17 23:53 
GeneralRe: co-occurrence matrix Pin
Pete O'Hanlon7-Mar-17 23:57
mvePete O'Hanlon7-Mar-17 23:57 
GeneralRe: co-occurrence matrix Pin
Richard MacCutchan8-Mar-17 0:05
mveRichard MacCutchan8-Mar-17 0:05 
GeneralRe: co-occurrence matrix Pin
Member 130454588-Mar-17 19:25
Member 130454588-Mar-17 19:25 
GeneralRe: co-occurrence matrix Pin
Pete O'Hanlon8-Mar-17 20:48
mvePete O'Hanlon8-Mar-17 20:48 
GeneralRe: co-occurrence matrix Pin
Member 1304545814-Mar-17 22:46
Member 1304545814-Mar-17 22:46 
GeneralRe: co-occurrence matrix Pin
Pete O'Hanlon14-Mar-17 23:47
mvePete O'Hanlon14-Mar-17 23:47 
GeneralRe: co-occurrence matrix Pin
Richard MacCutchan8-Mar-17 21:13
mveRichard MacCutchan8-Mar-17 21:13 
GeneralRe: co-occurrence matrix Pin
Member 1304545814-Mar-17 22:38
Member 1304545814-Mar-17 22:38 
GeneralRe: co-occurrence matrix Pin
Richard MacCutchan14-Mar-17 23:00
mveRichard MacCutchan14-Mar-17 23:00 
AnswerRe: co-occurrence matrix Pin
Patrice T9-Mar-17 15:16
mvePatrice T9-Mar-17 15:16 
GeneralRe: co-occurrence matrix Pin
Member 1304545814-Mar-17 22:32
Member 1304545814-Mar-17 22:32 
SuggestionRe: co-occurrence matrix Pin
CHill6015-Mar-17 1:08
mveCHill6015-Mar-17 1:08 
QuestionAlgorithm try and figure this out in c# Pin
Member 1300374315-Feb-17 11:28
Member 1300374315-Feb-17 11:28 
AnswerRe: Algorithm try and figure this out in c# Pin
Richard Andrew x6415-Feb-17 13:40
professionalRichard Andrew x6415-Feb-17 13:40 
AnswerRe: Algorithm try and figure this out in c# Pin
Richard MacCutchan15-Feb-17 21:20
mveRichard MacCutchan15-Feb-17 21:20 
AnswerRe: Algorithm try and figure this out in c# Pin
Richard Deeming16-Feb-17 2:02
mveRichard Deeming16-Feb-17 2:02 
AnswerRe: Algorithm try and figure this out in c# Pin
Patrice T18-Feb-17 14:59
mvePatrice T18-Feb-17 14:59 
QuestionProof by mathematical induction Pin
Member 129868787-Feb-17 0:18
Member 129868787-Feb-17 0:18 
AnswerRe: Proof by mathematical induction Pin
Pete O'Hanlon7-Feb-17 0:42
mvePete O'Hanlon7-Feb-17 0:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.