Good Day,
Can someone confirm what was said at the bottom of this post java - iterating a linked list The post mentions that you can use the for(char c: linkedlistofchars) syntax and it will still be O(n). I would think accessing a list that looks like this...
a b c d e f
would actually run start at the beggining of the linked list during every iteration of the for loop, like this...
a ab abc abcde abcdef
causing the access time not to be O(n).
How exactly does that work? It makes sense with an array and the array operators, but how does the java syntax know how to iterate through a linked list using the foreach loop in java?
I thought the LinkedList data structure was just an additional library and not part of the core language syntax. (I do realize that the LinkedList class is standard in java)
I hope I explained my concern clearly enough.... Thanks