Click here to Skip to main content
15,915,160 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Search for repeated character combinations algorithm Pin
khalidelmeknesi11-Sep-09 0:38
khalidelmeknesi11-Sep-09 0:38 
GeneralRe: Search for repeated character combinations algorithm Pin
Luc Pattyn11-Sep-09 1:14
sitebuilderLuc Pattyn11-Sep-09 1:14 
GeneralRe: Search for repeated character combinations algorithm [modified] Pin
khalidelmeknesi16-Sep-09 22:46
khalidelmeknesi16-Sep-09 22:46 
GeneralRe: Search for repeated character combinations algorithm Pin
Luc Pattyn17-Sep-09 2:05
sitebuilderLuc Pattyn17-Sep-09 2:05 
GeneralRe: Search for repeated character combinations algorithm Pin
khalidelmeknesi17-Sep-09 2:18
khalidelmeknesi17-Sep-09 2:18 
GeneralRe: Search for repeated character combinations algorithm Pin
Luc Pattyn17-Sep-09 3:31
sitebuilderLuc Pattyn17-Sep-09 3:31 
AnswerRe: Search for repeated character combinations algorithm [modified] Pin
Moreno Airoldi12-Sep-09 4:40
Moreno Airoldi12-Sep-09 4:40 
AnswerRe: Search for repeated character combinations algorithm Pin
Member 419459314-Sep-09 7:04
Member 419459314-Sep-09 7:04 
khalidelmeknesi,

I'll throw my 2 cents worth into the pot for what its worth (probably about 2 cents).

Use a sort like the Mix Software C Database Toolchest C-BTree routine to create a database (a tree).

Read the file line by line and for each line, ping pong from the front of the line using two character strings, then from the back of the line with 3 character strings, then from the front of the line with 4 character strings, etc, until a full sized line is finally entered, for each such string, add an entry to the tree, each entry containing the string, its length, and an Item (an unsigned long) with a value of 1, specifying no duplicates (if the sort detects a duplicate, it will not add a new entry but return an error, if so then read the existing entry's Item, increment the Item count, and re-save the updated Item, and as you are updating the items, save the top highest item values found in a short array of as you said "some top 5 counts so you know what to look for at the end).

When the end of the input file is reached, close it, then read each entry in the tree and delete the entry if the entry's Item is a value that is not 0 and less than the top 5 or so counts you saved. For entries in the top 5 or so, create a new entry that starts with the Item count subtracted from the maximum saved count converted to a fixed length string with a leading 1 (i.e. for an entry of "abc" with Item count of 45 with a maximum count of 50 start the string with 105, Note: all these created count strings must be the same length) then append the entry string ("abc") giving a string of "105abc", and set the new Item to a value of 0, and once this new entry is created, delete the original entry. If a tree entry is found that contains an Item with a count of 0 (an entry with a header string), then ignore it.

When you have finished modifying all of the tree entries, the tree will contain only the top 5 or so counts with the associated string snipits, all neatly sorted in ascending sequence with the highest count first, and for each high count, the snipits in ascending sequence. Note, to report the count, set a value of 1xxx where xxx is the maximum count, and subtract the leading string value, i.e. as in the example above, set the constant to 150 (1 + the maximum value) and subtract 105 (the heading string) to get a count of 45 for string "abc" (Note: the highest values would have a header string of 100 thus the count would be reported as 50).

When you are done, delete the tree file (Note: this tree file will be HUGE as it is being built).

Note: Mix software still has this excellent database available as of my last check about a year ago. I originally purchased the program and the source in 1984 or so and have recently converted it to compile under the latest Visual Studio. I also created export/import functions that could read old databases (where ints were 16 bits) and create new databases (where ints are 32 bits).

Piece of cake.

Dave.
Question[Message Deleted] Pin
kabirbdboy8-Sep-09 23:35
kabirbdboy8-Sep-09 23:35 
AnswerRe: help me to select my project Pin
CPallini9-Sep-09 1:53
mveCPallini9-Sep-09 1:53 
AnswerRe: help me to select my project Pin
Richard MacCutchan9-Sep-09 3:02
mveRichard MacCutchan9-Sep-09 3:02 
General[Message Deleted] Pin
kabirbdboy9-Sep-09 15:25
kabirbdboy9-Sep-09 15:25 
GeneralRe: help me to select my project Pin
Tim Craig9-Sep-09 17:56
Tim Craig9-Sep-09 17:56 
GeneralRe: help me to select my project Pin
kabirbdboy10-Sep-09 1:38
kabirbdboy10-Sep-09 1:38 
GeneralRe: help me to select my project Pin
Richard MacCutchan9-Sep-09 21:37
mveRichard MacCutchan9-Sep-09 21:37 
AnswerRe: help me to select my project Pin
Nagy Vilmos10-Sep-09 9:41
professionalNagy Vilmos10-Sep-09 9:41 
GeneralRe: help me to select my project Pin
kabirbdboy10-Sep-09 15:08
kabirbdboy10-Sep-09 15:08 
GeneralRe: help me to select my project Pin
Tim Craig10-Sep-09 19:30
Tim Craig10-Sep-09 19:30 
QuestionGradient map Pin
Sauce!8-Sep-09 6:21
Sauce!8-Sep-09 6:21 
AnswerRe: Gradient map Pin
Eddy Vluggen8-Sep-09 11:13
professionalEddy Vluggen8-Sep-09 11:13 
AnswerRe: Gradient map Pin
Alan Balkany9-Sep-09 5:12
Alan Balkany9-Sep-09 5:12 
Questioncomipler construction Pin
rizwana rashid7-Sep-09 8:23
rizwana rashid7-Sep-09 8:23 
AnswerRe: comipler construction Pin
Christian Graus7-Sep-09 15:55
protectorChristian Graus7-Sep-09 15:55 
AnswerRe: comipler construction Pin
mabo428-Sep-09 1:36
mabo428-Sep-09 1:36 
AnswerRe: comipler construction Pin
Luc Pattyn8-Sep-09 2:32
sitebuilderLuc Pattyn8-Sep-09 2:32 

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.