VB.NET exercises and solutions: singly linked list element


Singly linked list

Element of Singly linked list

Step 1: Define element and operations of the singly linked list

The linked list element has two parts--data and a link. Therefore, we define the the element of the linked list by using a class that has two members--data and next link.

C single linked list

VB.NET code to define list element

'List element class
Class ListNode
 Public val As Integer 'element data
 Public nextlk As ListNode 'next link
   Sub New(ByVal elem As Integer)

     val = elem
      nextlk = Nothing

   End Sub

End Class

The operations of the linkedlist can be outlined as methods of abstract class ClsList that is inherited by the LinkedList class.

MustInherit Class ClsList


 Public Overridable Sub insert(ByVal val As Integer, ByVal pos As Integer)
 End Sub
 Public Overridable Sub delete(ByVal pos As Integer)
 End Sub
 Public Overridable Function countitem() As Integer
   Return 0
 End Function

 Public Overridable Sub showall()
 End Sub
 Public Overridable Function find(ByVal Val As Integer) As ListNode
   Return Nothing
 End Function
 Public Overridable Function findmin(ByVal Val As Integer) As ListNode
   Return Nothing
 End Function
 Public Overridable Function findmax(ByVal Val As Integer) As ListNode
   Return Nothing
 End Function


End Class



Comments





This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.