![]() |
|
#1
|
|||
|
|||
Finite Set Question Related to Counting SortHello to all expect C++ programmer,
I have coded a CS but has some memory problem because i don't know how to ensure the the set is finite and memory allocated is enough. For instance, CPP / C++ / C Code:
CPP / C++ / C Code:
I wonder what is finite set ? How to i ensure the sortee is finite set ? Below is my code : CPP / C++ / C Code:
|
|||
|
#2
|
|||
|
|||
Re: Finite Set Question Related to Counting SortBy 'CS' do you mean character string? Shouldn't that be in type char?
> "i don't know how to ensure the the set is finite and memory allocated is enough" If you declare an array it's about as finite as you can get. The space allocated is only gauranteed to be large enough contain the specified number of items. If you write outside of that space you WILL overwrite other data OR get a segfault. Reading outside of that space can cause a segfault. Not clear: do you want to have definite space defined? ...and are looking for a size value? like this? CPP / C++ / C Code:
Please don't use tabs in your code. It's in the guidelines and messes up when I paste it in my editor to try out and must fix.... |
|
#3
|
|||
|
|||
Re: Finite Set Question Related to Counting SortQuote:
CS means counting sort. Quote:
I sure about that. Quote:
My question is What is finite set and how to ensure the data is finite before calling counting sort to ensure that memory is enough to contain the counting. I know that Tabs is not standard over editor/OS. Sorry. I use MS VS C++ 7.0(2005); Do you know any editor that same indentation and have code completion features with MS VS C++ ? I try to switch to Linux. Kdevelop need to adjust indentation when create C++ project. Emacs is too difficult to use. Thanks for your help. |
|
#4
|
|||
|
|||
Re: Finite Set Question Related to Counting Sort> What is finite set and how to ensure the data is finite before calling counting sort to ensure that memory is enough to contain the counting.
Like said the array size is finite but the I guess the 'finite set' would be the number of array elements which have been assigned a value. I guess you wouldn't want to sort 100 array elements if only 10 contained data. Why no just pass the address of the array and it's size to the sort() and heve sort() handle all that. > Sorry. I use MS VS C++ 7.0(2005); ...can't you tell it to use spaces instead of tabs? Complain to Bill about it! (and 'pause' too while you've got him on the phone) Do you really need that monster? Code completion... bah! How are you supposed to learn with that going on? I use gcc CLI and for an editor in windows I use 'textpad' in linux I use 'vim'. I never gave emacs much of a try... |
|
#5
|
|||
|
|||
Re: Finite Set Question Related to Counting SortQuote:
I think you have misunderstand me. Of course, we don' want sort 100 integer but only got 10 data. The rules of finite set is to ensure memory allocated for counting array is same as the original array. STL sort is good but not in linear time. Quote:
This is the reasons i don't want switch to Linux. If linux program these two features, i have no longer be MS World because you can learn a lot of things from g++ compiler options. Thanks. |
|
#6
|
|||
|
|||
Re: Finite Set Question Related to Counting SortQuote:
|
|
#7
|
|||
|
|||
Re: Finite Set Question Related to Counting SortQuote:
|
|
#8
|
|||
|
|||
Re: Finite Set Question Related to Counting SortMy question is
What is finite set and ensure the array is finite set before calling CountingSort ? I not very good in Mathematics. Thanks. |
|
#9
|
|||
|
|||
Re: Finite Set Question Related to Counting SortMy understanding is a 'finite set' would be a closed set of elements. onlinemathlearning.com/finite-sets.html
That is it would have a starting point and an ending point and a total number of elements. I believe your declared array above would fit that description. You know how to determine the number of elements. I don't know how you could sort an infinite list or list of unknown length (unless there was a stated marker (like NULL)). |
|
#10
|
|||
|
|||
Re: Finite Set Question Related to Counting Sortyes, i read that too but doesn't understand. Finally, i understand that finite set it is a set with accurate length.
This algorithm is suitable for lenght less than 100 due to extra memory space which is unpractical for commercial/Industry. |
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Please, This is Difficult question try for me! | bcompt143 | C++ Forum | 4 | 24-Aug-2008 10:14 |
| Question related to Operator overloading | Archer | C++ Forum | 6 | 09-Jun-2008 18:26 |
| How to sort in C++ alphabetically | wilen | C++ Forum | 5 | 20-Apr-2007 15:43 |
| C++ Syntax Highlighter related question | JdS | GIDForums™ | 4 | 25-Oct-2004 09:00 |
| 'Related articles' php /mysql question | JdS | MySQL / PHP Forum | 4 | 06-Sep-2002 11:17 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The