Click here to Skip to main content
16,004,991 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i read too many methods for this purpose but now i am confused bcz some methods are good but they are not workable in all conditions so i need a good and easy method which works in all situation even if we don't know the length of array
please write at least one program only which solves any problem about this topic
I am waiting
Thanks in advance....

What I have tried:

i tried many methods and they are very long and complex that's why i need a simple and understandable method which saves my time
So please tell me your method which u are using now.
Posted
Updated 21-Jun-18 5:34am
Comments
CPallini 21-Jun-18 9:10am    
You MUST know the size of an array.
(an array terminator is the poor man alternative).
jeron1 21-Jun-18 10:26am    
What? no mention of using STL containers? Methinks you're slipping! ;)
CPallini 21-Jun-18 13:06pm    
I'm growing older...
:-)

You always know the size of an existing array. Either by knowing the size itself or by looking for a specified end marker which can be found by iteration (e.g. the NULL character identifying the end of a C type string).

For sorting algorithms just search the web for something like "c++ sort algorithms". Most programmers will use advanced sorting algorithms because they prefer performance to saving their own time (especially because there are lot of example implementations). A common programmer will just use one of C++ standard sort methods.

However, the simplest (easiest to understand) sorting algorithm is probably "Bubble Sort".

Quote:
please write at least one program only which solves any problem about this topic
That is not going to happen here. We do not provide code on order.

Quote:
which saves my time
But we should invest our time instead?
 
Share this answer
 
Comments
CPallini 21-Jun-18 9:08am    
5.
Member 13881359 21-Jun-18 12:06pm    
Thanks for your advice
i tried to follow your advice
But i did not mean which u got from my message actually i want the path on which solution of my problem is present bcz i am new in this field that's why i commit such a mistake for which i am sorry if u mind
Quote:
please write at least one program only which solves any problem about this topic

No.
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
 
Share this answer
 
Comments
CPallini 21-Jun-18 9:09am    
5.
Member 13881359 21-Jun-18 12:07pm    
Thanks for your advice
i tried to follow your advice
But i did not mean which u got from my message actually i want the path on which solution of my problem is present bcz i am new in this field that's why i commit such a mistake for which i am sorry if u mind
OriginalGriff 21-Jun-18 12:18pm    
We're still not doing your homework for you!
And if you think there is a single "the path" to solve your problem then you have a lot to learn about development - there are more solutions than there are developers...
Do some research into sorting algorithms (google and wiki are your friends here) and pick one that will do the job.
Member 13881359 21-Jun-18 12:44pm    
can u tell me that which programming language is growing up nowadays
OriginalGriff 21-Jun-18 13:59pm    
Most of 'em!
The mainstream languages get additions and enhancements all the time: C++20 is in progress: https://isocpp.org/std/status
And C# 7.0 is pretty recent!
Read this overview of sorting algorhitms. Normally the divide and conquer is a good choice. Not only for sorting but also in lookup.

Tailoring the code for your needs is your tasks.
 
Share this answer
 
Comments
Member 13881359 21-Jun-18 12:07pm    
Thanks sir
Quote:
i read too many methods for this purpose but now i am confused bcz some methods are good but they are not workable in all conditions so i need a good and easy method which works in all situation even if we don't know the length of array

There is no method that can sort an array without knowing its size.
There is no magic method that can guess what is in your head.
Whatever the sort method you use, there is a time where you have to explain what you want you sort and how, no matter what.
Quote:
please write at least one program only which solves any problem about this topic
I am waiting

As already said, there is no such magic method.
Quote:
i tried many methods and they are very long and complex that's why i need a simple and understandable method which saves my time

Supposing you are a good programmer:
- the most simple methods will be inefficient and perform poorly.
- the most efficient methods will be complex.
There is a special case for bad programmers that can have complex methods that are inefficient.

Example: you have to sort a list of millions of numbers, all of them are same number of digits.
Without any complementary information, it is a huge task, whatever the method used.
If you know they are the phone numbers of your country, it is a special case which allow a method specially tailored for this case and it will out perform any other method.
 
Share this answer
 
v2
Comments
Member 13881359 21-Jun-18 12:08pm    
i got it and try next time not to commit such a mistake
Thanks sir

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900