Linked List

alien

Newcomer
Joined
Mar 21, 2006
Messages
24
iam learning vb.net and i need help in understanding the linked list class. i have this assignment am trying to do

Introduction
Ourworld is a travel company that provides worldwide flight routes for travellers.The company wants to improve the way in which it creates records and maintains flight routes. It is proposed that the flight route for each traveller will be defined by a linked list. Each node that forms part of such a linked list would be an airport. The resources available at any airport would be detailed via a suitable database. Entities such as Destinations, Date, Time, Carrier, Flight Number, and Seat Class would be part of the information
stored in the database for each airport.
Aims
Produce a prototype of a software system to demonstrate to the management of Ourworld by:
1. Designing, implementing and testing a linked list class.
Any linked list object instanced from this class must include the properties and methods:
• Forward link
• Node Text
• Add/Insert node
• Remove node
2. Designing, implementing and testing a procedure that would Traverse a linked list
generating a graphical representation of the linked list using label controls.
3. Designing, implementing and testing a simple database to demonstrate how clicking on a label control, that represents a node of the linked list, the detail of that part of the flight route could be displayed.
Task 1
Design an appropriate linked list class by carefully considering all the properties, methods and
events demanded by the application outlined above.
NOTE that you may wish to design a node class before you design the linked list class. Pay
attention to any data validation that would be required.
Task 2 Implement and test the class designed in Task 1
Task 3
Design a procedure for traversing the linked list and displaying the node text properties in a collection of label screen controls.
The procedure should show graphically how the nodes of the linked list are connected.
Task 4
Implement and test the procedure designed in Task 3.
Task 5
Design a simple database that would be sufficient to demonstrate the information that would have to be associated with each node.
Task 6
Using Microsoft Access set up the database designed in Task 5.
Populate the database with suitable test data.
Task 7
By using a suitable event, which should have been designed into the linked list class, implement the means by which a click on the label that represents a particular linked list node produces a display of the database data stored about that node.

please help!!!!!!!!!!!!!!!!!!!!!!!
 
Do you have a particular problem you would like help with: explanation of a linked list, implementation ideas, testing methodologies or tips etc?

If so feel free to ask, you are unlikely to get many responses to a cut and paste of a school / college / whatever assignment though.
 
thanks for your response
actually i need help in creating a procedure that would traverse a linked list and return the data in each node in the same order they were entered
 
It would greatly help to know what you've already done and what version of VB.NET you're using. In the 2.0 framework there is a generic type called LinkedList - are you using that? Or, is this an assignment to create the linked list from scratch?

Since it's against policy to "do" homework assignments for people, we can only offer advice on what you've already done or offer suggestions/partial solutions to code where you're stuck.

-ner
 
ok
i have an access database.iam able to read the contents of the database and insert them into a linked list. i have created a linked list class from scratch with methods to insert and delete a node. that is working fine. the major problem is traversing through the linked list and displaying the contents of each node into labels, or a listbox on the form. iam using visual studio.net 2003.
this is what i have:

the linked list class
Visual Basic:
Public Class ListNode
    Public data As Object
    Public link As ListNode
    Public list As ListBox
    Public Sub New()
        data = "empty"
        link = Nothing
    End Sub
    Public Sub AdditemTop(ByRef LN As ListNode, ByVal obj As Object)
        If LN.data = "empty" Then
            LN.data = obj
            Exit Sub
        End If
        Dim tempnode As New ListNode
        With tempnode
            .data = obj
            .link = LN
        End With
        LN = tempnode
    End Sub
    'list
    Public Sub Traversal(ByVal LN As ListNode)
        If Not LN Is Nothing AndAlso LN.data <> "empty" Then
            MessageBox.Show(LN.data)
            Traversal(LN.link)
        End If
    End Sub
    Public Sub remove(ByRef LN As ListNode)
        If LN.data = "empty" Then
            Exit Sub
        End If
        If Not LN.link Is Nothing Then
            Dim temp As ListNode
            temp = LN
            LN = LN.link
            temp = Nothing
        Else 'there is only one node left
            LN.data = "empty"

        End If
    End Sub
End Class
the method called traversal works fine. it displays the contents of each node on the messagebox. what can i do to have it displayed on a listbox or labels on a form??
 
Last edited by a moderator:
If your class implements the System.Collections.IEnumerable interface then it should work as a valid datasource - this means you could simply do something like
Visual Basic:
ListBox1.DataSource = <variable of your linked list type>
 
Back
Top