Data Structure tutorial (Java description) edited by Xu xiaokai-review abstract 02

Source: Internet
Author: User
Tags set set

Chapter 1 Set

A set is also called a set structure. It is composed of different data elements of the same type. There is no logical relationship between elements.

To facilitate insertion and deletion of nodes in a single-chain table that represents a set, a valueless node is usually added to the header, which is called an additional header node.

Sequential storage structure and operation implementation of a Set

Public class sequenceset implements set {final int maxsize = 10; // initial length of the array private object [] setarray; // array declaration, the element type is the system-provided base class private int length; // The current length of the Set // The Operation Public sequenceset () {} public sequenceset (int n) {} public Boolean add (Object OBJ) {} public Boolean remove (Object OBJ) {} public Boolean contains (Object OBJ) {} public object value (int I) {} public object find (Object OBJ) {} public int size () {} public Boolean isempty () {} public void output () {} public set union (Set set) {} public set intersection (Set set) {} public void clear (){}}

Link storage structure and operation implementation of a Set

Public class node {object element; node next; Public node (node nextval) {next = nextval;} public node (Object OBJ, node nextval) {element = OBJ; next = nextval ;}} public class linkset implements set {private node head; // header pointer private int length; // chain table length}

A set is a data structure. When performing operations on any data structure, you must first define the abstract data type and then define the corresponding abstract interface class, an Implementation class that uses a storage structure.

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.