iammrkcohen
asked on
LinkedListNote and 70-536 Exam
Can anyone help to explain to me how the heck this little program returns "E, B, D, A, C"?
My real problem is that I'm not getting how the LinkedListNode thing works. I understand LinkedList.AddFirst and LinkedList.AddLast...etc. But when it comes to the LinkedListNode = LinkList.AddBefore(LinkedL istNode, item) I get really lost. How does this work?
The MSDN explanation sort of confuses me more.
http://msdn.microsoft.com/en-us/library/ahf4c754.aspx
My real problem is that I'm not getting how the LinkedListNode thing works. I understand LinkedList.AddFirst and LinkedList.AddLast...etc. But when it comes to the LinkedListNode = LinkList.AddBefore(LinkedL
The MSDN explanation sort of confuses me more.
http://msdn.microsoft.com/en-us/library/ahf4c754.aspx
Module Module1
Sub Main()
Dim v1 As String
Dim v2 As String
Dim v3 As String
Dim v4 As String
Dim v5 As String
v1 = "A"
v2 = "B"
v3 = "C"
v4 = "D"
v5 = "E"
Dim vList As New LinkedList(Of String)
Dim vNode As LinkedListNode(Of String)
vNode = vList.AddFirst(v2) ' b - makes sense
vList.AddFirst(v5) ' e, b - makes sense
vList.AddLast(v3) ' e, b, c - makes sense
vNode = vList.AddAfter(vNode, v1) ' e, b, a, c - makes sense
vNode = vList.AddBefore(vNode, v4) ' ??????????? - not a clue
For Each v As String In vList
Console.WriteLine("{0}", v)
Next
End Sub
End Module
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks so much. I've solved several of these correctly now. Now on to the other 10,000 topics for this exam.
Thanks,
Mike
Thanks,
Mike
ASKER
so:
vNode = vList.AddAfter(vNode, v1) ---> vNode would become v1 here?
vNode = vList.AddBefore(vNode, v3) ---> vNode would become v3 here?