• 0

Don't code it, just explain method implementation


Question

Hey guys, one of my friends is experiencing a slight hit on his assignment:

http://teaching.ics.mq.edu.au/units/comp12...ments/ass2.html

Basically, we don't want it to be coded, however, we would like to hear from your experience, how we would go about implementing it, because so far theres quite a number of factors to take into consideration, and everytime we think of a new method of implementation it tends to conflict with a required aspect of the assignment, yeah this is homework, however, we don't want it to be done, but want ideas from you guys.

Cheers!

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Well you have a week.

a) extend abstract grid class

b) implement void readGrid(string filename);

c) implement void printGrid();

d) implement bool isEmpty();

e) work on void findAllBlobs(); which will use int getBlobSize(int curRow, int curCol);

if you don't get it to all work, you will get some marks for the a,b,c,d

its only worth 7% - but you really need to be more specific on what you want suggestions for. what have you already implemented? what ideas of yours is conflicting with assignment requirements?

Link to comment
Share on other sites

  • 0

It's a little bothering us... i've tried jotting down some ideas... because we're suppose to implement the method, and the problem here is... we gotta take into considerations like when the certain star is connected, adjacent, vertical or horizontal next to it, then its part of the blob, and we gotta also implement the method through the use of recursion.

Link to comment
Share on other sites

  • 0

I remember doin the EXACT SAME question for the canadian computing competition. The only problem was that I switched the x and y in some places :blush:. The only hint I'm gonna give you is about the recursion part. Look up 'Depth First Searching'. That's the tecnique you want to use.

Link to comment
Share on other sites

  • 0

Hi Guys,

'Depth First Searching' was a big hint from MrA

Well for fun I completed your assignment using Java.

If you are interested in the Java - not C++ code I can post it.

Conveting the Java to C++ would be pretty easy so I wont post it unless you asked.

on another note, the key thing is to mark all nodes that you have traversed

and to push x,y alignment out centred...... ie make the node thats found centre.

"n" is found to be a node pos(1,0), set you coordinace so node is centre

s = invalid space o = valid space

so your for loop in this case would start processing at (0,-1), you of course skip this space as it is invalid/not a blob

ooo ----> soo

noo ----> sno

ooo ----> soo

heres some algo stuff

public void findAllBlobs()

{

//do some for looping and check if node already read

blobSize = getBlobSize(i,j);

//print blobSize

}

private int getBlobSize(int currentRow, int currentColumn){

//if x or y is out of range of grid no link - skip

//if x,y is not marked no link -skip

//else x,y is blob

{

//push our alignment so that the node is centred

y = y - 1;

x = x - 1;

//do some looping

//if out of grid bounds skip do nothing

//else process this node if not visited

{

set this node as visited

//if is a blob

{

size = size + 1;

size = size + getBlobSize(row, col); //return size

}

}

}

}

}

return size;

}

Link to comment
Share on other sites

  • 0

On another note, dont think reading an algoritms is cheating, I copied the Depth First algorithm from my text book.

In the real world, everyone looks up already created code or algorithms.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.