473,511 Members | 15,408 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multi Linked List Data Structures in C

Ahsan Ali
1 New Member
How to make a class data base using multi linked list data structures(in C)?.
In class's Database : one column for 'Subjects' and other one for 'student's Roll Nos' . Now the task is to point 'subject' to the respective 'student'...
I know single and double linked list ... But I have never worked with 2-D linked list.
Please anyone help me out?
Nov 9 '11 #1
2 14878
weaknessforcats
9,208 Recognized Expert Moderator Expert
It's the same as working with a linked list where each node is itself a linked list in it's own right. That is, you have a node pointer as the data in the node. That is your start node for the second dimension list.

You will need one set of functions to manage a list where the nodes contain a node pointer as data as well as second set of functions to manage a list where the nodes contain a pointer to actual data.
Nov 9 '11 #2
akashjiit
2 New Member
I am giving you the code similar to one you asked for(you will never find codes or questions on multi linked list on net! So make sure you undertand it by heart..)
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<stdlib.h>
  4. struct scorel
  5. {
  6. int no;
  7. struct scorel *rp;
  8. };
  9. struct namel
  10. {
  11. char a[10];
  12. struct scorel *rp;
  13. struct namel *dp;
  14. };
  15. void main()
  16. {
  17. int i,j,n,m;
  18. struct namel *temp,*head,*end,**s;
  19. struct scorel *tmp,*had,*nd;
  20. clrscr();
  21. printf("enter no of students");
  22. scanf("%d",&n);
  23. end=NULL;
  24. for(i=0;i<n;i++)
  25. {
  26. temp=(struct namel*)malloc(sizeof(struct namel));
  27. printf("enter name\n");
  28. scanf("%s",temp->a);
  29. temp->rp=NULL;
  30. temp->dp=NULL;
  31. *(s+i)=temp;
  32. if(end==NULL)
  33. {
  34. end=head=temp;
  35. }
  36. else
  37. {
  38. end->dp=temp;
  39. end=temp;
  40. }
  41. printf("enter no of scores");
  42. scanf("%d",&m);
  43. nd=NULL;
  44. for(j=0;j<m;j++)
  45. {
  46. tmp=(struct scorel*)malloc(sizeof(struct scorel));
  47. printf("enter score\n");
  48. scanf("%d",&tmp->no);
  49. tmp->rp=NULL;
  50. if(nd==NULL)
  51. {
  52. nd=had=tmp;
  53. temp->rp=tmp;
  54. }
  55. else
  56. {
  57. nd->rp=tmp;
  58. nd=tmp;
  59. }
  60. }
  61. }
  62. for(i=0;i<n;i++)
  63. {
  64. temp=*(s+i);
  65. printf("%s-->",temp->a);
  66. tmp=temp->rp;
  67. while(tmp!=NULL)
  68. {
  69. printf("%d-->",tmp->no);
  70. tmp=tmp->rp;
  71. }
  72. printf("\n");
  73. }
  74. getch();
  75. }
Mar 9 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2968
by: Jonathan Moss | last post by:
I have (almost) succesfully created a linked list data structure class. It will quite happily add items to to the end of the list (once I found that objects are not passed by reference :). What I...
7
4806
by: Chris Ritchey | last post by:
Hmmm I might scare people away from this one just by the title, or draw people in with a chalange :) I'm writting this program in c++, however I'm using char* instead of the string class, I am...
0
2665
by: Andrew | last post by:
Are there any problems with creating a linked list of structures in the following sample? Or is the preferred way to create the data structure then create a seperate "node" style structure to hold...
5
22959
by: disco | last post by:
I am working on this example from a book "C Primer Plus" by Prata 4th edition - p. 672. There is no erata on this problem at the publisher's website. 1) Is it a violation of copyright laws to...
5
6036
by: John N. | last post by:
Hi All, Here I have a linked list each containing a char and is double linked. Then I have a pointer to an item in that list which is the current insertion point. In this funtion, the user...
12
2492
by: Jonathan Bartlett | last post by:
Just finished a new IBM DeveloperWorks article on linked lists, and thought you all might be interested. It's not an introduction -- it instead covers some of the more interesting aspects of...
1
6170
by: yaarnick | last post by:
Create a linked list data structure library to hold strings. Then library should support the following linked list operations. Create() – Creates the linked list Insert() – Insert a string into the...
3
3553
by: quorn | last post by:
Hi there, I have an assignment in which the first part requires me to store coordinates in a .txt file in a linked list data structure. The text file has coordinates laid out as follows: 1 1 5...
4
1699
by: sasidharan091 | last post by:
what are the applications of linked lists data structures?
2
4842
by: iceice | last post by:
I'm trying to print out the contents of a linked list of structures but am not able to access the attributes of the structure by using the dot operator. I don't know what's the problem. Can someone...
0
7242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7138
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7508
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5662
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.