Word sorting program

  • (10 Pages)
  • +
  • « First
  • 8
  • 9
  • 10

140 Replies - 6700 Views - Last Post: 04 November 2013 - 03:14 PM Rate Topic: -----

#136 lewm  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 160
  • Joined: 29-March 13

Re: Word sorting program

Posted 04 November 2013 - 01:48 PM

View Postjimblumberg, on 04 November 2013 - 01:40 PM, said:

Then why can't you answer my question as to what type of sort you are currently using. It is the most basic of sorts, so you should be able to answer that question.


Jim

No I cant, that was my question.
I didn't say I fully understood them all...

Ive not seen any sort use pointers so I don't know what sort this is, I didn't find the algorithm or code it was completely my own.

Ive been looking at different quicksort examples and im still having trouble understanding how to write the code, I need a good example of complete code to study so I can get my head round it, can you help?

This post has been edited by lewm: 04 November 2013 - 01:51 PM

Was This Post Helpful? 0
  • +
  • -

#137 jimblumberg  Icon User is online

  • member icon


Reputation: 4025
  • View blog
  • Posts: 12,432
  • Joined: 25-December 09

Re: Word sorting program

Posted 04 November 2013 - 02:12 PM

Let me state this as simply as I can. If you can't identify the type of sort that you're currently using I don't give you much hope of figuring out the different sorting methods without a lot of help.

If you're so confused by pointers then I suggest you stop using C-strings and stick with ints until you figure out the differences. Try setting up a program that just uses ints and try the different sort methods. Don't be afraid of copying code from tutorials you find on the net, sorting is not something you will be able to come up with on your own, unless your a Math Wizard. Once you find a sort method that seems to do the job, you can single step through the sort to get an idea of what is going on but remember that most sort algorithms were developed by scientists versed in both mathematics and computer science.

By the way that sort you're currently using is a type of bubble sort, the simplest, but slowest of all the soring methods. You speed problems is not being caused by the time it takes to swap the elements, but the number of comparisons that must be preformed to produce the sort.

And again try to find a tutorial for the sorts you want to try, in the language you're using, and insert the code into your program and try it. No one will expect you to totally understand these sorts unless you're a gifted mathematician. Sort routines are one of the few pieces of code that most people copy from a reputable tutorial or paper, just don't forget to document where the code was obtained.


Jim

This post has been edited by jimblumberg: 04 November 2013 - 02:13 PM

Was This Post Helpful? 0
  • +
  • -

#138 lewm  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 160
  • Joined: 29-March 13

Re: Word sorting program

Posted 04 November 2013 - 02:30 PM

View Postjimblumberg, on 04 November 2013 - 02:12 PM, said:

Let me state this as simply as I can. If you can't identify the type of sort that you're currently using I don't give you much hope of figuring out the different sorting methods without a lot of help.

If you're so confused by pointers then I suggest you stop using C-strings and stick with ints until you figure out the differences. Try setting up a program that just uses ints and try the different sort methods. Don't be afraid of copying code from tutorials you find on the net, sorting is not something you will be able to come up with on your own, unless your a Math Wizard. Once you find a sort method that seems to do the job, you can single step through the sort to get an idea of what is going on but remember that most sort algorithms were developed by scientists versed in both mathematics and computer science.

By the way that sort you're currently using is a type of bubble sort, the simplest, but slowest of all the soring methods. You speed problems is not being caused by the time it takes to swap the elements, but the number of comparisons that must be preformed to produce the sort.

And again try to find a tutorial for the sorts you want to try, in the language you're using, and insert the code into your program and try it. No one will expect you to totally understand these sorts unless you're a gifted mathematician. Sort routines are one of the few pieces of code that most people copy from a reputable tutorial or paper, just don't forget to document where the code was obtained.


Jim

I didn't say I was confused by pointers and I know the differences.
I only want to use the quicksort method.
You said sorting is not something I would be able to come up with on my own, well I've come up with 3 different methods on my own all be it slow.
I've found sort methods that work and have posted code which shows this.
dream in code good practise:
Do:
Provide in-depth explanations & details
Include links to documentation & references
Be polite and professional
Provide a solution others will find useful in the future
Do Not:
Enforce rules in replies, use the "Report" button instead
Just tell someone to "Google It"
Be rude or hijack topics just to criticize the OP
You have told me to Google it before you just seem to point out my lack of knowledge and what I cant do and don't provide very much help. Its quite frustrating and disheartening.

Help is what im asking for.

This post has been edited by lewm: 04 November 2013 - 02:35 PM

Was This Post Helpful? 0
  • +
  • -

#139 jimblumberg  Icon User is online

  • member icon


Reputation: 4025
  • View blog
  • Posts: 12,432
  • Joined: 25-December 09

Re: Word sorting program

Posted 04 November 2013 - 02:38 PM

Well then I'll stop trying to help. You have a topic that is has over one hundred and thirty posts about this topic and you still can't tell the difference between different basic sorting algorithms. So good luck.

Jim

This post has been edited by jimblumberg: 04 November 2013 - 02:38 PM

Was This Post Helpful? 0
  • +
  • -

#140 lewm  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 160
  • Joined: 29-March 13

Re: Word sorting program

Posted 04 November 2013 - 02:46 PM

Look jim im sorry, we seem to keep butting heads, I keep saying it: im not the smartest person in the world.
If I had all the answers I wouldn't be on here.
Was This Post Helpful? 0
  • +
  • -

#141 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3553
  • View blog
  • Posts: 11,017
  • Joined: 05-May 12

Re: Word sorting program

Posted 04 November 2013 - 03:14 PM

View Postlewm, on 04 November 2013 - 03:48 PM, said:

Ive been looking at different quicksort examples and im still having trouble understanding how to write the code, I need a good example of complete code to study so I can get my head round it, can you help?


If you are having a hard time understanding a sorting algorithm, complete code is actually the last thing that you need. The code will distract you from the key concepts of how the algorithm works. A whiteboard/chalkboard, or pen and paper, or a deck of cards is actually going to be better learning aids.

Here's the pseudo-code from wikipedia that you need to follow:
function quicksort(array, left, right)
     // If the list has 2 or more items
     if left < right
         // See "#Choice of pivot" section below for possible choices
         choose any pivotIndex such that left ≤ pivotIndex ≤ right
         // Get lists of bigger and smaller items and final position of pivot
         pivotNewIndex := partition(array, left, right, pivotIndex)
         // Recursively sort elements smaller than the pivot
         quicksort(array, left, pivotNewIndex - 1)
         // Recursively sort elements at least as big as the pivot
         quicksort(array, pivotNewIndex + 1, right)



For now just pick the number that happens to be in the middle of the range as your pivot and don't get bogged down by the details of better choices for pivots.
Was This Post Helpful? 0
  • +
  • -

  • (10 Pages)
  • +
  • « First
  • 8
  • 9
  • 10