Adjacency Matrix & General Questions 
Author Message
 Adjacency Matrix & General Questions

My first year courses were all in Java but the courses in second year all
assume C knowledge and as my high school never had any programming course
other then say keyboarding in WordPerfect. I've picked up a copy of The C
Programming Language and have worked through it. (There were a few
exercises I didn't get but I'm buying the solutions.)

I'm re-doing my first year assignments in C for the practise. I wish to
implement Dijkstra's on a adjacency matrix (after that I'll try it with a
adjacency list) and I'm looking for a short, maybe 3 by 3, example on how
this is done as I can't seem to find one on the net.

Perhaps, even a recommendation on a more advanced book containing such an
example?

My main problem is with these structs. Are these like objects in java? All
the exercises in the book treat them like records but could I define a
function in them? Would I access this like a member variable such as

(*p).function()

Oh and one last question. In the book I've seen functions prototypes like

int function(void)
int main()

Should the keyword void be in the prototype for a main method if I don't
intend to use command line arguments?

Thank you for your time. Especially if you read this far down. It's much
appreciated.

--
SharkBoy



Tue, 06 Sep 2005 08:18:15 GMT  
 Adjacency Matrix & General Questions

Quote:

> I'm re-doing my first year assignments in C for the practise. I wish to
> implement Dijkstra's on a adjacency matrix (after that I'll try it with a
> adjacency list) and I'm looking for a short, maybe 3 by 3, example on how
> this is done as I can't seem to find one on the net.

> Perhaps, even a recommendation on a more advanced book containing such an
> example?

_C Unleashed_ pp. 677-687 contains a worked-out example and
working code in C for Dijkstra's algorithm.  Disclaimer: I
contributed a chapter to this book.  (I don't get royalties on
sales though.)

Quote:
> My main problem is with these structs. Are these like objects in java? All
> the exercises in the book treat them like records but could I define a
> function in them? Would I access this like a member variable such as

> (*p).function()

Structures cannot have functions as members.  They can have
pointers to function though, and you could use the above syntax
to invoke a pointer-to-function member of structure *p.

Quote:
> Oh and one last question. In the book I've seen functions prototypes like

> int function(void)
> int main()

> Should the keyword void be in the prototype for a main method if I don't
> intend to use command line arguments?

It's optional but recommended.  In fact without the void keyword
a declaration for a function with no arguments doesn't provide a
prototype.
--
"A lesson for us all: Even in trivia there are traps."
--Eric Sosman


Tue, 06 Sep 2005 08:23:51 GMT  
 Adjacency Matrix & General Questions

Quote:


>> I'm re-doing my first year assignments in C for the practise. I wish to
>> implement Dijkstra's on a adjacency matrix (after that I'll try it with a
>> adjacency list) and I'm looking for a short, maybe 3 by 3, example on how
>> this is done as I can't seem to find one on the net.

>> Perhaps, even a recommendation on a more advanced book containing such an
>> example?

> _C Unleashed_ pp. 677-687 contains a worked-out example and
> working code in C for Dijkstra's algorithm.  Disclaimer: I
> contributed a chapter to this book.  (I don't get royalties on
> sales though.)

Thank you, I've found a few complicated examples but I think I understand how
it's implemented. That book seems pretty good based on the reviews I've
read but I'll have to hold off on buying it till I make some money in the
summer.

Quote:
>> Oh and one last question. In the book I've seen functions prototypes like

>> int function(void)
>> int main()

>> Should the keyword void be in the prototype for a main method if I don't
>> intend to use command line arguments?

> It's optional but recommended.  In fact without the void keyword
> a declaration for a function with no arguments doesn't provide a
> prototype.

I think I'll be sticking with:
int main(void)

It looks more uniform especially with other functions with no parameters
and it looks neat :)

--
SharkBoy



Thu, 08 Sep 2005 05:36:10 GMT  
 Adjacency Matrix & General Questions

Quote:

> > _C Unleashed_ pp. 677-687 contains a worked-out example and
> > working code in C for Dijkstra's algorithm.  Disclaimer: I
> > contributed a chapter to this book.  (I don't get royalties on
> > sales though.)

> Thank you, I've found a few complicated examples but I think I understand how
> it's implemented. That book seems pretty good based on the reviews I've
> read but I'll have to hold off on buying it till I make some money in the
> summer.

You may want to check your public or school libraries to see if they
have a copy. My public library has several copies, although I did
request that they add it to their selection.

Brian Rodenborn



Sat, 10 Sep 2005 02:26:42 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Pointers & matrices: Twist on the original question

2. Adjacency linked list example..?

3. adjacency multilists

4. matrix-matrix multiplication in ANSI C

5. Matrix inverse and matrix multiplication

6. Parsing a string with numbers (reading a graph's adjacency list)

7. Adjacency Lists in C

8. Adjacency Lists in C

9. exception with ImageList - a general question

10. General C++ questions from a VB noob

11. General Package Design Question

12. general question about debuggers

 

 
Powered by phpBB® Forum Software