Click here to Skip to main content
15,884,931 members
Please Sign up or sign in to vote.
1.33/5 (3 votes)
See more:
anyone can provide here code for searching,sorting and string matching algorithms.

What I have tried:

C#
public List<int> quicksort( List<int> a)
{
    Random r = new Random();
    List<int> less = new List<int>();
    List<int> greater = new List<int>();
    if (a.Count &lt;= 1)
        return a;
    int pos =r.Next(a.Count);
    
    int pivot = a[pos];
    a.RemoveAt(pos);
    foreach (int x in a)
    {
        if (x &lt;= pivot)
        {
            less.Add(x);
        }
        else
        {
            greater.Add(x);
        }
    }
    return concat(quicksort(less), pivot, quicksort(greater));
}
Posted
Updated 27-Apr-16 21:27pm
v2
Comments
BillWoodruff 27-Apr-16 23:47pm    
What's the matter with what you have tried ? Does it work ? If it doesn't work, what have you done to debug it ... what are the error messages, and where do they occur. If it runs, but does not result in the type of sort you intend: how is the result different from the expected result.

Do some work, analyze it, explain it here, and we'll be happy to help.
Patrice T 28-Apr-16 3:11am    
You don't have Google ?

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!
So just posting "provide here code for ..." and a lump of code that may or may not work without any explanation of why it's there is not going to get you anywhere useful!
 
Share this answer
 
Don't search for code. Study algorithms instead. An oldie-goldie book is Wirth's one: "Algorithms + Data Structures = Programs - Wikipedia, the free encyclopedia"[^]. It could be a staring point, covering all but string matching.
 
Share this answer
 

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