Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

ajprincess

  • 3 years ago

Please help:)

  • This Question is Closed
  1. ajprincess
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Fill in the blanks public class Link{ public int data; public Link next; public Link(int data){ ......................=data; next=.......................; } public void display() { System.out.print(..........................+" "); } public ................. getdata() { return data; } } public class LinkList{ private (5).................... first; public LinkList() { first=(6).......................; } //insert at start of list public void insert(int value) { Link current=.......................; ...............................=first; first=..............................; } //display the list public void displayA() { Link current = ......................; While(...............................) { ......................; current=................................; } System.out.println(); } //find size of the list public ......................... size() { Link current=..........................; .................................................; while(.............................) { ...................................; current=...................................; } return ..............................; } //find the middle element in the list public ................ midelement() { Link current = ...........................; Link middle =............................; int length = 0; while(current!=null){ length++; if(..............................................................) { middle=middle.nest; } current=current.next; } return ......................; } //find the nth link public ............................ nthelement(......................) { link current=.......................; for(.......................................) { current = ..............................; } return current; } //reverse the list public ........................... reverse (){ Link current=first; Link forward; Link previous=null; while(............................................) { .............................................; .............................................; .............................................; ..............................................; } ....................................................; } } public class LinkListApp { public static void main(String args[]) { ............................................................................; obj.insert(10); obj.insert(20); obj.insert(30); obj.insert(40); obj.insert(50); obj.displayA(); int size = ................................................; System.out.println("Length of the List is"+..........); ....................................=objmidelement(); System.out.println("Middle data is"+............................); ..............................; .......................................=obj.nthelement(......); System.out.println(nth+" element has the value of "+............................); obj.reverse(0; obj.displayA(); } }

  2. ajprincess
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    My answer is public class Link{ public int data; public Link next; public Link(int data){ ......................=data; next=null; } public void display() { System.out.print(data+" "); } public int. getdata() { return data; } } public class LinkList{ private Link first; public LinkList() { first=null; } //insert at start of list public void insert(int value) { Link current=new Link(value); current.next=first; first=current; } //display the list public void displayA() { Link current = first; While(current!=null) { current.display(); current=current.next; } System.out.println(); } //find size of the list public int size() { Link current=first; int length=0; while(current!=null) { length++; current=current.next; } return length; } //find the middle element in the list public ................ midelement() { Link current = first; Link middle =first; int length = 0; while(current!=null){ length++; if(..............................................................) { middle=middle.next; } current=current.next; } return middle; } //find the nth link public Link nthelement(......................) { link current=fisrt; for(.......................................) { current = ..............................; } return current; } //reverse the list public ........................... reverse (){ Link current=first; Link forward; Link previous=null; while(............................................) { .............................................; .............................................; .............................................; ..............................................; } ....................................................; } } public class LinkListApp { public static void main(String args[]) { LinkList obj=new LinkList(); obj.insert(10); obj.insert(20); obj.insert(30); obj.insert(40); obj.insert(50); obj.displayA(); int size = ................................................; System.out.println("Length of the List is"+..........); ....................................=objmidelement(); System.out.println("Middle data is"+............................); ..............................; .......................................=obj.nthelement(......); System.out.println(nth+" element has the value of "+............................); obj.reverse(0; obj.displayA(); } }

  3. ajprincess
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    My answer for reverse method is public void reverse() { Link previous = null; Link current=first; Link forward; while(current!=null) { forward=current.next; current.next = previous; previous=current; current=forward; } first=previous; }

  4. KonradZuse
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    holy crap hahaha.... Let me look through this slowly :P.

  5. ajprincess
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I have done other methods. Nw I need help with only nthelement method

  6. KonradZuse
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Okay, what's next?

  7. ajprincess
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    sorry didnt get u?

  8. KonradZuse
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I didn't read everything, what exactly do you still need help with? The above method or...????

  9. ajprincess
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ya only that method

  10. ajprincess
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I got t. thanks a lot for trying to help me:)

  11. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy