Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: java oop

  1. #1
    Junior Member
    Join Date
    Nov 2019
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default java oop

    public class DLNode {
    public int Element;
    public DLNode left;
    public DLNode right;
    }


    You may NOT use Java’s built-in data structure libraries, like java.util.LinkedList, in this homework. All
    data structure implementations should be your own or those taken from lectures. You can not use stack
    or queue in your implementations.



    public void SquashL(); // SquashL takes the linked list and trace the
    contiguous blocks in the list. After initiating the method, it changes the
    linked list into the list such that there are tuples: the element and number
    of occurrence in the list.

    For example, if the list is [1 2 3 3 3 3 2 2 2 2 1 2 2 3 2], after initiating
    the method the link list converts to: [1 1 2 1 3 4 2 4 1 1 2 2 3 1 2 1]

    --- Update ---

    public void SquashL() {
    DLNode dummy=head; //ı want to use just lınk of head so ı dont create new node ı use lınk of ıt ın dummy
    //starting dummy
    int b=1;//what ever *element ıs at least it has 1 times in list so we r starting fom "
    int a = 0; //for getting element of nodes


    for(int i=0;i<numElements;i++){


    dummy.Element=a;//listemin başlangıç node u
    DLNode dummy1=head; // hangi node oldugu
    DLNode howmuch = new DLNode();//araya koyacagım

    if(a==dummy1.right.Element){
    while(dummy1.right.Element==a){ //checling how many time this element repating
    b++;// ı get the number here
    numElements--;// my size wıll be decrease becasue ı ll elımınate repeating elements
    dummy1=dummy1.right; // for checking nextnode
    }

    howmuch.Element=b;

    howmuch.right=dummy1;
    howmuch.left=dummy;
    howmuch=dummy.right;
    dummy1.left=howmuch;


    numElements++;

    }

    else{
    DLNode one = new DLNode();
    one.right=dummy.right;
    one.left=dummy;
    dummy.right=one;
    one.right.left=one;
    one.Element=1;
    numElements++;
    }

    for(int t=0;t<2;t++)//hiç değişmeyen headımden 2 2 kayıcam buyuk for a gore sıradakı eleman için
    dummy=head.right;
    }
    }

    --- Update ---

    plss HELP MEE I M STUCK IN THIS METHODDDD

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: java oop

    Do you have any java programming questions?

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Tags for this Thread