Results 1 to 8 of 8
  1. #1
    ras_oscar is offline Member
    Join Date
    Jun 2013
    Posts
    60
    Rep Power
    0

    Default Learning how to use data structures

    Where could I find a tutorial on data structures? I'd like to create several compound data structures, below is a dummy example to describe the concept;

    Struct car
    {
    string tire;
    int cylinders;
    string model name;
    long serial number;
    Struct directions;
    }

    Struct directions
    {
    String step 1;
    String Step 2;
    String Step 3;
    String Step 4;
    }

    I realize I am asking a broad question, but I would like to explore the implications of my choices, and before I organize the program data structure, understand things like

    how do I add elements
    How do I sort, alphabetize, and search the data structures
    if I put each " structure" in its own class, do I end up writing more code to do low level functions like sort and search?

    This is not a school assignment, this is a hobby writer trying to get started.


    }
    Last edited by ras_oscar; 08-07-2013 at 10:31 PM. Reason: previous post incomplete

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,157
    Rep Power
    6

    Default Re: Learning how to use data structures

    Whole books have been filled discussing this very subject, there is no "tutorial" that is going to make you understand this complicated and highly theoretical subject. Heck, it took two years of schooling for me.

    To get you feet wet, try researching into linked lists, binary searching and bubble sort; google and wikipedia are your friends. Those subjects is what I started out with in school too.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    ras_oscar is offline Member
    Join Date
    Jun 2013
    Posts
    60
    Rep Power
    0

    Default Re: Learning how to use data structures

    Is it possible to define a user data type or is this a C++ thing?

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,810
    Rep Power
    5

    Default Re: Learning how to use data structures

    Yep! They're called objects.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,157
    Rep Power
    6

    Default Re: Learning how to use data structures

    Quote Originally Posted by jim829 View Post
    Yep! They're called objects.

    Regards,
    Jim
    (pedant: classes?)
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,810
    Rep Power
    5

    Default Re: Learning how to use data structures

    Yeah, the OP did say define not create.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  7. #7
    ras_oscar is offline Member
    Join Date
    Jun 2013
    Posts
    60
    Rep Power
    0

    Default Re: Learning how to use data structures

    Am I correct in concluding that in order to do what I want,I would need to create a class with the data values outside all other methods? Would I derive from an existing Java class or create something stand alone?

  8. #8
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,810
    Rep Power
    5

    Default Re: Learning how to use data structures

    Well, I am not exactly certain what you want. You could create a class of Car and Directions.

    class car {
    string tire;
    int cylinders;
    string model name;
    long serial number;
    Directions directions;
    }

    class Directions {
    String step1;
    String step2;
    String step3;
    String step4;
    }

    You may also include methods to manipulate the fields. You can then add one or more instances to a linked list or array. If you want to do sorting, you can either implement your own sort routines or implement specific interfaces that allow other utility classes to sort for you. It all depends on what exactly you want to do.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Help about data structures and algorithms
    By herolua in forum New To Java
    Replies: 2
    Last Post: 05-21-2011, 06:57 AM
  2. Please help in data structures
    By pheonix in forum New To Java
    Replies: 0
    Last Post: 03-27-2009, 11:41 AM
  3. C like data structures in java ?
    By ankitmcgill in forum New To Java
    Replies: 10
    Last Post: 11-09-2008, 02:53 PM
  4. Sux data structures 1.0.1
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 04-15-2008, 07:54 PM
  5. Data Structures Help...
    By jac0117 in forum New To Java
    Replies: 1
    Last Post: 01-12-2008, 08:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •