Question:
plz tell me a 'C'program depicting array implementation of linked list Abstract Data Type..?
anonymous
2007-07-09 07:21:59 UTC
The above program is included in Data Structures.It must include creation,insertion,deletion,search and display of nodes....If U cudn't help me with a full program..plz..tell me appropriate website for my question ...plz...
Four answers:
anonymous
2007-07-09 08:26:02 UTC
There's a full C program on the Wikipedia page for Linked List. I recommend that you study it and write your own. It's probably for a class assignment, so I strongly encourage you not to copy and paste code that you find on the web. Your instructor will respect you more if you do your own work.
ChanChan
2007-07-09 08:40:44 UTC
int max_elm = 10;



/*element info's structure*/

struct tElmInfo {

int InfoA;

int InfoB;

/*another needed info goes here*/

}



/*List structure*/

struct tList {

int Head;

int Tail; /* if needed */

int count;

tElmInfo Elm[max_elm]; /*we assume that 0 elm won't be used*/

}





void main() {

/*List Var*/

tList List1;

createList(List1);

/*it depends your needs*/

}



void createList(tList *List){

/* we assume that if head and tail point 0, then the list is empty */

(*List).Head = 0;

(*List).Tail = 0;

}



int isEmpty(tList List) {

if ((List.Head == 0) && (List.Tail == 0)) {

return 1;

} else {

return 0;

}

}



int isFull(tList List) {

if (List.count >= max_elm - 1) {

return 1;

} else {

return 0;

}

}



void insertLast(tList *List, tElmInfo X) {

if isFull((*List)) {

printf("List is FULL");

} else {

if isEmpty((*List)) {

(*List).Head = 1;

(*List).Tail = 1;

} else {

(*List).Tail++;

if ((*List).Tail >= max_elm) {

(*List).Tail = 1;

}

}

(*List).Elm[(*List).Tail] = X;

(*List).count++;

}

}

/* for other insert method (like insert first) just modify from code above (i'm sure you can do this) */



tElmInfo delFirst (tList *List) {

tElminfo tmpResult;

if (isEmpty((*List))) { /* actually you do this checking before call this function */

printf("List empty!");

} else {

tmpResult = (*List).element[(*List).Head];

(*List).count--;

if ((*List).Head == (*List).Tail) {

createList(List);

} else {

(*List).Head++;

}

if ((*List).Head >= max_elm) {

(*List).Head = 1;

}

return tmpResult;

}

}





I hope these will help. And I am sorry if there's ('re) mistake(s). There also a lot of other method out there. But the concept always be the same.
jaye
2016-05-17 22:39:52 UTC
Dude array is static u cannot implement linked list using array !! please be clear with your question !! link- list is dynamic !! ie u dont have to initilize memory for L.L !! if u wan i can get u L.L program in C++ :)
coolblue
2007-07-09 09:35:49 UTC
Below i have provided a link which may help u:

http://www.cprogramming.com/

This site contains tutorials & there are quizzes on C & C++.

Try it,i did too.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...