sivakrupa
May 12th, 2008, 09:36 PM
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....
Thanking u in advance....
|
Click to See Complete Forum and Search --> : Best data structure for notepad application sivakrupa May 12th, 2008, 09:36 PM 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.... dglienna May 12th, 2008, 09:51 PM Binary, so you can't read it? ;) Is this a homework question? Have you tried GOOGLE? sivakrupa May 13th, 2008, 10:31 AM 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........... sivakrupa May 13th, 2008, 10:32 AM I had tried google............bt still was not satisfied............ mandeep2 May 14th, 2008, 07:29 AM It will be good to use linked list of fixed sized (may be) arrays of chars for notepad like text handling! sivakrupa May 15th, 2008, 11:31 PM 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.......? dglienna May 15th, 2008, 11:40 PM Xml sivakrupa May 16th, 2008, 09:01 AM what do you mean by simply mentioning as xml? INA_ctive May 16th, 2008, 04:45 PM 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 sivakrupa May 17th, 2008, 12:26 AM Yes, Ur suggestion was correct......... Actually string is also a good one.............. Thanks a lot yere............. Ajay Vijay May 17th, 2008, 12:53 AM 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? mildarmz January 23rd, 2011, 11:27 AM 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. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |