Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Self sorting is a little bit to ambigious. First of all</p> <p><strong>What kind of data structure?</strong></p> <p>There are a lot of different data structures out there, such as:</p> <ul> <li>Linked list</li> <li>Double linked list</li> <li>Binary tree</li> <li>Hash set / map</li> <li>Stack </li> <li>Heap</li> </ul> <p>And many more and each of them behave differently than others and have their benefits of course.</p> <p>Now, not all of them could or should be self-sorting, such as the Stack, it would be weird if that one were self-sorting.</p> <p>However, the Linked List and the Binary Tree could be self sorting, and for this you could sort it in different ways and on different times.</p> <p><strong>For Linked Lists</strong></p> <p>I would preffere <a href="http://en.wikipedia.org/wiki/Insertion_sort" rel="nofollow noreferrer">Insertion sort</a> for this, you can read various good articles about this on both wikis and other places. I like the pasted link though. Look at it and try to understand the concept.</p> <p>If you want to sort after it is inserted, i.e. on random times, well then you can just implement a sorting algororithm different than insertion sort maybe, <a href="http://en.wikipedia.org/wiki/Bubble_sort" rel="nofollow noreferrer">bubblesort</a> or maybe <a href="http://sv.wikipedia.org/wiki/Quicksort" rel="nofollow noreferrer">quicksort</a>, I would avoid bubblesort though, it's a lot slower! But easier to gasp the mind around.</p> <p><strong>Random Access</strong></p> <p>Random is always something thats being discusses around so have a read about how to perform good randomization and you will be on your way, if you have a linked list and have a "getAt"-method, you could just randomize an index between 0 and n and get the item at that index.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload