Module III. Linear Data Structures and their Linked Storage Representation
|
|
- Tracy Goodman
- 6 years ago
- Views:
Transcription
1 Module III Linear Data Structures and their Linked Storage Representation 3.1 Linked List Linked list is the collection of inter connected nodes with a head node representing the first node and a tail node representing the last node of it. A node can be viewed as a block consisting of two major fields : a data field and a pointer field. The pointer field is used to interconnect nodes of a list. Below diagram depicts the linked list setup. Tail 3.2 Linked list types There are few variants of linked lists. Below diagram shows a brief classification of Linked Lists. Linked List NULL Singly LL Circular LL Doubly LL Singly Circular LL Doubly Circular LL Regarding these variants of LL, explanations and examples are given in subsequent sections of the notes. 3.2 Linked List Representation A simple representation of singly linked list would look like the below: struct node int data; struct node *next; ;
2 struct node *newnode; With the above declaration we can create a node of the pattern below: data *next newnode Initially, the pointer field of the first node in singly linked list would contain NULL value. Instruction that makes it is: newnode->next = NULL; Note: Structure variables fields of self referential type are accessed through -> (arrow operator) Now, let us try to understand few conventions w.r.t linked lists. Consider below given list h h h 40 NULL head (1000h) (1008h) (1016h) tail (1024h) In this list, head node contains data = 10 and tail node contains data = 40. This list has 4 nodes that are interconnected. Head node is connected to the next node since the pointer value contains the address of next node. Tail node is not linked to any node since its pointer value is NULL. struct node *head, *tail, *newnode; // variables declared of type struct node head = (struct node *) malloc (1 * sizeof(struct node)); This instruction creates one node of type struct. Memory gets allocated using DMA function malloc(). Created node in the above instruction is referred to as head. It can be any other name as well. head->data = 10; // assigns head node s data field with 10 head->next = NULL; //assigning pointer value to NULL 10 NULL head; tail tail = head; // assigning the reference of head to tail. This means both head and tail are referring to the same node. Now, let us add a new node to this list. newnode = (struct node *) malloc (1 * sizeof(struct node)); newnode->data = 20; newnode->next = NULL; 10 NULL 10 NULL Mr. Head; Nischaykumar tail Hegde, newnode CSE, VCET, Puttur
3 The above nodes can be connected using the following instructions: head->next = newnode; // assigning head node s pointer value with address of newnode h 20 NULL head; tail (1000h) newnode (1008h) Now, if we execute the instruction, tail = newnode; tail & newnode both refer to the node with value 20. In this way, linked lists can be created. 3.3 Operations on Linked Lists Major operations performed on linked lists are inserting a node, deleting a node, searching a node and traversing the list to display all of its nodes. a) Inserting a node: Node can be inserted at the beginning, at the end or anywhere in the linked list h h h 40 NULL head (1000h) (1008h) (1016h) tail (1024h) Consider the above list. Suppose we wish to insert a node at the beginning, following set of instruction are to be executed. newnode = (struct node *) malloc (1 * sizeof(struct node)); newnode->data = 50; newnode->next = head; h head = newnode; h h h 40 NULL (1000h) (1008h) (1016h) tail (1024h) h head; newnode Suppose we wish to insert a node at the end, following set of instruction are to be executed h h h h head (1000h) (1008h) (1016h) tail (1024h) newnode = (struct node *) malloc (1 * sizeof(struct node)); 80 NULL newnode->data = 80; newnode->next = NULL; 80 NULL (1032h)
4 Take a temporary variable of type struct node, traverse the list until you reach the last node (i.e tail ) while(temp->next!=null) temp=temp->next; temp->next = newnode; tail = newnode; Now let us see how to insert a node at a particular position in the list. For this, we need to ask user to specify after which node in the list he would want to insert. Call it as key node. This can be realized as below: temp h h h h head (1000h) (1008h) (1016h) tail (1024h) Key = h Newnode (1040h) 80 NULL (1032h) Take a temporary variable of type struct node, traverse the list until you reach the desired node (i.e 30) while(temp->data!=key) temp=temp->next; 100 NULL newnode (1040h) newnode->next = temp->next; temp->next = newnode; b) Deleting a node: A node in the list can be deleted using the standard function free ( ). Let us see an example to understand delete operations on linked list h h 30 NULL 40 NULL head (1000h) temp2 (1008h) temp(1016h) tail (1024h) Let us try to delete node with 30 data value. Take two temporary variables and position them to key node and the previous node of it.
5 Now, key =30. While(temp->data!=key) temp=temp->next; While(temp2->next!=key) temp2=temp2->next; temp2->next = temp->next; temp->next = NULL; free(temp); Below C program creates a singly linked list and performs few operations like insert, delete, display, search, insert and delete at specific positions in the list. #include <stdio.h> #include <conio.h> #include <stdlib.h> struct node int data; struct node *ptr; ; struct node *head, *last,*temp, *temp2; void create(); void delet(); void dele_spec(); void display(); void spec_ins(); int search(int); int num,con=1,ch,key,f; void main()
6 clrscr(); head=null; printf("1.create\n2.delete\n3.delete Specific\n4.Insert After Specific node\n5.display\n6. Search\n7.Exit\n"); while(1) printf("enter choice\n"); scanf("%d",&ch); switch(ch) case 1: printf("enter number\n"); scanf("%d",&num); create(); case 2: delet(); case 3: dele_spec(); case 4: spec_ins(); case 5: display(); case 6: printf("enter the node data to be searched\n"); scanf("%d",&key); f=search(key); if(f==1) printf("node FOUND\n"); printf("node NOT FOUND\n"); case 7: exit(0);
7 void create() if(head==null) head = (struct node*)malloc(1*sizeof(struct node)); head->data=num; head->ptr=null; last=head; temp= (struct node*)malloc(1*sizeof(struct node)); temp->data=num; last->ptr=temp; temp->ptr=null; last=temp; void delet() if(head==null) printf("list is empty\n"); temp=head->ptr; free(head); head=temp;
8 void dele_spec() int key; printf("enter the node to be deleted\n"); scanf("%d",&key); temp=head; temp2=head; while(temp->data!=key) temp=temp->ptr; while(temp2->ptr!=temp) temp2=temp2->ptr; if(temp->ptr==null) temp2->ptr=null; free(temp); last=temp2; temp2->ptr=temp->ptr; free(temp); void spec_ins()
9 int key; printf("enter the node info next to which to be inserted\n"); scanf("%d",&key); printf("enter data for newnode\n"); scanf("%d",&num); temp2= (struct node*)malloc(1*sizeof(struct node)); temp2->data=num; temp=head; while(temp->data!=key) temp=temp->ptr; temp2->ptr=temp->ptr; temp->ptr=temp2; void display() if(head==null) printf("list empty\n"); temp=head; while(temp!=null) printf("%d\t",temp->data); temp=temp->ptr;
10 int search(int key) int flag=0; temp=head; while(temp!=null) if(temp->data==key) flag=1; return flag; temp=temp->ptr; return flag; Advantages of Linked Lists They are a dynamic in nature which allocates the memory when required. Insertion and deletion operations can be easily implemented. Stacks and queues can be easily executed. Linked List reduces the access time. Disadvantages of Linked Lists The memory is wasted as pointers require extra memory for storage. No element can be accessed randomly; it has to access each node sequentially. Reverse Traversing is difficult in linked list. Applications of Linked Lists Linked lists are used to implement stacks, queues, graphs, etc. Linked lists let you insert elements at the beginning and end of the list. In Linked Lists we don t need to know the size in advance. 3.4 Types of Linked Lists
11 Singly Linked List : Singly linked lists contain nodes which have a data part as well as an address part i.e. next, which points to the next node in sequence of nodes. The operations we can perform on singly linked lists are insertion, deletion and traversal. Doubly Linked List : In a doubly linked list, each node contains two links the first link points to the previous node and the next link points to the next node in the sequence. Circular Linked List : Singly Circular LL: In the circular linked list the last node of the list contains the address of the first node and forms a circular chain. Doubly Circular LL: In the doubly circular linked list the last node s next ptr field will have the address of start (head) node and the start (head) node s previous ptr field will have the address of last (tail) node. Below diagram shows its pictorial representation.
12 3.5 Header Linked List Header linked list is similar to Singly linked List but the difference is that in this type of list, there exists a special node called head, which either contains information regarding total nodes in the list or the address of the last node in the whole list. C Program to implement header linked list is shown below #include <stdio.h> #include <conio.h> #include <stdlib.h> struct node int data; struct node *ptr; ; struct node *head, *last,*temp, *newnode; void create(); void delet(); void display(); int num,count=0,ch; void main() clrscr();
13 head=null; printf("1.create\n2.delete\n3.display\n4.exit\n"); while(1) printf("enter choice\n"); scanf("%d",&ch); switch(ch) case 1: if(head==null) head = (struct node*)malloc(1*sizeof(struct node)); head->data=count; head->ptr=null; last=head; printf("enter number\n"); scanf("%d",&num); create(); case 2: delet(); case 3: display(); case 4: exit(0); void create() newnode = (struct node*)malloc(1*sizeof(struct node)); newnode->data=num;
14 newnode->ptr=null; last->ptr=newnode; last=newnode; count++; head->data=count; void delet() if(head->data==0) printf("list is empty\n"); temp=head; while(temp->ptr!=last) temp=temp->ptr; free(last); last =temp; last->ptr=null; count--; head->data=count; void display() if(head==null) printf("list empty\n");
15 temp=head->ptr; while(temp!=null) printf("%d\t",temp->data); temp=temp->ptr; printf("\nheader Information:%d\n",head->data); 3.5 Linked implementation of Stack #include <stdio.h> #include <stdlib.h> struct Node int Data; struct Node *next; *top; void popstack() struct Node *temp, *var=top; if(var==top) top = top->next; free(var); printf("\nstack Empty");
16 void push(int value) struct Node *temp; temp=(struct Node *)malloc(sizeof(struct Node)); temp->data=value; if (top == NULL) top=temp; top->next=null; temp->next=top; top=temp; void display() struct Node *var=top; if(var!=null) printf("\nelements are as:\n"); while(var!=null) printf("\t%d\n",var->data); var=var->next; printf("\n"); printf("\nstack is Empty");
17 int main(int argc, char *argv[]) int i=0; top=null; printf(" \n1. Push to stack"); printf(" \n2. Pop from Stack"); printf(" \n3. Display data of Stack"); printf(" \n4. Exit\n"); while(1) printf(" \nchoose Option: "); scanf("%d",&i); switch(i) case 1: int value; printf("\nenter a valueber to push into Stack: "); scanf("%d",&value); push(value); display(); case 2: popstack(); display(); case 3:
18 display(); case 4: struct Node *temp; while(top!=null) temp = top->next; free(top); top=temp; exit(0); default: printf("\nwrong choice for operation"); 3.6 Merging of two lists #include<stdio.h> #include<conio.h> #include<stdlib.h> struct node int data; struct node *next; ;
19 void insert_list1(); void insert_list2(); void display(); void merge_list(); struct node *list1, *list2,*list3,*temp1,*temp2,*temp3,*temp4; void main() int ch; clrscr(); printf("1 for insert in first linklist\n"); printf("2 for insert in second linklist\n"); printf("3 for display first & second linklist\n"); printf("4 for merge linklist\n"); printf("5 for exit\n"); while(1) printf("\nenter ur choice:"); scanf("%d",&ch); switch(ch) case 1: insert_list1(); case 2: insert_list2(); case 3: display(); case 4: merge_list(); case 5: exit(0);
20 void merge_list() temp1=list1; temp2=list2; while(temp1!=null temp2!=null) temp3=(struct node*)malloc(1*sizeof(struct node)); if(list3==null) list3=temp3; temp4=temp3; if(temp1->data<temp2->data) temp3->data=temp1->data; temp4->next=temp3; temp4=temp3; temp1=temp1->next; temp3->data=temp2->data; temp4->next=temp3; temp4=temp3; temp2=temp2->next; if(temp2==null) while(temp1!=null)
21 temp3=(struct node*)malloc(1*sizeof(struct node)); temp3->data=temp1->data; temp4->next=temp3; temp4=temp3; temp1=temp1->next; if(temp1==null) while(temp2!=null) temp3=(struct node*)malloc(1*sizeof(struct node)); temp3->data=temp2->data; temp4->next=temp3; temp4=temp3; temp2=temp2->next; temp3->next=null; void insert_list1() struct node *new; if(list1==null) list1=(struct node *)malloc(sizeof(struct node));
22 printf("enter the info"); scanf("%d",&list1->data); list1->next=null; temp1=list1; new=(struct node *)malloc(sizeof(struct node)); printf("enter the info"); scanf("%d",&new->data); new->next=null; temp1->next=new; temp1=temp1->next; void insert_list2() struct node *new; if(list2==null) list2=(struct node *)malloc(sizeof(struct node)); printf("enter the info"); scanf("%d",&list2->data); list2->next=null; temp2=list2; new=(struct node *)malloc(sizeof(struct node)); printf("enter the info");
23 scanf("%d",&new->data); new->next=null; temp2->next=new; temp2=temp2->next; void display() temp1=list1; temp2=list2; printf("\nthe Information of First linklist:"); while(temp1!=null) printf("%d ",temp1->data); temp1=temp1->next; printf("\nthe Information of Second linklist:"); while(temp2!=null) printf("%d ",temp2->data); temp2=temp2->next; temp3=list3; printf("\nmerged List:"); while(temp3!=null) printf("%d ",temp3->data); temp3=temp3->next;
24 3.7 Reversing a Singly Linked List #include<stdio.h> #include<conio.h> #include<stdlib.h> struct node int data; struct node *next; ; void insert_list(); void display(); void revers(); struct node *head,*tail,*temp,*temp1; void main() int ch; clrscr(); printf("1 insert in list\n"); printf("2 Reverse and display list\n"); printf("3.exit\n"); while(1) printf("\nenter ur choice:"); scanf("%d",&ch); switch(ch) case 1: insert_list(); case 2: revers(); case 3: exit(0);
25 void revers() temp=tail; temp1=head; while(temp!=head) temp1=head; while(temp1->next!=temp) temp1=temp1->next; temp->next=temp1; temp=temp1; temp=tail; head->next=null; printf("reversed list: "); while(temp!=null) printf("%d ",temp->data); temp=temp->next; void insert_list() struct node *new; if(head==null)
26 head=(struct node *)malloc(sizeof(struct node)); printf("enter the info"); scanf("%d",&head->data); head->next=null; tail=temp=head; new=(struct node *)malloc(sizeof(struct node)); printf("enter the info"); scanf("%d",&new->data); new->next=null; temp->next=new; temp=temp->next; tail=temp; temp1=head; printf("created list: "); while(temp1!=null) printf("%d ",temp1->data); temp1=temp1->next; 3.8 Singly Circular Linked List Operations #include <stdio.h> #include <conio.h> #include <stdlib.h> struct node int data;
27 struct node *ptr; ; struct node *newnode, *front,*rear, *temp; void create(); void display(); void delet(); int num,ch; void main() front=rear=null; while(1) printf("enter choice\n"); scanf("%d",&ch); switch(ch) case 1: printf("enter number\n"); scanf("%d",&num); create(); case 2: delet(); case 3: display(); case 4: exit(0); void create()
28 newnode = (struct node*)malloc(1*sizeof(struct node)); newnode->data=num; if(rear==null) front=rear=newnode; rear->ptr=newnode; rear=newnode; rear->ptr=front; void delet() if(front==null) printf("list is empty\n"); if(front==rear) printf("element deleted is %d",front->data); front=null; temp=front; printf("deleted element is %d",temp->data); temp=temp->ptr; free(front); front=temp; rear->ptr=front;
29 void display() if(front==null) printf("list empty\n"); temp=front; while(temp!=rear) printf("%d\t",temp->data); temp=temp->ptr; printf("%d\n",temp->data); 3.9 Adding and evaluating Polynomials using Circular Linked List #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <math.h> struct node int coeff; int expo; struct node *ptr; ; struct node *head1,*head2,*head3, *temp,*temp1,*temp2,*temp3,*list1,*list2,*list3; struct node *dummy1,*dummy2; void create_poly1(int, int);
30 void create_poly2(int, int); void display(); void add_poly(); void eval_poly(int ); int n,ch; int c,e,i; void main() int x; list1=list2=null; printf("1.create first polynomial\n2.create Second Polynomial\n3.Display both the polynomials\n"); printf("4.add Polynomials\n5.Evaluate a Polynomial\n6.Exit\n"); while(1) printf("enter choice\n"); scanf("%d",&ch); switch(ch) case 1: printf("enter the number of terms\n"); scanf("%d",&n); printf("enter coefficient & power of each term\n"); for(i=0;i<n;i++) scanf("%d%d",&c,&e); create_poly1(c,e); case 2: printf("enter the number of terms\n"); scanf("%d",&n); printf("enter coefficient & power of each term\n");
31 for(i=0;i<n;i++) scanf("%d%d",&c,&e); create_poly2(c,e); case 3: display(); case 4: add_poly(); case 5:printf("Enter the value for x\n"); scanf("%d",&x); eval_poly(x); case 6:exit(0); void create_poly1(int c, int e) dummy1=(struct node*)malloc(1*sizeof(struct node)); dummy1->coeff=0; dummy1->expo=0; dummy1->ptr=list1; if(list1==null) list1=(struct node*)malloc(1*sizeof(struct node)); list1->coeff=c; list1->expo=e; list1->ptr=list1; head1=list1;
32 head1->ptr=dummy1; temp=(struct node*)malloc(1*sizeof(struct node)); temp->coeff=c; temp->expo=e; head1->ptr=temp; temp->ptr=dummy1; head1=temp; void create_poly2(int c, int e) dummy2=(struct node*)malloc(1*sizeof(struct node)); dummy2->coeff=0; dummy2->expo=0; dummy2->ptr=list2; if(list2==null) list2=(struct node*)malloc(1*sizeof(struct node)); list2->coeff=c; list2->expo=e; list2->ptr=list2; head2=list2; head2->ptr=dummy2;
33 temp=(struct node*)malloc(1*sizeof(struct node)); temp->coeff=c; temp->expo=e; head2->ptr=temp; temp->ptr=dummy2; head2=temp; void add_poly() temp1=list1; temp2=list2; while((temp1!=dummy1)&&(temp2!=dummy2)) temp=(struct node*)malloc(1*sizeof(struct node)); if(list3==null) list3=temp; head3=list3; if(temp1->expo==temp2->expo) temp->coeff=temp1->coeff+temp2->coeff; temp->expo=temp1->expo; temp->ptr=list3; head3->ptr=temp; head3=temp; temp1=temp1->ptr; temp2=temp2->ptr;
34 if(temp1->expo>temp2->expo) temp->coeff=temp1->coeff; temp->expo=temp1->expo; temp->ptr=list3; head3->ptr=temp; head3=temp; temp1=temp1->ptr; temp->coeff=temp2->coeff; temp->expo=temp2->expo; temp->ptr=list3; head3->ptr=temp; head3=temp; temp2=temp2->ptr; if(temp1==dummy1) while(temp2!=dummy2) temp=(struct node*)malloc(1*sizeof(struct node)); temp->coeff=temp2->coeff; temp->expo=temp2->expo; temp->ptr=list3; head3->ptr=temp; head3=temp; temp2=temp2->ptr;
35 if(temp2==dummy2) while(temp1!=dummy1) temp=(struct node*)malloc(1*sizeof(struct node)); temp->coeff=temp1->coeff; temp->expo=temp1->expo; temp->ptr=list3; head3->ptr=temp; head3=temp; temp1=temp1->ptr; void display() temp1=list1; temp2=list2; temp3=list3; printf("\npolynomial 1:"); while(temp1!=dummy1) printf("%dx^%d+",temp1->coeff,temp1->expo); temp1=temp1->ptr; printf("\b "); printf("\npolynomial 2:"); while(temp2!=dummy2)
36 printf("%dx^%d+",temp2->coeff,temp2->expo); temp2=temp2->ptr; printf("\b "); printf("\n\nsum OF POLYNOMIALS:\n"); while(temp3->ptr!=list3) printf("%dx^%d+",temp3->coeff,temp3->expo); temp3=temp3->ptr; printf("%dx^%d\n",temp3->coeff,temp3->expo); void eval_poly(int x) int result=0; temp1=list1; temp2=list2; while(temp1!=dummy1) result+=(temp1->coeff)*pow(x,temp1->expo); temp1=temp1->ptr; printf("polynomial 1 Evaluation:%d\n",result); result=0; while(temp2!=dummy2) result+=(temp2->coeff)*pow(x,temp2->expo); temp2=temp2->ptr;
37 printf("polynomial 2 Evaluation:%d\n",result); 3.10 Doubly Linked list operations Below shown C program demonstrates basic operations on Doubly Linked List #include<stdio.h> #include<stdlib.h> #include<string.h> int count=0; struct stud long long int ph; int sem; char name[15],usn[15],brnch[8]; struct stud *next; *head=null,*tail=null,*temp=null,*temp1; void create(long long int n,int s,char na[20],char u[15],char b[5]) if(head==null) head=(struct stud*)malloc(1*sizeof(struct stud)); head->ph=n; head->sem=s; strcpy(head->name,na); strcpy(head->usn,u); strcpy(head->brnch,b); head->next=null; tail=head; count++;
38 temp=(struct stud*)malloc(1*sizeof(struct stud)); temp->ph=n; temp->sem=s; strcpy(temp->name,na); strcpy(temp->usn,u); strcpy(temp->brnch,b); temp->next=null; tail->next=temp; tail=temp; count++; void display() temp1=head; if(temp1==null) printf("\nlist is empty\n"); printf("student details are as follows:\n"); while(temp1!=null) printf(" \n"); printf("name:%s\nusn:%s\nbranch:%s\nsem:%d\nphone NO.:%lld\n",temp1- >name,temp1->usn,temp1->brnch,temp1->sem,temp1->ph); printf(" \n"); temp1=temp1->next; printf("no. of nodes=%d\n",count);
39 void insert_head(long long int n,int s,char na[15],char u[15],char b[8]) temp=(struct stud*)malloc(1*sizeof(struct stud)); temp->ph=n; temp->sem=s; strcpy(temp->name,na); strcpy(temp->usn,u); strcpy(temp->brnch,b); temp->next=head; head=temp; count++; void insert_tail(long long int n,int s,char na[15],char u[15],char b[8]) temp=(struct stud*)malloc(1*sizeof(struct stud)); temp->ph=n; temp->sem=s; strcpy(temp->name,na); strcpy(temp->usn,u); strcpy(temp->brnch,b); tail->next=temp; temp->next=null; tail=temp; count++; void delete_head() temp1=head; if(temp1==null)
40 printf("list is empty\n"); head=head->next; printf("deleted node is:\n"); printf(" \n"); printf("name:%s\nusn:%s\nbranch:%s\nsem:%d\nphone NO.:%lld\n",temp1- >name,temp1->usn,temp1->brnch,temp1->sem,temp1->ph); printf(" \n"); free(temp1); count--; void delete_tail() temp1=head; if(temp1==null) printf("list is empty\n"); while(temp1->next!=tail) temp1=temp1->next; printf("deleted node is:\n"); printf(" \n"); printf("name:%s\nusn:%s\nbranch:%s\nsem:%d\nphone NO.:%lld\n",tail->name,tail- >usn,tail->brnch,tail->sem,tail->ph); printf(" \n");
41 free(tail); tail=temp1; tail->next=null; count--; void main() int choice; long long int ph; int sem; char name[20],usn[15],brnch[5]; printf(" menu \n"); printf("1.create\n2.insert from head\n3.insert from tail\n4.delete from head\5.delete from tail\n6.display\n7.exit\n"); printf(" \n"); while(1) printf("enter your choice\n"); scanf("%d",&choice); switch(choice) case 1: printf("enter the name usn branch sem phno. of the student respectively\n"); scanf("%s%s%s%d%lld",name,usn,brnch,&sem,&ph); create(ph,sem,name,usn,brnch); case 2: printf("enter the name usn branch sem phno. of the student respectively\n"); scanf("%s%s%s%d%lld",name,usn,brnch,&sem,&ph); insert_head(ph,sem,name,usn,brnch); case 3: printf("enter the name usn branch sem phno. of the student respectively\n"); scanf("%s%s%s%d%lld",name,usn,brnch,&sem,&ph);
42 insert_tail(ph,sem,name,usn,brnch); case 4: delete_head(); case 5: delete_tail(); case 6: display(); case 7: exit(0); default:printf("invalid option\n");
Data Structures and Applications (17CS33)
3.7 Reversing a Singly Linked List #include #include struct node int data; struct node *next; ; void insert_list(int); void display(); void revers(); struct node *head,*newnode,*tail,*temp,*temp1,*temp2;
More informationModule III. Linear Data Structures and their Linked Storage Representation
Module III Linear Data Structures and their Linked Storage Representation 3.1 Linked List Linked list is the collection of inter connected nodes with a head node representing the first node and a tail
More informationVivekananda College of Engineering & Technology. Laboratory Manual
Vivekananda College of Engineering & Technology [Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ] Affiliated to Visvesvaraya Technological University Approved by AICTE New Delhi & Govt of Karnataka
More informationVivekananda College of Engineering & Technology. Laboratory Manual
Vivekananda College of Engineering & Technology [Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ] Affiliated to Visvesvaraya Technological University Approved by AICTE New Delhi & Govt of Karnataka
More informationLinked List in Data Structure. By Prof. B J Gorad, BECSE, M.Tech CST, PHD(CSE)* Assistant Professor, CSE, SITCOE, Ichalkaranji,Kolhapur, Maharashtra
Linked List in Data Structure By Prof. B J Gorad, BECSE, M.Tech CST, PHD(CSE)* Assistant Professor, CSE, SITCOE, Ichalkaranji,Kolhapur, Maharashtra Linked List Like arrays, Linked List is a linear data
More informationAIM:- To write a C program to create a singly linked list implementation.
SINGLY LINKED LIST AIM:- To write a C program to create a singly linked list implementation. ALGORITHM:- 1. Start the program. 2. Get the choice from the user. 3. If the choice is to add records, get the
More informationPOLYNOMIAL ADDITION. AIM:- To write a C program to represent a polynomial as a linked list and write functions for polynomial addition.
POLYNOMIAL ADDITION AIM:- To write a C program to represent a polynomial as a linked list and write functions for polynomial addition. ALGORITHM:- 1. Start the program 2. Get the coefficients and powers
More informationData accessing is faster because we just need to specify the array name and the index of the element to be accssed.. ie arrays are simple to use
Module 3 Linear data structures and linked storage representation Advantages of arrays Linear data structures such as stacks and queues can be represented and implemented using sequential allocation ie
More informationDS Lab Manual -17CS33
Chethan Raj C Assistant Professor Dept. of CSE 6. Design, Develop and Implement a menu driven Program in C for the following operations on Circular QUEUE of Characters (Array Implementation of Queue with
More informationUNIT 4: Linked List Programs demonstrated in class. Tojo Mathew Asst. Professor CSE Dept., NIE Mysuru.
UNIT 4: Linked List Programs demonstrated in class. Tojo Mathew Asst. Professor CSE Dept., NIE Mysuru. 1 Table of Contents 1. Array Implementation of Linked List...3 2. Queue using Array Implementation
More informationSolution for Data Structure
Solution for Data Structure May 2016 INDEX Q1 a 2-3 b 4 c. 4-6 d 7 Q2- a 8-12 b 12-14 Q3 a 15-18 b 18-22 Q4- a 22-35 B..N.A Q5 a 36-38 b N.A Q6- a 39-42 b 43 1 www.brainheaters.in Q1) Ans: (a) Define ADT
More informationComputer Systems and Networks
University of the Pacific LECTURE 5: C PROGRAMMING Computer Systems and Networks Dr. Pallipuram (vpallipuramkrishnamani@pacific.edu) Today s Class o Pointer basics o Pointers and mul;- dimensional arrays
More informationPESIT Bangalore South Campus
TEST - 2 Date : 29-9-2014 Marks : 50 Subject & Code : DS(10CS35) Class : III CSE &ISE Name of faculty : Dr.JSP/Mrs.Vandana/Mrs.Renuka Time : 11.30AM to 1 PM Note: Answer any 5 Questions 1 Write a C program
More informationGuide for The C Programming Language Chapter 5
1. Differentiate between primitive data type and non-primitive data type. Primitive data types are the basic data types. These data types are used to represent single values. For example: Character, Integer,
More informationPESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Computer Science and Engineering
USN 1 P E PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Computer Science and Engineering SOLUTION FOR INTERNAL ASSESSMENT TEST 2 Date : 6/10/2017 Marks:
More informationDEV BHOOMI INSTITUTE OF TECHNOLOGY
DEV BHOOMI INSTITUTE OF TECHNOLOGY Department of Computer Science and Engineering Year: 2nd Semester: 3rd Data Structures- PCS-303 LAB MANUAL Prepared By: HOD(CSE) DEV BHOOMI
More informationSTACKS 3.1 INTRODUCTION 3.2 DEFINITION
STACKS 3 3.1 INTRODUCTION A stack is a linear data structure. It is very useful in many applications of computer science. It is a list in which all insertions and deletions are made at one end, called
More informationThis document can be downloaded from with most recent updates. 1 Data Structures using C: Module 4 (16MCA11) LINKED LISTS
1 Data Structures using C: Module 4 (16MCA11) LINKED LISTS 4.1 MEMORY MANAGEMENT 4.1.1 Basics about Memory When a C program is compiled, the compiler translates the source code into machine code. Now the
More informationMODULE V: POINTERS & PREPROCESSORS
MODULE V: POINTERS & PREPROCESSORS INTRODUCTION As you know, every variable is a memory-location and every memory-location has its address defined which can be accessed using ampersand(&) operator, which
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
WINTER 18 EXAMINATION Subject Name: Data Structure using C Model wer Subject Code: 22317 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given
More informationNow consider the following situation after deleting three elements from the queue...
Scheme of valuvation -1I Subject & Code : Data Structure and Application (15CS33) NOTE: ANSWER All FIVE QUESTIONS 1 Explain the diadvantage of linear queue and how it i olved in circular queue. Explain
More informationMC9217 / Programming and Data Structures Lab MC9217 PROGRAMMING AND DATA STRUCTURES LAB L T P C
MC9217 PROGRAMMING AND DATA STRUCTURES LAB L T P C 0 0 3 2 1.Create a Stack and do the following operations using arrays and linked lists (i)push (ii) Pop (iii) Peep 2.Create a Queue and do the following
More informationESc101: (Linear, Circular, Doubly) Linked Lists, Stacks, Queues, Trees. Introduction to Linked Lists
ESc101: (Linear, Circular, Doubly) Linked Lists, Stacks, Queues, Trees Instructor: Krithika Venkataramani Semester 2, 2011-2012 1 Introduction to Linked Lists Each bead connected to the next through a
More informationSingle linked list. Program: #include<stdio.h> #include<conio.h> #include<alloc.h> struct node. int info; struct node *next; void main()
Single linked list Program: #include #include #include struct node int info; struct node *next; ; void main() struct node *s,*start,*prev,*new1,*temp,*temp1,*ptemp; int cho,i,j,x,n,p;
More informationApplication of Stack (Backtracking)
Application of Stack (Backtracking) Think of a labyrinth or maze How do you find a way from an entrance to an exit? Once you reach a dead end, you must backtrack. But backtrack to where? to the previous
More informationLinked Lists and other Dynamic Data Structures
Linked Lists and other Dynamic Data Structures Arrays Fixed in size Allocated in advance within a contiguous memory block Look-up is fast Resizing and Deleting is hard (reallocate and copy) Dynamic Data
More informationAshish Gupta, Data JUET, Guna
Categories of data structures Data structures are categories in two classes 1. Linear data structure: - organized into sequential fashion - elements are attached one after another - easy to implement because
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) WINTER 16 EXAMINATION Model Answer Subject Code:
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate
More informationComputer Systems and Networks
LECTURE 6: C PROGRAMMING Computer Systems and Networks Dr. Pallipuram (vpallipuramkrishnamani@pacific.edu) University of the Pacific Today s Class o Recap from last class o File I/O o What happens during
More informationDEPARTMENT OF COMPUTER SCEINCE AND ENGINEERING DATA STRUCTURES LABORATORY. Subject Code: 17CSL38. B.E - III Semester. Academic Year:
Channabasaveshwara Institute of Technology (Affiliated to VTU, Belgaum & Approved by AICTE, New Delhi) (NAAC Accredited & ISO 9001:2015 Certified Institution) NH 206 (B.H. Road), Gubbi, Tumkur 572 216.
More informationBITS PILANI, DUBAI CAMPUS DUBAI INTERNATIONAL ACADEMIC CITY, DUBAI FIRST SEMESTER
BITS PILANI, DUBAI CAMPUS DUBAI INTERNATIONAL ACADEMIC CITY, DUBAI FIRST SEMESTER 2017-2018 COURSE : COMPUTER PROGRAMMING (CS F111) COMPONENT : Tutorial# 7 (SOLUTIONS) DATE : 06-DEC-2017 Answer 1 enum
More informationGovernment Girls Polytechnic, Bilaspur
Government Girls Polytechnic, Bilaspur Name of the Lab: Programming Lab Practical: Data Structure Lab Class: 4 th Semester (Computer Science & Engineering) Teachers Assessment: 30 End Semester Examination:70
More informationFundamentals of Programming & Procedural Programming
Universität Duisburg-Essen PRACTICAL TRAINING TO THE LECTURE Fundamentals of Programming & Procedural Programming Session Eight: Math Functions, Linked Lists, and Binary Trees Name: First Name: Tutor:
More informationSINGLE LINKED LIST. Algorithm for allocating memory for the new node
SRI CHANDRASEKHARENDRA SARASWATHI VISWA MAHAVIDYALAYA SCSVMV UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Faculty: S.Gokulakrishnan AP/CSE SINGLE LINKED LIST Aim:- Write a C program to implement
More informationModel Solution for QP CODE : ( 3 Hours )
Model Solution for QP CODE : 24788 ( 3 Hours ) All answers are for reference only. Any alternate answer that solves the problem should be considered eqully valid. 1. (a) Define data structure? Give its
More informationProcedural Programming
Exercise 6 (SS 2016) 04.07.2015 What will I learn in the 6. exercise Math functions Dynamic data structures (linked Lists) Exercise(s) 1 Home exercise 4 (3 points) Write a program which is able to handle
More informationBachelor of Engineering First Year II SEMESTER CS6212 PROGRAMMING AND DATA STRUCTURES LABORATORY I LAB MANUAL DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Page 1 CS6212 PROGRAMMING AND DATA STRUCTURES
More information19-Nov CSCI 2132 Software Development Lecture 29: Linked Lists. Faculty of Computer Science, Dalhousie University Heap (Free Store)
Lecture 29 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lecture 29: Linked Lists 19-Nov-2018 Location: Chemistry 125 Time: 12:35 13:25 Instructor: Vlado Keselj Previous
More informationCOP Programming Concepts Spring 1999 CLOSED BOOK Exam #1 100 Points NAME
CLOSED BOOK Exam #1 100 Points NAME 1. The following program has (at least) 10 syntax errors. Circle each error. Write the corrected program in the blank space below. 2 points for each error you find.
More informationDATA STRUCTURE. o DYNAMIC MEMORY. ALLOCATION o SELF-REFERENTIAL STRUCTURE o TYPEDEF LINK LIST STACK QUEUE TREE
DATA STRUCTURE TOPICS PAGE o DYNAMIC MEMORY 2-5 ALLOCATION o SELF-REFERENTIAL STRUCTURE o TYPEDEF LINK LIST 5-16 STACK 17-28 o APPLICATION OF STACK 28-38 QUEUE 39-43 TREE o BINARY SEARCH TREE o HEAP GRAPH
More informationPESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of MCA
USN 1 P E PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of MCA INTERNAL ASSESSMENT TEST 2 (Scheme and Solution) Data Structures Using C (16MCA11) 1) A.
More informationThat means circular linked list is similar to the single linked list except that the last node points to the first node in the list.
Leaning Objective: In this Module you will be learning the following: Circular Linked Lists and it operations Introduction: Circular linked list is a sequence of elements in which every element has link
More informationC PROGRAMMING Lecture 5. 1st semester
C PROGRAMMING Lecture 5 1st semester 2017-2018 Program Address Space The Stack The stack is the place where all local variables are stored a local variable is declared in some scope Example int x; //creates
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
WINTER 17 EXAMINATION Subject Name: Data Structure Using C Model Answer Subject Code: 17330 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as
More informationDC54 DATA STRUCTURES JUNE 2013
Q 2 (a) Define storage class and its functions. Explain in detail scope, storage allocation and purpose of each storage class. 'Storage' refers to the scope of a variable and memory allocated by compiler
More informationDC104 DATA STRUCTURE JUNE Q.2 a. If you are using C language to implement the heterogeneous linked list, what pointer type will you use?
Q.2 a. If you are using C language to implement the heterogeneous linked list, what pointer type will you use? The heterogeneous linked list contains different data types in its nodes and we need a link
More informationStack & Queue on Self-Referencing Structures
C Programming 1 Stack & Queue on Self-Referencing Structures C Programming 2 Representation of Stack struct stack { int data ; struct stack *next ; ; typedef struct stacknode node, *stack ; C Programming
More informationDynamic Memory Allocation
Dynamic Memory Allocation The process of allocating memory at run time is known as dynamic memory allocation. C does not Inherently have this facility, there are four library routines known as memory management
More informationActually, C provides another type of variable which allows us to do just that. These are called dynamic variables.
When a program is run, memory space is immediately reserved for the variables defined in the program. This memory space is kept by the variables until the program terminates. These variables are called
More informationAssignment 6. Q1. Create a database of students using structures, where in each entry of the database will have the following fields:
Assignment 6 Q1. Create a database of students using structures, where in each entry of the database will have the following fields: 1. a name, which is a string with at most 128 characters 2. their marks
More informationLinked-List Basic Examples. A linked-list is Linear collection of self-referential class objects, called nodes Connected by pointer links
Linked-List Basic Examples A linked-list is Linear collection of self-referential class objects, called nodes Connected by pointer links Accessed via a pointer to the first node of the list Subsequent
More informationLINKED LIST IMPLEMENTATION USING C LANGUAGE: A REVIEW
LINKED LIST IMPLEMENTATION USING C LANGUAGE: A REVIEW Ekta Nehra Assistant Professor (Extn.), C.R.M jat college, Hisar, Haryana, (India) ABSTRACT This paper describes about linear data structure i.e. linked
More informationCS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0)
CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) The queue ADT A queue is like a "natural" queue of elements. It is an ordered list in which all insertions occur at one end called
More informationPointers. Array. Solution to the data movement in sequential representation
1 LISTS Pointers Array sequential representation some operation can be very time-consuming (data movement) size of data must be predefined static storage allocation and deallocation Solution to the data
More informationLinked List. April 2, 2007 Programming and Data Structure 1
Linked List April 2, 2007 Programming and Data Structure 1 Introduction head A linked list is a data structure which can change during execution. Successive elements are connected by pointers. Last element
More informationCP2 Revision. theme: dynamic datatypes & data structures
CP2 Revision theme: dynamic datatypes & data structures structs can hold any combination of datatypes handled as single entity struct { }; ;
More informationDarshan Institute of Engineering & Technology for Diploma Studies Unit 3
Linear and Non-Linear Data Structures Linear data structure: Linear data structures are those data structure in which data items are arranged in a linear sequence by physically or logically or both the
More informationBBM 201 DATA STRUCTURES
BBM 201 DATA STRUCTURES Lecture 10: Implementation of Linked Lists (Linked stacks and queues, Circular linked lists) 2015-2016 Fall Linked list implementation of stacks The cost of insert and delete at
More informationClass / Sem: I CSE / II Semester Subject Code: CS 6202 Subject: Programming and Data Structures I Prepared by T. Vithya Unit IV - LINEAR DATA STRUCTURES STACKS AND QUEUES Stack ADT Evaluating arithmetic
More informationInformation Technology Association Department of Information Technology MIT Campus, Anna University Chennai
Algorithm Puzzles - Week1 Solutions 1. Swap two integer variables without using temporary variable. Give at least two different solutions. The first solution is a=a+b; b=a-b; a=a-b; Hope most of you are
More informationStack & Queue on Self-Referencing Structures
PDS: CS 11002 Computer Sc & Engg: IIT Kharagpur 1 Stack & Queue on Self-Referencing Structures PDS: CS 11002 Computer Sc & Engg: IIT Kharagpur 2 Representation of Stack struct stack { int data ; struct
More informationMethodology and Program. By Abhishek Navlakhi Semester 3: Data Structures
Linked List Methodology and Program By Abhishek Navlakhi Semester 3: Data Structures This document is for private circulation for the students of Navlakhi. More educational content can be found on www.navlakhi.com
More information/****************************************** Application: Linked List Example Compiled on: Borland Turbo C++ 3.0
/****************************************** Application: Linked List Example Compiled on: Borland Turbo C++ 3.0 ******************************************/ #include #include /* Structure
More informationDarshan Institute of Engineering & Technology for Diploma studies Unit 4
Pointer A pointer is a variable that contains address or location of another variable. Pointer is a derived data type in C. Pointers contain memory address as their values, so they can also be used to
More information/* Polynomial Expressions Using Linked List*/ #include<stdio.h> #include<conio.h> #include <malloc.h> struct node. int num; int coeff;
/* Polynomial Expressions Using Linked List*/ #include #include #include struct node int num; int coeff; struct node *next; ; struct node *start1 = NULL; struct node *start2
More informationLinked Lists. .. and other linked structures. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR
1 Linked Lists.. and other linked structures Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Dynamic memory allocation: review typedef struct { int hitemp;
More informationBangalore South Campus
USN: 1 P E PESIT Bangalore South Campus Hosur road, 1km before ElectronicCity, Bengaluru -100 Department of Basic Science and Humanities INTERNAL ASSESSMENT TEST 3 Date: 22/11/2017 Time:11:30am- 1.00 pm
More informationUNIT-2 Stack & Queue
UNIT-2 Stack & Queue 59 13. Stack A stack is an Abstract Data Type (ADT), commonly used in most programming languages. It is named stack as it behaves like a real-world stack, for example a deck of cards
More informationThe combination of pointers, structs, and dynamic memory allocation allow for creation of data structures
Data Structures in C C Programming and Software Tools N.C. State Department of Computer Science Data Structures in C The combination of pointers, structs, and dynamic memory allocation allow for creation
More informationProgramming. Lists, Stacks, Queues
Programming Lists, Stacks, Queues Summary Linked lists Create and insert elements Iterate over all elements of the list Remove elements Doubly Linked Lists Circular Linked Lists Stacks Operations and implementation
More information/*Addition of two polynomials*/ #include<stdio.h> #include<malloc.h> #include<conio.h> struct link { int coeff; int pow; struct link *next; }; struct
/*Addition of two polynomials*/ #include #include #include struct link int coeff; int pow; struct link *next; ; struct link *poly1=null,*poly2=null,*poly=null; void create(struct
More informationFrequently asked Data Structures Interview Questions
Frequently asked Data Structures Interview Questions Queues Data Structure Interview Questions How is queue different from a stack? The difference between stacks and queues is in removing. In a stack we
More informationOutline. Briefly review the last class Pointers and Structs Memory allocation Linked lists
Outline Briefly review the last class Pointers and Structs Memory allocation Linked lists C Structures and Memory Allocation A struct is a data structure that comprises multiple types, each known as a
More informationPrepared By:- Dinesh Sharma Asstt. Professor, CSE & IT Deptt. ITM Gurgaon
Data Structures &Al Algorithms Prepared By:- Dinesh Sharma Asstt. Professor, CSE & IT Deptt. ITM Gurgaon What is Data Structure Data Structure is a logical relationship existing between individual elements
More informationCS61, Fall 2012 Section 2 Notes
CS61, Fall 2012 Section 2 Notes (Week of 9/24-9/28) 0. Get source code for section [optional] 1: Variable Duration 2: Memory Errors Common Errors with memory and pointers Valgrind + GDB Common Memory Errors
More informationDC54 DATA STRUCTURES DEC 2014
Q.2 a. Write a function that computes x^y using Recursion. The property that x^y is simply a product of x and x^(y-1 ). For example, 5^4= 5 * 5^3. The recursive definition of x^y can be represented as
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in themodel answer scheme. 2) The model answer and the answer written by candidate may
More informationThe time and space are the two measure for efficiency of an algorithm.
There are basically six operations: 5. Sorting: Arranging the elements of list in an order (either ascending or descending). 6. Merging: combining the two list into one list. Algorithm: The time and space
More informationLists (Section 5) Lists, linked lists Implementation of lists in C Other list structures List implementation of stacks, queues, priority queues
(Section 5) Lists, linked lists Implementation of lists in C Other list structures List implementation of stacks, queues, priority queues By: Pramod Parajuli, Department of Computer Science, St. Xavier
More informationBasically queue is nothing but an array or a vector with a maximum capacity of size. Front=1 Front=1 REAR=2. Front=1 REAR=3 Front=1 REAR=4 Q is Full
Queue A Queue is defined as linear list in which insertion is taking place at one end and deletion is taking place at the other end. The end where insertion is taking place is called as rear end. The end
More informationUnit-2. Stacks: Introduction-Definition-Representation of Stack-Operations on Stacks- Applications of Stacks.
Unit-2 Stacks: Introduction-Definition-Representation of Stack-Operations on Stacks- Applications of Stacks. Queues: Introduction, Definition- Representations of Queues- Various Queue Structures- Applications
More informationWhat is recursion. WAP to find sum of n natural numbers using recursion (5)
DEC 2014 Q1 a What is recursion. WAP to find sum of n natural numbers using recursion (5) Recursion is a phenomenon in which a function calls itself. A function which calls itself is called recursive function.
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
WINTER 18 EXAMINATION Subject Name: Data Structure Model wer Subject Code: 17330 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in
More informationSelf-referential Structures and Linked List. Programming and Data Structure 1
Self-referential Structures and Linked List Programming and Data Structure 1 Linked List :: Basic Concepts A list refers to a set of items organized sequentially. An array is an example of a list. The
More informationDoubly Linked List Methodology and Program
Doubly Linked List Methodology and Program Semester 3: Data Structures This document is for private circulation for the students of Navlakhi. More educational content can be found on www.navlakhi.com and
More informationMODULE 3: LINKED LIST
MODULE 3: LINKED LIST DEFINITION A linked list, or one-way list, is a linear collection of data elements, called nodes, where the linear order is given by means of pointers. That is, each node is divided
More informationPESIT Bangalore South Campus Hosur road, 1km before ElectronicCity, Bengaluru -100 Department of Basic Science and Humanities
INTERNAL ASSESSMENT TEST-3 Date : 12-05-2016 Marks: 40 Subject & Code : Programming in C and data structures (15PCD23) Sec : F,G,H,I,J,K Name of faculty :Dr J Surya Prasad/Mr.Sreenath M V/Ms.Monika/ Time
More informationChapter 8 STRUCTURES IN C
Chapter 8 STRUCTURES IN C 1 Structures Introduction Collections of related variables (aggregates) under one name Can contain variables of different data types Commonly used to define records to be stored
More informationS.Y. Diploma : Sem. III [CO/CM/IF/CD/CW] Data Structure using C
S.Y. Diploma : Sem. III [CO/CM/IF/CD/CW] Data Structure using C Time: 3 Hrs.] Prelim Question Paper Solution [Marks : 100 Q.1 (a) Attempt any SIX of the following : [12] Q.1 (a) (i) Define time complexity
More informationMODULE 5: Pointers, Preprocessor Directives and Data Structures
MODULE 5: Pointers, Preprocessor Directives and Data Structures 1. What is pointer? Explain with an example program. Solution: Pointer is a variable which contains the address of another variable. Two
More informationWrite a program that creates in the main function two linked lists of characters and fills them with the following values:
Write a program that creates in the main function two linked lists of characters and fills them with the following values: The first list will have 3 nodes with the following characters: A,B, and C. The
More informationSpring 2008 Data Structures (CS301) LAB
Spring 2008 Data Structures (CS301) LAB Objectives The objectives of this LAB are, o Enabling students to implement Singly Linked List practically using c++ and adding more functionality in it. o Enabling
More informationA. Year / Module Semester Subject Topic 2016 / V 2 PCD Pointers, Preprocessors, DS
Syllabus: Pointers and Preprocessors: Pointers and address, pointers and functions (call by reference) arguments, pointers and arrays, address arithmetic, character pointer and functions, pointers to pointer,initialization
More informationSingly linked lists in C.
Singly linked lists in C http://www.cprogramming.com/tutorial/c/lesson15.html By Alex Allain Linked lists are a way to store data with structures so that the programmer can automatically create a new place
More informationMULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR
STUDENT IDENTIFICATION NO MULTIMEDIA COLLEGE JALAN GURNEY KIRI 54100 KUALA LUMPUR FIFTH SEMESTER FINAL EXAMINATION, 2014/2015 SESSION PSD2023 ALGORITHM & DATA STRUCTURE DSEW-E-F-2/13 25 MAY 2015 9.00 AM
More informationQueues. Manolis Koubarakis. Data Structures and Programming Techniques
Queues Manolis Koubarakis 1 The ADT Queue A queue Q of items of type T is a sequence of items of type T on which the following operations are defined: Initialize the queue to the empty queue. Determine
More informationCS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0)
CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0) Teacher: Sourangshu Bha@acharya sourangshu@gmail.com h@p://cse.iitkgp.ac.in/~sourangshu/ Department of Computer Science and Engineering
More informationIntroduction to Data Structures. Systems Programming
Introduction to Data Structures Systems Programming Intro to Data Structures Self-referential Structures Dynamic Memory Allocation A Simple malloc Example Linear Lists Linked Lists Insertion Example Linked
More informationDynamic Data Structures
Dynamic Data Structures We have seen that the STL containers vector, deque, list, set and map can grow and shrink dynamically. We now examine how some of these containers can be implemented in C++. To
More informationData Structure & Algorithms Laboratory Manual (CS 392)
Institute of Engineering & Management Department of Computer Science & Engineering Data Structure Laboratory for 2 nd year 3 rd semester Code: CS 392 Data Structure & Algorithms Laboratory Manual (CS 392)
More information