Tuesday, March 29, 2011

Lab 8, lab 7 signins

Lab 8 is here. Last lab!

Lab 7 signins are here.

30 comments:

  1. Thanks for the lab sir, this one was a lot more challenging than the last few. I felt I learned a lot more about Linked Lists from this lab than I did about GUI or Recursion from the last two labs. With that being said, is there any possibility of assigning some "Exam Style" or "Exam Level" practice problems that integrate the concepts we have covered in this course. I am having trouble structuring a study plan for this final exam, specifically for the programming portion, as the textbook does not treat these concepts in the same respect we have been approaching them in class (All practice problems in the text are the role of the architect, not the role of the implementer, in my opinion). Also, we haven't had any real practice with searching and sorting algorithms. As you said on the first day of class, the key to success in the course is simple: Practice, Practice, Practice. Can you please help me practice more?

    ReplyDelete
  2. I have question about Lab8. I know that each array is supposed to be placed a single position, however, the Node class only accepts data of type String and we're not allowed to modify that part of the code.

    My question is: How do we store the array data at one particular Node if the Node class doesn't accept arrays?

    I'd appreciate any help/direction.

    Thank you.

    ReplyDelete
  3. Just to follow up on my question. Are we allowed to write an internal toString() method to convert the array into one string and then store that string as data in the Node?

    ReplyDelete
  4. Hi sir, was wondering if you are going to put up the solutions for Lab 6 and 7 up. it really helped when you posted them up for lab 5 and lab 5a. thanks

    ReplyDelete
  5. This is just me but I think you are supposed to insert each string in the array as a node in the linked list. So you wouldn't need a private toString() method to convert the entire array to a single string.

    ReplyDelete
  6. @Dennis

    The thing is, though, you're given only one position value, which is where the entire array should be located. I understand that this means the entire array should be stored at ONE Node. For this to be possible the array needs to be a String or there's probably something I missed and there's another way to do it.

    ReplyDelete
  7. @Anonymous 6:41,

    If you read the documentation of the add(int, String[]) method, it says:

    "Takes an array of Strings as an argument, and adds them to the list, starting at the given position. Existing data at position and later are moved down by newData.length positions"

    So, from my understanding, it wont add at just one position. It will add the first element of newData[] at that position of argument, and each consecutive elements at previous position + 1. Basically, nth position of newData[] will be added at position + n, where (0 <= n < newData.length).

    ReplyDelete
  8. Sir would it be possible to put up the last couple of your in-class methods on the website? the last version available is march 18th, and I find the classes that you do during the lecture very helpful resources

    ReplyDelete
  9. May i know when will we have the 3rd lab test?
    or does the exam period include that part

    ReplyDelete
  10. http://mail.google.com/mail/help/motion.html

    ReplyDelete
  11. @Woody

    Honestly, I understand that it's a work in progress, but it looks so... stupid. The guy looks like he's dancing in front of his computer.

    I can already imagine that Google comes up with a very strict "dance" routine to write out an email and teenagers all over the world will find short cuts by break-dancing instead!

    Side note: How in the world does a hand wave translate into Barbados at 1:16?

    ReplyDelete
  12. @April 1, 2011 10:43 AM

    He said 54,327,921 times in class that the final written test and the final lab test will take place at the same time and on the same day. You write one and then immediately the other.

    ReplyDelete
  13. @2:49 PM
    You'll need a movement for every word.

    ReplyDelete
  14. It seems like if position is negative or zero, the node can still be added in front of the head.

    ReplyDelete
  15. Can anyone post the full solution for Lab 8 please?

    ReplyDelete
  16. Yes Can anyone please post the solution to lab 8? I know the add method is similar to the add method already provided but I can't happen to figure out how to do it? Thanks

    ReplyDelete
  17. For the mutate method? I was wondering that we don't have a setData method how would I set the data there?
    I made it walk from the head to the position and at that position i'm thinking what should I do?

    ReplyDelete
  18. I did this for the mutate method

    LinkedList.Node m = walk(position);
    if(m != null)
    {
    m.data = newData;
    return true;
    }
    else
    return false;

    worked fine for me

    ReplyDelete
  19. Mine is like this. Hope this is correct.


    public boolean mutate(int position, String newData)
    {
    if(position <= this.size-1)
    {
    this.delete(position);
    this.add(position, newData);
    return true;
    }
    return false;
    }

    ReplyDelete
  20. @Woody
    Why did you delete it? I think we just need to change the data at the given position, No? And what did you check in the if statement?

    So basically what you did is you deleted the whole node at the given position and then you created a new Node at the same position with the passed Data. But what if the node is null at the position? I ain't no expert but don't you think there will be something wrong with it if the node is empty at the given position?

    @12:44
    My method is similar to yours as well. Maybe we both are wrong and maybe Woody is right but lets wait for Professor Eckford for the feedback.

    Can anyone please post the add method?

    ReplyDelete
  21. Or this.

    public boolean mutate(int position, String newData)
    {
    if(this.delete(position))
    {
    this.add(position, newData);
    return true;
    }
    return false;
    }

    ReplyDelete
  22. @ 1:32 PM

    I think:
    if(position <= this.size-1)


    checks if position is there is a node at the position because position is less than than the size of the linked list. I didn't think of your way.

    ReplyDelete
  23. I didn't try your method but what someone described above is working perfect. I'm pretty sure yours is gonna work too

    ReplyDelete
  24. It works I just tested it.
    =)

    ReplyDelete
  25. @ Woody:
    Can you post your add method please? I'm done with the rest.

    ReplyDelete
  26. public boolean add(int position, String[] newData)
    {

    Node n = this.walk(position);
    if(n != null)
    {
    for(int i = 0; i < newData.length; i++)
    {
    this.add(position, newData[i]);
    position++;
    }
    return true;
    }
    return false;
    }

    ReplyDelete
  27. ||Off topic||

    Does section M have a class tomorrow(Monday, April 4th)?

    I know that we have a make-up class on April 5th. Not so sure about 4th.

    ReplyDelete
  28. We are in class right now (Monday, April 4th) and there is no class tomorrow (Tuesday, April 5th)

    ReplyDelete
  29. Can we get an extra practice lab before the exam? Preferably one the involves both recursion and linked lists.

    Thank you

    ReplyDelete