Results 1 to 14 of 14
  1. #1
    ayoood is offline Member
    Join Date
    May 2008
    Posts
    39
    Rep Power
    0

    Default i need same of help

    Hi every body
    How are you??
    i need same of help plz
    Could anyone solve for me this problem??
    thank you for your help :)

    Due: May 4, 2008

    1. Create your own version of the Java program to implement a linked list as explained in class.

    2. Create a Java program for doubly linked lists and provide input and output.

    3. Analyze examples with generic classes given in class used in building linked lists. Make your own example.

  2. #2
    theonly is offline Member
    Join Date
    Apr 2008
    Posts
    23
    Rep Power
    0

    Default

    Well, it's hard to do any of that without being in your class? :)

  3. #3
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    Ofcourse...

    Due: May 4, 2008

    1. Create your own version of the Java program to implement a linked list as explained in class.

    2. Create a Java program for doubly linked lists and provide input and output.

    3. Analyze examples with generic classes given in class used in building linked lists. Make your own example.
    Try to attempt an effort..... There are experts here that are ready to help you out....(problem about your code.)
    Last edited by sukatoa; 05-01-2008 at 04:45 PM.
    freedom exists in the world of ideas

  4. #4
    ayoood is offline Member
    Join Date
    May 2008
    Posts
    39
    Rep Power
    0

    Default

    its an assignment if you need to attemt the lecture i will

  5. #5
    ayoood is offline Member
    Join Date
    May 2008
    Posts
    39
    Rep Power
    0

    Default

    http://www.nmehic.com/csci260/Lectur...Final%20SQ.ppt

    this is the lecture

    think you again for your help

  6. #6
    theonly is offline Member
    Join Date
    Apr 2008
    Posts
    23
    Rep Power
    0

    Default

    Like Sukatoa, said try this yourself, first. I will gladly help you, but give this a honest attempt. Understanding Linked-list is really important if you plan on continuing programming.

  7. #7
    ayoood is offline Member
    Join Date
    May 2008
    Posts
    39
    Rep Power
    0

    Default

    this is my code what the wrong with it

    public class DoublyLinkedList
    {
    public static void main(String args[])
    {
    DoublyLinkedList<Integer> list = new DoublyLinkedListinkedList<Integer>();
    list.addHead(new Integer(1));
    list.addHead(new Integer(2));
    list.addTail(new Integer(9));
    list.addHead(new Integer(3));
    list.addTail(new Integer(11));
    list.add(2, new Integer(0));
    System.out.println(list);
    list.remove(list.size());
    System.out.println(list);
    }

    }

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Lots of errors I can found there pal. Here what you have to do.

    Java Code:
    import java.util.LinkedList;
    
    public class DoublyLinkedList {
    
        public static void main(String[] args) {
            LinkedList <Integer> list = new LinkedList<Integer>();
      
            list.add(new Integer(1));
            list.add(new Integer(2));
            list.add(new Integer(9));
            list.add(new Integer(3));
            list.add(new Integer(11));
            list.add(2, new Integer(0));
    
            System.out.println(list);
    
            list.remove(0);
            System.out.println(list);
        }
    
    }

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  10. #10
    ayoood is offline Member
    Join Date
    May 2008
    Posts
    39
    Rep Power
    0

    Default

    thank you very much for your help

  11. #11
    tito84 is offline Member
    Join Date
    May 2008
    Posts
    1
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    Lots of errors I can found there pal. Here what you have to do.

    Java Code:
    import java.util.LinkedList;
    
    public class DoublyLinkedList {
    
        public static void main(String[] args) {
            LinkedList <Integer> list = new LinkedList<Integer>();
      
            list.add(new Integer(1));
            list.add(new Integer(2));
            list.add(new Integer(9));
            list.add(new Integer(3));
            list.add(new Integer(11));
            list.add(2, new Integer(0));
    
            System.out.println(list);
    
            list.remove(0);
            System.out.println(list);
        }
    
    }


    how does this programme work

    can you tell me each code how work plz

  12. #12
    ayoood is offline Member
    Join Date
    May 2008
    Posts
    39
    Rep Power
    0

    Default

    hi
    i have this programme i don’t know why does not work with me

    class Queue<T> {
    private LinkedList<T> items = new LinkedList<T>();
    public void enqueue(T item) {
    items.addLast(item);
    }
    public T dequeue() {
    return items.removeFirst();
    }
    public boolean isEmpty() {
    return (items.size() == 0);
    }
    public void addAll(Collection<? extends T> collection) {
    // Add all the items from the collection to the end of the queue
    for ( T item : collection )
    enqueue(item);
    }
    }
    Last edited by ayoood; 05-12-2008 at 10:03 AM.

  13. #13
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by tito84 View Post
    how does this programme work

    can you tell me each code how work plz
    First LinkedList is declared and initialized.

    Java Code:
    LinkedList <Integer> list = new LinkedList<Integer>();
    Here you have to define the generic to avoid compiler warnings. Generic is depend on the LinkedList element type. Here it is an Integer. Then populate the linked list. You can do it in different ways.

    Just add elements there.

    Java Code:
    list.add(new Integer(1));
    Here actually no need to instantiate a int value. Simply add.

    Java Code:
    list.add(1);
    Or you can define the index that where you want to add the element.

    Java Code:
    list.add(2, new Integer(0));
    But you can't skip index there. Then remove element,

    Java Code:
    list.remove(0);
    Remove the 0th element of the list.
    Last edited by Eranga; 05-12-2008 at 03:48 AM.

  14. #14
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by ayoood View Post
    could you change the name of programme to generic plz
    I don't know what you are trying to do. See that your class declaration also incorrect. And defining generics for LinkedList too.

    It's much better to do some work with basis of Java, then try some applications like this.

Posting Permissions

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