Results 1 to 3 of 3
  1. #1
    andy_d is offline Member
    Join Date
    Oct 2013
    Rep Power

    Default Making this code more efficient...

    So I've been reviewing my assignments from last semester and the one thing I wish the TA would have done is provided his solution to the assignments. My program works but it's not clear to me how efficient the code really is. This was the assignment...


    And this was is my code...

    I understand the code is lengthy so not sure what to expect in terms of help but figured I'd give it a try.

  2. #2
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Rep Power

    Default Re: Making this code more efficient...


    One thing I saw:
    The borders are always empty so there is no reason to check these when doing a comparison or checking in isempty.

    With Kind regards,


  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: Making this code more efficient...

    Also: only living cells and cells next to a living cell have the opportunity to change in the next generation; you only need to check those cells (which is the minority in normal circumstances). A naive implementation that uses (and checks) all cells in a matrix, will be much slower than a set of coordinates of 'living' cells.

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Finished Code - More Efficient Way?
    By AlexGraal in forum New To Java
    Replies: 2
    Last Post: 01-07-2014, 06:31 PM
  2. Replies: 14
    Last Post: 06-13-2013, 07:19 PM
  3. Need help making program more efficient
    By cid in forum New To Java
    Replies: 4
    Last Post: 06-30-2010, 08:22 PM
  4. Replies: 1
    Last Post: 03-22-2010, 09:21 AM
  5. How to write efficient maintainable code.
    By Zosden in forum Advanced Java
    Replies: 9
    Last Post: 05-01-2008, 05:48 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