Linked List

use Linked list to do ajacency list

Page 1 of 1

4 Replies - 1269 Views - Last Post: 14 April 2010 - 02:58 AM Rate Topic: -----

#1 Guest_irvine*


Reputation:

Linked List

Posted 13 April 2010 - 07:05 AM

How to use pointer based linked list to do adjacency list?
let say for a course structure:

Major : SubjectA -> SubjectB
core : SubjectC -> SubjectD
Elective: SubjectE

Thank You...
Is This A Good Question/Topic? 0

Replies To: Linked List

#2 callahan09  Icon User is offline

  • D.I.C Head

Reputation: 20
  • View blog
  • Posts: 61
  • Joined: 13-April 10

Re: Linked List

Posted 13 April 2010 - 08:18 AM

I'm familiar with linked lists, but I'm not entirely sure what you're asking for? Could you elaborate, please? By adjacency list, are you implying that you want to create a list of all of the links in the linked list? If so, then wouldn't that defeat the purpose of using a linked list? Or am I misunderstanding what you're asking for?

This post has been edited by callahan09: 13 April 2010 - 08:19 AM

Was This Post Helpful? 0
  • +
  • -

#3 mojo666  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 352
  • View blog
  • Posts: 771
  • Joined: 27-June 09

Re: Linked List

Posted 13 April 2010 - 08:49 AM

An adjacency list is a list of lists. It's just like a list, but instead of having data in the node, you have a pointer to another list. Using your example, your main list would be MajorList->CoreList->ElectiveList. You traverse this list to get a particular group of courses. Then you would traverse that resulting list to get a particular course in that group.
Was This Post Helpful? 0
  • +
  • -

#4 Guest_irvine*


Reputation:

Re: Linked List

Posted 14 April 2010 - 02:43 AM

Thank you for your concerned.
I want to use linked list to do something like this:

MajorList -> CoreList -> ElectiveList
| | |
SubjectA SubjectC SubjectE
| |
SubjectB SubjectD
|
NULL
Was This Post Helpful? 0

#5 Guest_irvine*


Reputation:

Re: Linked List

Posted 14 April 2010 - 02:58 AM

Is it possible to use struct within a struct to do it?

MajorList -> SubjectA -> SubjectB
|
CoreList -> SubjectC -> SubjectD
|
ElectiveList -> SubjectE
Was This Post Helpful? 0

Page 1 of 1