How many elements need to be accessed in a get(x) operation in doubly linkedlist?

There isn't a single correct answer to this. It actually depends on the way that the get(position) method is implemented.

  • If the implentation always traverses the list in one direction (either forward or backward) then the worst case is N steps.

  • If the implentation traverses the list from the one end or the other depending on the value of the position, then the worst case is N/2 steps.

But there is a catch. In order to do it the "smart" way, the list implementation has to keep a record of the list's size. Without this, it must calculate the size ... which involves traversing the entire list.

(Oracle / OpenJDK LinkedList implementations are specified as traversing from either end in all Java versions that I looked at. However, you have not said if you are talking about the standard implementations.)

The average case is also not quite as straight forward as you would think. It actually depends on the distribution function for the positions you look up. If the distribution function is "flat"; i.e. all positions are equally probable, then the average number of steps is half of the worst case. Otherwise ... not.

Answer:1

After my research and discussion here I decided I need to set the same name for threads on different JVMs which belong to the same control flow in the distributed system. Threads are created e.g. by ...

I have made an application in which a JForm containing the JTextfields,JButtons. When I click a button I want to display the data of JTextfield in JTable. How can I do this anybody help me. I know how ...

NullPointerException at if (hrefAttr.contains("?")) I'm running into a problem. I'm using selenium and JUnit to parse through links and compare them to a list of links provided from a CSV file. ...

I have used Eclipse Helios 3.6.1 for Java development. I wanted to start C++ development in the same IDE so I installed Autotools Support For CDT, C/C++ Development Tools, C/C++ Library API ...