C # data structure and algorithm series (3) linked list of linear tables

Source: Internet
Author: User

The chain storage of a linear table is called a linked list. Features: the non-continuous and non-sequential Storage Structure on the storage unit. The logical sequence of data elements is achieved through the pointer link sequence in the linked list.
A linked list consists of a series of nodes (each element in a linked list is called a node), which can be dynamically generated at runtime. Each node consists of two parts: one is to store data elements
The other is the pointer field that stores the next node address.
Linked lists include single-chain tables and two-way linked lists.
The following describes how to implement a single-chain table:

 

Public   Class Node < T >
{
Private T data;
Private Node < T > Next;

Public Node (T val, Node < T > P)
{
Data = Val;
Next = P;
}
Public Node (Node < T > P)
{
Next = P;
}
Public Node (T val)
{
Data = Val;
}
Public Node ()
{
Data =   Default (T );
Next =   Null ;
}
Public T Data
{
Get { Return Data ;}
Set {Data = Value ;}
}
Public Node < T > Next
{
Get { Return Next ;}
Set {Next = Value ;}
}
}

Public   Class LinkList < T >
{
Private Node < T > Head;
Public Node < T > Head
{
Get { Return Head ;}
Set {Head = Value ;}
}
Public LinkList ()
{
Head =   Null ;
}
Public   Int GetLength ()
{<

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.