Abstract data type constructed from combinations of the four fundamental data types

Posted on 2006-05-24
Last Modified: 2010-03-31

Another quick question. Does anyone know of any abstract data types constructed from the following types of data types,

- a set with components which are sets
- a set with components which are lists
- a list with components which are sets
- a tree with components which are lists

and so on. Any help really appreciated.

Question by:nhay59
    LVL 14

    Expert Comment

    a set with components which are sets
    new Set<Set>();

    a set with components which are lists
    new Set<List>();

    and so on

    Author Comment


    Thanks for the reply. I'm sorry, I should have been more specific. I'm trying to find examples of complex data types that are constructed from the combinations of other data types, eg: a set of sets

    I'm not currently trying to code this, buit think of theoretical aspect of the ADTs.

    Thanks for any help.
    LVL 4

    Accepted Solution

    A set of sets could be used to model an unordered n-ary tree.

    A leaf would be represented as {} and a branch { Left, Right }

    Therefore a simple tree with 1 as the root and 2 and 3 as leaves would be { 1, {2,3} }

    You can extend this to binary trees if it is a list of lists (lists are ordered, important for binary trees).

    A set with components that are lists could be used to model a map.  

    The list < {A,1}, {B,2}, {C,3} > could represent a Map, A->1, B->2, C->3

    Not that these are particularly good ways of implementing this sort of idea :)

    Author Comment


    Thanks for the help.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    fix34  challenge 9 73
    fetching the full url inside controller 2 31
    changeXy challenge 13 41
    for i loop in grovy 1 26
    INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
    Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
    The viewer will learn how to implement Singleton Design Pattern in Java.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now