Click here to Skip to main content
15,885,182 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: Writing a Sorting Algorithm -- NEED HELP! Pin
Member 1488614010-Jul-20 3:04
Member 1488614010-Jul-20 3:04 
GeneralRe: Writing a Sorting Algorithm -- NEED HELP! Pin
Dave Kreskowiak23-Jul-20 3:39
mveDave Kreskowiak23-Jul-20 3:39 
QuestionA permutation problem Pin
Member 135615816-Dec-17 4:04
Member 135615816-Dec-17 4:04 
AnswerRe: A permutation problem Pin
Richard MacCutchan6-Dec-17 4:09
mveRichard MacCutchan6-Dec-17 4:09 
AnswerRe: A permutation problem Pin
Luc Pattyn20-Dec-17 12:03
sitebuilderLuc Pattyn20-Dec-17 12:03 
QuestionAlgorithm for insert element in compressed sparse row matrix Pin
drudox 16-Nov-17 4:23
drudox 16-Nov-17 4:23 
QuestionNo-intersection edge detection. Pin
primem0ver11-Nov-17 6:19
primem0ver11-Nov-17 6:19 
QuestionDatagap finder Pin
V.7-Nov-17 0:10
professionalV.7-Nov-17 0:10 
A question arose here at work where they would like to find datagaps in timeline datasets. This can be from database or from images. (eg each 6 hours there's an image).

Basically they want a "pseudocode" function that would work across technologies.
in: at least an array of datetime stamps
out: a list of gaps in the list.

This is what I have so far (it's C type language, but no language in particular):
C#
// interval = milliseconds, seconds, minutes, hours, days, months, year
//amount (interval) is the amount you need to add to the timestamp in a certain interval.  (eg amount = 12, interval = seconds ==> add 12 seconds)
function FindGaps(DateTime dts_start, DateTime dts_end, int amount, string interval, Array list2check){

//Build reference list.
Array listreference<DateTime, boolean>;     //dictionary containing datetime as key and boolean as value (or integer, enums, ...)
for(DateTime dts = dts_start; dts < dts_end; dts += amount (interval)){
    listreference.Add(dts, false);      //initialize base values
}

//check list with reference list.
for(int i = 0; i < list2check.length; i++){     //or use long ?
    //if value of DateTime list2check is in the reference list:  Jeej!
    if(KeyExists(listrefence, list2check[i])){
        listrefence[list2check[i]]) = true;
    }
}

return listrefence;
}       

and some of my own thoughts:

problems/remarks:
* You cannot uniformally convert months, years, ... eg to milliseconds (january has different amount of milliseconds than february, ...)
* not all datasets have uniform progression (timegap difference between points)
* datasets passed should not be too large
* the key check should be on similar interval (minutes = minutes eg. 00:00 = 00:00, but 00:00 != 00:00:01)
* adding the fill value can also mark the gap as true / false / invalid eg.
* should you "remove" values that are in between gaps? eg. there are 100 values in a row = false. Should we only keep first and last value?
* This will not be very fast: can we loop from start --> end with amount (interval) and check if DateTime is in list2check? (how will we return?)
* better would be if there are points in between 2 points of the reference list, but how to do that practically? (could potentially fix point 2 to some extent)

Does anyone have experience in this? any tips or pointers?

(PS: I have a nice query that can do this in a (postgresql) database, but this does not fit file based datasets)

thanks!
V.
(MQOTD rules and previous solutions)

AnswerRe: Datagap finder Pin
Peter_in_27807-Nov-17 0:46
professionalPeter_in_27807-Nov-17 0:46 
AnswerRe: Datagap finder Pin
Gerry Schmitz7-Nov-17 12:21
mveGerry Schmitz7-Nov-17 12:21 
QuestionPrefix sum: GenomicRangeQuery Pin
Yugo Amaryl5-Nov-17 23:20
Yugo Amaryl5-Nov-17 23:20 
AnswerRe: Prefix sum: GenomicRangeQuery Pin
Gerry Schmitz6-Nov-17 6:08
mveGerry Schmitz6-Nov-17 6:08 
AnswerRe: Prefix sum: GenomicRangeQuery Pin
honey the codewitch17-Jan-18 17:02
mvahoney the codewitch17-Jan-18 17:02 
Questionfind largest number of pages i can buy from a list of books within a certain budget. Pin
Member 135013603-Nov-17 1:16
Member 135013603-Nov-17 1:16 
AnswerRe: find largest number of pages i can buy from a list of books within a certain budget. Pin
OriginalGriff3-Nov-17 1:19
mveOriginalGriff3-Nov-17 1:19 
GeneralRe: find largest number of pages i can buy from a list of books within a certain budget. Pin
Member 135013603-Nov-17 1:56
Member 135013603-Nov-17 1:56 
AnswerRe: find largest number of pages i can buy from a list of books within a certain budget. Pin
Ralf Meier3-Nov-17 2:08
mveRalf Meier3-Nov-17 2:08 
GeneralRe: find largest number of pages i can buy from a list of books within a certain budget. Pin
Member 135013603-Nov-17 2:15
Member 135013603-Nov-17 2:15 
QuestionWhat is the best search strategy? Pin
daxue2-Nov-17 18:07
daxue2-Nov-17 18:07 
QuestionLoad balancing with 3 factors Pin
LabVIEWstuff1-Nov-17 4:58
LabVIEWstuff1-Nov-17 4:58 
AnswerRe: Load balancing with 3 factors Pin
Afzaal Ahmad Zeeshan1-Nov-17 5:36
professionalAfzaal Ahmad Zeeshan1-Nov-17 5:36 
GeneralRe: Load balancing with 3 factors Pin
LabVIEWstuff3-Nov-17 1:45
LabVIEWstuff3-Nov-17 1:45 
GeneralRe: Load balancing with 3 factors Pin
Afzaal Ahmad Zeeshan3-Nov-17 1:55
professionalAfzaal Ahmad Zeeshan3-Nov-17 1:55 
AnswerRe: Load balancing with 3 factors Pin
Gerry Schmitz1-Nov-17 5:37
mveGerry Schmitz1-Nov-17 5:37 
GeneralRe: Load balancing with 3 factors Pin
LabVIEWstuff3-Nov-17 1:38
LabVIEWstuff3-Nov-17 1:38 

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.