c++ - Insertion into a skip list -


A left list is a data structure in which the elements are stored in order of order and each node The list can be more than 1 indicator, and it can be used to reduce the time required for a search operation from O (ng) to O (lg n) seems to be for the average case:

Leave the list

Reference: "Leave list" Wojciech Muhammad Dwa Ra? One - Own work licensed through Wikimedia Commons under the public domain -

It can be viewed as a ruler to have a similarity:

 ruler marks

In a wig list, it is ok to find an element and remove one, but when it comes to entry It is difficult, because structures and algorithms according to the data in C ++: 2 versions by Adam Drozdek: :

To insert a new element, all the nodes need to be restructured just after the inserted node; The number of pointers and the value of pointers must be changed.


I can assume that even though selecting nodes with random number of nodes based on the probability of nodes

My question is < / p>

strong>: Why can not we insert in the new node, determine the number of indicators based on the previous node, at the end of the list Attach, and then just use the sorting algorithm to sort the data in the bus. Nodes, thereby maintaining the structure of the left list and O (lg n) insert complexity to achieve?

Edit : I have not tried any code yet, I'm just presenting a view simply because it is difficult to implement a drop list . Pardon.

You have a problem at this point and then just sort the sorting algorithm for sorting Use the data present in the nodes to sort the data will be complexity o (n * lg (n)) and thus the complexity of the entry will increase. In theory, you can choose the "perfect" link for each node, but even if you do so, when you perform the removal work, the completion will be "broken." Using a random approach is quite close to the right structure to fix it.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -