|
-
May 12th, 2008, 09:36 PM
#1
Best data structure for notepad application
Can any one pls tell me which data structure will best suit the application - notepad.......? Justify as to how its best suited.............
Thanking u in advance....
-
May 12th, 2008, 09:51 PM
#2
Re: Best data structure for notepad application
Binary, so you can't read it?
Is this a homework question? Have you tried GOOGLE?
-
May 13th, 2008, 10:31 AM
#3
Re: Best data structure for notepad application
no ths s not a home work question........
its a question asked in the technical interview for jobs........
i had thought about the data structure 'trie'.........
bt i cld nt obtain a reasonable answer..........
thats why i posted it here...........
-
May 13th, 2008, 10:32 AM
#4
Re: Best data structure for notepad application
I had tried google............bt still was not satisfied............
-
May 14th, 2008, 07:29 AM
#5
Re: Best data structure for notepad application
It will be good to use linked list of fixed sized (may be) arrays of chars for notepad like text handling!
-
May 15th, 2008, 11:31 PM
#6
Re: Best data structure for notepad application
 Originally Posted by mandeep2
It will be good to use linked list of fixed sized (may be) arrays of chars for notepad like text handling!
but you will not be able to move around the text while editing.......... it becomes difficult for you right..........?
it should also be convenient for you to move around the text.......?
-
May 15th, 2008, 11:40 PM
#7
Re: Best data structure for notepad application
-
May 16th, 2008, 09:01 AM
#8
Re: Best data structure for notepad application
what do you mean by simply mentioning as xml?
-
May 16th, 2008, 04:45 PM
#9
Re: Best data structure for notepad application
if you mean a data structure to store the text typed in notepad, than string would no doubt be one of the most (if not the most) suitable data structure for notepad application since notepad basically handles, well.. string.
in many languages string is treated just as other builtin datatypes, making most people think that string is just a primitive datatype like bool, int, or char. The truth is that string is actually a char container, making it practically a data structure. a string implementation can utilise any kind of data structure available (linked list and array being the most simple). Implementation wise, we can leave the worries to the language and library designer and simply use what the language & std. library provide (e.g. std::string on c++, String on java, etc).
just my 2cents
Last edited by INA_ctive; May 16th, 2008 at 04:58 PM.
-
May 17th, 2008, 12:26 AM
#10
Re: Best data structure for notepad application
Yes,
Ur suggestion was correct.........
Actually string is also a good one..............
Thanks a lot yere.............
-
May 17th, 2008, 12:53 AM
#11
Re: Best data structure for notepad application
For larger text files, string it not a good solution - for both non-terminated C-style strings or strings which store their length. What if you need to insert some text at the beginning of document (say at 50th character, in a 2MB document). You need to run a loop even for one character insert/delete till 2000000+ counts?
I would recommend using linked list (or std::list), and store each line as list' one element. Each list' element would be 'string' - which you may limit to few KBs. Any replace, insert, delete would be just replacing the string contents for that line. This would, of course, not require whole 'list' object to be traversed.
Now here comes the hard part: when there is line break, or merging of two lines - the two list' elements needs to be merged. Say 6th and 7th lines are merged, you need to append 7th line content into 6th, and delete the 7the line from list. 8th line would now become 7th and so on.
Special taken must be taken care of of multiple lines are being deleted, inserted or replaced - this might be complicated, but appropriate solution.
Similar thing needs to be done where a single line is being breaked into two lines (a simple Enter key would do!).
But if your text-editor would be limited (or you place this limitation) to few KBs, you can straightly use string as data-structure. Remeber Notepad.EXE used to support only 65K files?
Last edited by Ajay Vijay; May 17th, 2008 at 12:55 AM.
-
January 23rd, 2011, 12:27 PM
#12
Re: Best data structure for notepad application
I have a problem of what type of data structure of my mobile dictionary application. I use notepad to save data. From my program I call the data that save on notepad. pls help me of what data structures that if I save data as a textfile.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|