Data 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

Size: px
Start display at page:

Download "Data 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"

Transcription

1 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 using arrays. Use of arrays have the following advantages Data 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 Disadvantages The size of the array is fixed. This limits the user in determining the required storage well in advance. However memory requirement cannot be determined while writing the program. ie if the allocation is more and required is less then memory is wasted. Similarly if less memory is allocated and requirement is more then we cannot allocate memory during execution. Also array items are stored sequentially. In such a case contigious memory may not be available. Most of the times chunks of memory will be available but they cannot be used as they are not contiguous. Finally insertion and deletion of items in a array is difficult. Insertion of an element at the i th position requires us to move all the elements from i+1 th position To the next position and only after this movement insertion can be performed. A similar movement is required for deletion also. Linked lists A linked list is a collection of zero or more nodes where each node has some information Info link Link will contain the address of the next node Info will contain the information. Hence if the address of a node is known we can easily access the subsequent nodes 1

2 Types of lists Singly linked lists doubly linked lists circular linked lists circular doubly linked lists Singly linked list A singly linked list is a collection of zero or more nodes. Each node will have one info field and one link field. A chain is a singly list with zero or more nodes. A empty list is as shown \0 A list is represented as follows First Note: List contains 4 nodes where each node contains a info and link fields Info filed contains the data Link field contains the address of the next node First is a variable containing the address of the first node of the list Using first we can access any node in the list The link field of the last node will have NULL 2

3 Representation Nodes in the list are self referential structures. A structure is a collection of one or more fields which are of the same type or different type. A self refrential structure is a structure which has at least one field which is a pointer to the same structure. ex struct node Int info; Struct node * link; ; Info is a int containing integer data Link is a pointer and should contain the address and normally it contains the address of the next node Declaration of variable We have the following declaration struct node Int info; Struct node * link; ; typedef struct node * NODE; now a pointer variable first can be declared as NODE first; Creation of a empty list 3

4 Before creating a list we need to create a empty list first. This is achieved by assigning NULL to the variable first ie first=null creating a new node A new node is created as follows First=(NODE) malloc(1 * sizeof(node)) The above statement will allocate memory to the variable first Using first we can access the contents of the node such as First->info or first->link(for the next node) To store the data. We use First->info=10; We need to store NULL as this is the first node First->link=NULL Deleting a node Any node which is not required is deleted using the free function Free(first); When the above statement is executed the memory which was allocated to first using malloc is deallocated and returned to the OS. The variable first will have a invalid address and hence is called as dangling pointer Operations on a singly linked list Inserting a node Deleting a node Search for a node 4

5 Display the list #include<stdio.h> #include<stdlib.h> // Declaration of the node struct node int data; struct node *next; *head; //function to add a node at the end of the list void append(int num) struct node *temp,*right; temp= (struct node *)malloc(sizeof(struct node)); temp->data=num; right=(struct node *)head; while(right->next!= NULL) right=right->next; right->next =temp; right=temp; right->next=null; void add( int num ) struct node *temp; temp=(struct node *)malloc(sizeof(struct node)); temp->data=num; if (head== NULL) head=temp; head->next=null; else 5

6 temp->next=head; head=temp; //function to add a node after a given node void addafter(int num, int loc) int i; struct node *temp,*left,*right; right=head; for(i=1;i<loc;i++) left=right; right=right->next; temp=(struct node *)malloc(sizeof(struct node)); temp->data=num; left->next=temp; left=temp; left->next=right; return; //function to insert a node void insert(int num) int c=0; struct node *temp; temp=head; if(temp==null) add(num); else while(temp!=null) if(temp->data<num) c++; temp=temp->next; if(c==0) add(num); 6

7 else if(c<count()) addafter(num,++c); else append(num); //function to delete a node int delete(int num) struct node *temp, *prev; temp=head; while(temp!=null) if(temp->data==num) if(temp==head) head=temp->next; free(temp); return 1; else prev->next=temp->next; free(temp); return 1; else prev=temp; temp= temp->next; return 0; 7

8 // function to display a list void display(struct node *r) r=head; if(r==null) return; while(r!=null) printf("%d ",r->data); r=r->next; printf("\n"); //function to count the number of nodes in a list int count() struct node *n; int c=0; n=head; while(n!=null) n=n->next; c++; return c; 8

9 // main program to perform all the operations int main() int i,num; struct node *n; head=null; while(1) printf("\nlist Operations\n"); printf("1.insert\n"); printf("2.display\n"); printf("3.size\n"); printf("4.delete\n"); printf("5.exit\n"); printf("enter your choice : "); scanf("%d",&i) switch(i) case 1: printf("enter the number to insert : "); scanf("%d",&num); insert(num); case 2: if(head==null) printf("list is Empty\n"); else printf("element(s) in the list are : "); display(n); 9

10 return 0; case 3: printf("size of the list is %d\n",count()); case 4: if(head==null) printf("list is Empty\n"); else printf("enter the number to delete : "); scanf("%d",&num); if(delete(num)) printf("%d deleted successfully\n",num); else printf("%d not found in the list\n",num); case 5: return 0; default: printf("invalid option\n"); Function to search for a element in a list void search(struct node *head, int key) while (head!= NULL) if (head->a == key) printf("key found\n"); return; head = head->next; printf("key not found\n"); 10

11 Circular linked list Circular Linked List is little more complicated linked data structure. In the circular linked list we can insert elements anywhere in the list whereas in the array we cannot insert element anywhere in the list because it is in the contiguous memory. In the circular linked list the previous element stores the address of the next element and the last element stores the address of the starting element. The elements points to each other in a circular way which forms a circular chain. The circular linked list has a dynamic size which means the memory can be allocated when it is required. Application of Circular Linked List The real life application where the circular linked list is used is our Personal Computers, where multiple applications are running. All the running applications are kept in a circular linked list and the OS gives a fixed time slot to all for running. The Operating System keeps on iterating over the linked list until all the applications are completed. Another example can be Multiplayer games. All the Players are kept in a Circular Linked List and the pointer keeps on moving forward as a player's chance ends. Circular Linked List can also be used to create Circular Queue. In a Queue we have to keep two pointers, FRONT and REAR in memory all the time, where as in Circular Linked List, only one pointer is required. 11

12 #include<stdio.h> #include<conio.h> struct circular int i; struct circular *next; ; struct circular *temp; struct circular *head; struct circular *p; struct circular *mid; struct circular *move; int cnt=0; void create(void); void insert(void); void display(void); void del(void); void main() int ch=0; clrscr(); while(ch!=5) printf("\n1.create"); printf("\n2.insert"); printf("\n3.delete"); printf("\n4.display"); printf("\n5.exit"); scanf("%d",&ch); if(ch==1) create(); 12

13 cnt++; cnt++; if(ch==2) insert(); cnt++; if(ch==3) del(); cnt--; if(ch==4) display(); if(ch==5) getch(); void create() head=(struct circular *)malloc(sizeof(struct circular)); head->next=head; printf("eneter THE DATA"); scanf("%d",&head->i); temp=head; temp->next=(struct circular *)malloc(sizeof(struct circular)); temp=temp->next; temp->next=head; printf("eneter THE DATA"); scanf("%d",&temp->i); 13

14 void insert() int add,t; printf("\n\t ENTER ANY NUMBER BETWEEN 1 AND %d",cnt); scanf("%d",&add); p=head; t=1; while(t<add) p=p->next; t++; printf("%d",p->i); clrscr(); mid=(struct circular *)malloc(sizeof(struct circular)); printf("eneter THE DATA"); scanf("%d",&mid->i); mid->next=p->next; p->next=mid; void display() p=head; printf("%d-->",p->i); p=p->next; 14

15 while(p!=head) printf("%d-->",p->i); p=p->next; void del(void) int add,t; printf("\n\t ENTER ANY NUMBER BETWEEN 1 AND %d",cnt); scanf("%d",&add); p=head; t=1; while(t<add-1) p=p->next; t++; printf("%d",p->i); clrscr(); mid=p->next; p->next=mid->next; Doubly linked list In computer science, a doubly linked list is a linked data structure that consists of a set of sequentially linked records called nodes. Each node contains two fields, called links, that are references to the previous and to the next node in the sequence of nodes. The beginning and ending nodes' previous and next links, respectively, point to some kind of terminator, typically a sentinel node or null, to facilitate traversal of the list. If there is only one sentinel node, then the list is circularly linked via the sentinel node. It can be conceptualized as two singly linked lists formed from the same data items, but in opposite sequential orders. A doubly linked list whose nodes contain three fields: an integer value, the link to the next node, and the link to the previous node. The two node links allow traversal of the list in either direction. While adding or removing a node in a doubly linked list requires changing more links than the same operations on a singly 15

16 linked list, the operations are simpler and potentially more efficient (for nodes other than first nodes) because there is no need to keep track of the previous node during traversal or no need to traverse the list to find the previous node, so that its link can be modified. #include<stdio.h> #include<conio.h> #include<stdlib.h> //define the structure struct node struct node *previous; int data; struct node *next; *head, *last; //function to insert ate the beginning void insert_begning(int value) 16

17 struct node *var,*temp; var=(struct node *)malloc(sizeof(struct node)); var->data=value; if(head==null) head=var; head->previous=null; head->next=null; last=head; else temp=var; temp->previous=null; temp->next=head; head->previous=temp; head=temp; // function to insert at the end of the list void insert_end(int value) struct node *var,*temp; var=(struct node *)malloc(sizeof(struct node)); var->data=value; if(head==null) head=var; head->previous=null; head->next=null; last=head; else last=head; while(last!=null) temp=last; last=last->next; last=var; temp->next=last; last->previous=temp; 17

18 last->next=null; // function to insert after a node int insert_after(int value, int loc) struct node *temp,*var,*temp1; var=(struct node *)malloc(sizeof(struct node)); var->data=value; if(head==null) head=var; head->previous=null; head->next=null; else temp=head; while(temp!=null && temp->data!=loc) temp=temp->next; if(temp==null) printf("\n%d is not present in list ",loc); else temp1=temp->next; temp->next=var; var->previous=temp; var->next=temp1; temp1->previous=var; last=head; while(last->next!=null) last=last->next; //function to delete at the end of the list 18

19 int delete_from_end() struct node *temp; temp=last; if(temp->previous==null) free(temp); head=null; last=null; return 0; printf("\ndata deleted from list is %d \n",last->data); last=temp->previous; last->next=null; free(temp); return 0; // function to delete a node from the middle of the list int delete_from_middle(int value) struct node *temp,*var,*t, *temp1; temp=head; while(temp!=null) if(temp->data == value) if(temp->previous==null) free(temp); head=null; last=null; return 0; else var->next=temp1; temp1->previous=var; free(temp); return 0; else 19

20 var=temp; temp=temp->next; temp1=temp->next; printf("data deleted from list is %d",value); // function to display the list void display() struct node *temp; temp=head; if(temp==null) printf("list is Empty"); while(temp!=null) printf("-> %d ",temp->data); temp=temp->next; // main program int main() int value, i, loc; head=null; printf("select the choice of operation on link list"); printf("\n1.) insert at begning\n2.) insert at at\n3.) insert at middle"); printf("\n4.) delete from end\n5.) reverse the link list\n6.) display list\n7.)exit"); while(1) printf("\n\nenter the choice of operation you want to do "); scanf("%d",&i); switch(i) case 1: printf("enter the value you want to insert in node "); scanf("%d",&value); 20

21 insert_begning(value); display(); case 2: printf("enter the value you want to insert in node at last "); scanf("%d",&value); insert_end(value); display(); case 3: printf("after which data you want to insert data "); scanf("%d",&loc); printf("enter the data you want to insert in list "); scanf("%d",&value); insert_after(value,loc); display(); case 4: delete_from_end(); display(); case 5: printf("enter the value you want to delete"); scanf("%d",value); delete_from_middle(value); display(); case 6 : display(); case 7 : exit(0); 21

22 printf("\n\n%d",last->data); display(); getch(); Applications of linked lists Polynomial addition A polynomial is sum of terms where each term is of the form ax e Where a is the coefficient is the variable, e is the exponent The largest exponent is also called as the degree. Various operations can be performed on the polynomials Iszero(poly)-Returns 0 if the polynomial does not exist Coeff(poly,expo)-returns the coefficient Leadexpo(poly)-returns the largest exponent Attach- Attach a term<coeff,expo> onto the polynomial 22

23 Remove (poly,expo)-delete a term Add(poly1,poly2)-adds two polynomials General procedure to add two polynomials Three cases exist Case 0 : Powers of the two terms to be added are equal In such a case the coefficients of the two terms are added using Sum=coeff(a,leadexpo(a)+coeff(b,leadexpo(b)) And then insert the resultant term on to the resulting polynomial using the attach function. We move onto the next term using the remove function. Ie A=remove(a,leadexpo(a)); B= remove (b,leadexpo(b)); Case 1: Power of the first term is > power the second term In such a case we insert the first term onto the resulting polynomial using Attach(c,coeff(a,leadexpo(a)) And move onto the next term using remove function A=remove(a,leadexpo(a) Default case: Here the power of the first term is < the power of the second term In such a case we insert the second term onto the resulting polynomial using Attach(c,coeff(b,leadexpo(b)) And move onto the next term using remove function b=remove(b,leadexpo(b) 23

24 //9.c polynomial operations #include<stdio.h> #include<process.h> #include<conio.h> #include<math.h> typedef struct node int expo,coef; struct node* next; node; node * insert(node *,int,int); node * create(); node * add(node *p1,node *p2); int eval(node *p1); void display(node *head); node * insert(node *head,int coef1,int expo1) node *p,*q; p=(node *) malloc(sizeof(node)); p->expo=expo1; 24

25 p->coef=coef1; p->next=null; if(head==null) head=p; head->next=head; return (head); if(expo1>head->expo) p->next=head->next; head->next=p; head=p; return(head); if(expo1==head->expo) head->coef=head->coef+coef1; return(head); q=head; while(q->next!=head && expo1>=q->next->expo) 25

26 ////insert q=q->next; if(p->expo==q->expo) q->coef=q->coef+coef1; else p->next=q->next; q->next=p; return (head); ////inserted node *create() int n,i,expo1,coef1; node *head =NULL; printf("\n enter num of poly terms"); scanf("%d",&n); for(i=0;i<n;i++) printf("\n enter coef and expo"); scanf("%d%d",&coef1,&expo1); head=insert(head,coef1,expo1); 26

27 return (head); node *add(node *p1,node *p2) node *p; node *head=null; printf("\n addition of ploy"); p=p1->next; do head=insert(head,p->coef,p->expo); p=p->next; while(p!=p1->next); p=p2->next; do head=insert(head,p->coef,p->expo); p=p->next; while(p!=p2->next); return (head); int eval(node *head) 27

28 node *p; int x,ans=0; printf("\n enter the value of x"); scanf("%d",&x); p=head->next; do ans=ans+p->coef*pow(x,p->expo); p=p->next; while(p!=head->next); return (ans); void display(node *head) node *p,*q; int n=0; q=head->next; p=head->next; do n++; q=q->next; 28

29 while(q!=head->next); printf("\n poly is "); do if(n-1) printf(" %dx^(%d) + ",p->coef,p->expo); p=p->next; else printf(" %dx^(%d)",p->coef,p->expo); p=p->next; n--; while(p!=head->next); void main() node *p1,*p2,*p3; int a,x,ch; p1=p2=p3=null; 29

30 while(1) printf("\n1.add"); printf("\n2.evaluate"); printf("\n 3.exit"); printf("enter ur choice"); scanf("%d",&ch); switch(ch) case 1: p1=create(); display(p1); p2=create(); display(p2); p3=add(p1,p2); display(p3); case 2: p1=create(); display(p1); a=eval(p1); printf("\n value of poly is %d",a); case 3: exit(0); 30

31 default: printf("\n invalid choice"); 31

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 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 information

Fundamentals of Programming & Procedural Programming

Fundamentals 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 information

Module III. Linear Data Structures and their Linked Storage Representation

Module 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 information

AIM:- To write a C program to create a singly linked list implementation.

AIM:- 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 information

NOTES SUBJECT: DATA STRUCTURES USING C. BRANCH: CSE SEM: 3 rd SESSION: Evaluation Scheme SUBJECT CODE: NCS-301

NOTES SUBJECT: DATA STRUCTURES USING C. BRANCH: CSE SEM: 3 rd SESSION: Evaluation Scheme SUBJECT CODE: NCS-301 NOTES SUBJECT: DATA STRUCTURES USING C SUBJECT CODE: NCS-301 BRANCH: CSE SEM: 3 rd SESSION: 2014-15 Evaluation Scheme Subject Code NCS-301 Name of Subject Data Structures Using C Periods Evaluation Scheme

More information

UNIT 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. 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 information

Procedural Programming

Procedural 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 information

LINKED LIST IMPLEMENTATION USING C LANGUAGE: A REVIEW

LINKED 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 information

Data Structures and Applications (17CS33)

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 information

POLYNOMIAL 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. 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 information

Solution for Data Structure

Solution 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 information

SINGLE LINKED LIST. Algorithm for allocating memory for the new node

SINGLE 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 information

Ashish Gupta, Data JUET, Guna

Ashish 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 information

That means circular linked list is similar to the single linked list except that the last node points to the first node in the list.

That 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 information

DEV BHOOMI INSTITUTE OF TECHNOLOGY

DEV 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 information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

MAHARASHTRA 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 information

Procedural Programming & Fundamentals of Programming

Procedural Programming & Fundamentals of Programming & Fundamentals of Programming Exercise 4 (SS 2018) 12.06.2018 What will I learn in the 5. exercise Files Math functions Dynamic data structures (linked Lists) Exercise(s) 1 Files A file can be seen as

More information

Linked Lists and other Dynamic Data Structures

Linked 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 information

DS Lab Manual -17CS33

DS 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 information

NCS 301 DATA STRUCTURE USING C

NCS 301 DATA STRUCTURE USING C NCS 301 DATA STRUCTURE USING C Unit-1 Part-4 Linked Lists Hammad Mashkoor Lari Assistant Professor Allenhouse Institute of Technology www.ncs301ds.wordpress.com Introduction List refers to linear collection

More information

This document can be downloaded from with most recent updates. 1 Data Structures using C: Module 4 (16MCA11) LINKED LISTS

This 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 information

Information Technology Association Department of Information Technology MIT Campus, Anna University Chennai

Information 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 information

Single 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<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 information

MODULE V: POINTERS & PREPROCESSORS

MODULE 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 information

Now consider the following situation after deleting three elements from the queue...

Now 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 information

ESc101: (Linear, Circular, Doubly) Linked Lists, Stacks, Queues, Trees. Introduction to Linked Lists

ESc101: (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 information

Module III. Linear Data Structures and their Linked Storage Representation

Module 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 information

Pointers. Array. Solution to the data movement in sequential representation

Pointers. 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 information

STACKS 3.1 INTRODUCTION 3.2 DEFINITION

STACKS 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 information

Lists (Section 5) Lists, linked lists Implementation of lists in C Other list structures List implementation of stacks, queues, priority queues

Lists (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 information

BBM 201 DATA STRUCTURES

BBM 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 information

PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of MCA

PESIT 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 information

Fall, 2015 Prof. Jungkeun Park

Fall, 2015 Prof. Jungkeun Park Data Structures t and Algorithms Circular lists / Doubly linked lists Fall, 2015 Prof. Jungkeun Park Copyright Notice: This material is modified version of the lecture slides by Prof. Rada Mihalcea in

More information

DC54 DATA STRUCTURES JUNE 2013

DC54 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 information

The combination of pointers, structs, and dynamic memory allocation allow for creation of data structures

The 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 information

PROGRAMMAZIONE I A.A. 2017/2018

PROGRAMMAZIONE I A.A. 2017/2018 PROGRAMMAZIONE I A.A. 2017/2018 LINKED LISTS LINKED LIST What are the problems with arrays? üsize is fixed üarray items are stored contiguously üinsertions and deletions at particular positions is complex

More information

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING LAB MANUAL. Academic Year: ODD SEMESTER

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING LAB MANUAL. Academic Year: ODD SEMESTER DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING LAB MANUAL Academic Year: 2015-16 ODD SEMESTER Programme (UG/PG) : UG Semester : IV Course Code : CS1032 Course Title : Data Structures & Algorithms Lab Prepared

More information

The time and space are the two measure for efficiency of an algorithm.

The 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 information

Downloaded from : Algorithm: Implementation QUESTION 1 :

Downloaded from :   Algorithm: Implementation QUESTION 1 : QUESTION 1 : WRITE AN ALGORITHM THAT ACCEPTS A BINARY TREE AS INPUT AND PR INTS ITS HEIGHT TO STANDARD OUTPUT. Algorithm: 1. If tree is empty then return 0 2. Else (a) Get the max depth of left subtree

More information

/*Tree Traversals*/ #include<stdio.h> #include<conio.h> typedef struct bin { int data; struct bin *left,*right; }node;

/*Tree Traversals*/ #include<stdio.h> #include<conio.h> typedef struct bin { int data; struct bin *left,*right; }node; /*Tree Traversals*/ #include #include typedef struct bin int data; struct bin *left,*right; node; void insert(node *,node *); void inorder(node *); void preorder(node *); void postorder(node

More information

Computer Systems and Networks

Computer 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 information

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0)

CS11001/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 information

PESIT Bangalore South Campus

PESIT 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 information

UNIT IV 4 LINKED LIST

UNIT IV 4 LINKED LIST 4 UNIT IV LINKED LIST LINKED LIST SYLLABUS: 4.1 Pointers Revision 4.2 Revision of Structure 4.3 Revision of structure using pointers 4.4 Dynamic Memory Allocation 4.5 Linked list Presentation 4.6 Types

More information

MODULE 1. Introduction to Data Structures

MODULE 1. Introduction to Data Structures MODULE 1 Introduction to Data Structures Data Structure is a way of collecting and organizing data in such a way that we can perform operations on these data in an effective way. Data Structures is about

More information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) WINTER 16 EXAMINATION Model Answer Subject Code:

MAHARASHTRA 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 information

Chapter 4. LISTS. 1. Pointers

Chapter 4. LISTS. 1. Pointers Chap 4: LIST (Page 1) Chapter 4. LISTS TABLE OF CONTENTS 1. POINTERS 2. SINGLY LINKED LISTS 3. DYNAMICALLY LINKED STACKS AND QUEUES 4. POLYNOMIALS 5. ADDITIONAL LIST OPERATIONS 6. EQUIVALENCE RELATIONS

More information

MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) Subject Code: 17330 Model Answer Page 1/ 22 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

More information

C PROGRAMMING Lecture 5. 1st semester

C 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 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<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 information

What is recursion. WAP to find sum of n natural numbers using recursion (5)

What 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 information

MC9217 / Programming and Data Structures Lab MC9217 PROGRAMMING AND DATA STRUCTURES LAB L T P C

MC9217 / 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 information

S.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 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 information

DATA STRUCTURE ASSIGNMENT

DATA STRUCTURE ASSIGNMENT PROGRAM TO SEARCH AN ITEM FROM AN ARRAY USING BINARY SEARCH: CODE:- #include #include int main() int a[100],n,start,end,mid,i,s,j,swap; printf("enter the Number of Terms: "); scanf("%d",&n);

More information

DOWNLOAD PDF LINKED LIST PROGRAMS IN DATA STRUCTURE

DOWNLOAD PDF LINKED LIST PROGRAMS IN DATA STRUCTURE Chapter 1 : What is an application of linear linked list data structures? - Quora A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. The elements

More information

AE52/AC52/AT52 C & Data Structures JUNE 2014

AE52/AC52/AT52 C & Data Structures JUNE 2014 Q.2 a. Write a program to add two numbers using a temporary variable. #include #include int main () int num1, num2; clrscr (); printf( \n Enter the first number : ); scanf ( %d, &num1);

More information

MODULE 3: LINKED LIST

MODULE 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 information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

MAHARASHTRA 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 information

A. Year / Module Semester Subject Topic 2016 / V 2 PCD Pointers, Preprocessors, DS

A. 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 information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

MAHARASHTRA 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 information

Sree Vidyanikethan Engineering College Sree Sainath Nagar, A. Rangampet

Sree Vidyanikethan Engineering College Sree Sainath Nagar, A. Rangampet Sree Vidyanikethan Engineering College Sree Sainath Nagar, A. Rangampet 517 102 Department of Computer Science and Engineering I B. Tech C Programming Language Lab Title: Stack SVEC/IT/EXPT-CP-21 PROBLEM

More information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

MAHARASHTRA 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 information

CS6202 - PROGRAMMING & DATA STRUCTURES I Unit IV Part - A 1. Define Stack. A stack is an ordered list in which all insertions and deletions are made at one end, called the top. It is an abstract data type

More information

Stack & Queue on Self-Referencing Structures

Stack & 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 information

BITS PILANI, DUBAI CAMPUS DUBAI INTERNATIONAL ACADEMIC CITY, DUBAI FIRST SEMESTER

BITS 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 information

DC54 DATA STRUCTURES DEC 2014

DC54 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 information

Prepared By:- Dinesh Sharma Asstt. Professor, CSE & IT Deptt. ITM Gurgaon

Prepared 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 information

Darshan Institute of Engineering & Technology for Diploma studies Unit 4

Darshan 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

COP Programming Concepts Spring 1999 CLOSED BOOK Exam #1 100 Points NAME

COP 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 information

Linked List. April 2, 2007 Programming and Data Structure 1

Linked 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 information

DC104 DATA STRUCTURE JUNE Q.2 a. If you are using C language to implement the heterogeneous linked list, what pointer type will you use?

DC104 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 information

BBM 201 DATA STRUCTURES

BBM 201 DATA STRUCTURES BBM 201 DATA STRUCTURES Lecture 10: Implementation of Linked Lists (Stacks, Queue, Hashtable) 2017-2018 Fall Linked list implementation of stacks The cost of insert and delete at the beginning of a linked

More information

APS105. Structures 11/18/2013. Example A struct of stock items at a store: Structures. Lists. Arrays allow a collection of elements

APS105. Structures 11/18/2013. Example A struct of stock items at a store: Structures. Lists. Arrays allow a collection of elements APS105 Lists Structures Textbook Chapters 10.1, 10.3, 10.4, 10.6 2 Structures Arrays allow a collection of elements All of the same type How to collect elements of different types? Structures; in C: struct

More information

a) State the need of data structure. Write the operations performed using data structures.

a) State the need of data structure. Write the operations performed using data structures. 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 information

Chapter 4: Lists 2004 년가을학기. 강경란 정보및컴퓨터공학부, 아주대학교

Chapter 4: Lists 2004 년가을학기. 강경란 정보및컴퓨터공학부, 아주대학교 Chapter 4: Lists 2004 년가을학기 강경란 korykang@ajou.ac.kr 정보및컴퓨터공학부, 아주대학교 1. Pointers 2. Singly Linked Lists Chapter 4 Lists 3. Dynamically Linked Stacks and Queues 4. Polynomials 5. Additional List Operations

More information

19-Nov CSCI 2132 Software Development Lecture 29: Linked Lists. Faculty of Computer Science, Dalhousie University Heap (Free Store)

19-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 information

Programming. Lists, Stacks, Queues

Programming. 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

PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Computer Science and Engineering

PESIT 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 information

UNIT-I Fundamental Notations

UNIT-I Fundamental Notations UNIT-I Fundamental Notations Introduction to Data Structure We know that data are simply values or set of values and information is the processed data. And actually the concept of data structure is much

More information

Methodology and Program. By Abhishek Navlakhi Semester 3: Data Structures

Methodology 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

CSE2301. Dynamic memory Allocation. malloc() Dynamic Memory Allocation and Structs

CSE2301. Dynamic memory Allocation. malloc() Dynamic Memory Allocation and Structs Warning: These notes are not complete, it is a Skelton that will be modified/add-to in the class. If you want to us them for studying, either attend the class or get the completed notes from someone who

More information

Introduction to Programming in C Department of Computer Science and Engineering

Introduction to Programming in C Department of Computer Science and Engineering Introduction to Programming in C Department of Computer Science and Engineering Once we know structures and pointers to structures, we can introduce some very important data structure called link list.

More information

Cpt S 122 Data Structures. Data Structures

Cpt S 122 Data Structures. Data Structures Cpt S 122 Data Structures Data Structures Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Topics Introduction Self Referential Structures Dynamic Memory Allocation

More information

Computer Systems and Networks

Computer 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 information

MTH 307/417/515 Final Exam Solutions

MTH 307/417/515 Final Exam Solutions MTH 307/417/515 Final Exam Solutions 1. Write the output for the following programs. Explain the reasoning behind your answer. (a) #include int main() int n; for(n = 7; n!= 0; n--) printf("n =

More information

Darshan Institute of Engineering & Technology for Diploma Studies Unit 3

Darshan 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 information

Stack & Queue on Self-Referencing Structures

Stack & 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 information

Actually, C provides another type of variable which allows us to do just that. These are called dynamic variables.

Actually, 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 information

Subject: Fundamental of Computer Programming 2068

Subject: Fundamental of Computer Programming 2068 Subject: Fundamental of Computer Programming 2068 1 Write an algorithm and flowchart to determine whether a given integer is odd or even and explain it. Algorithm Step 1: Start Step 2: Read a Step 3: Find

More information

UNIT-2 Stack & Queue

UNIT-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 information

DATA STRUCTURE LAB DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING CS09 407(P)

DATA STRUCTURE LAB DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING CS09 407(P) DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING CS09 407(P) DATA STRUCTURE LAB LIST OF EXPERIMENTS SET-I 1. Implementation of Stack using Array 2. Implementation of Queue using Array 3. Implementation of

More information

INSERT AS A FIRST NODE

INSERT AS A FIRST NODE CIRCULAR LINKED LIST Insert as a first node Insert as a last node Delete first node Delete last node Insert after a node Insert before a node Search Traverse INSERT AS A FIRST NODE void insertf() struct

More information

Introduction to Data Structures. Systems Programming

Introduction 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 information

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0)

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0) CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-0-0) Class Teacher: Pralay Mitra Department of Computer Science and Engineering Indian Institute of Technology Kharagpur Conceptual Idea

More information

Linked List Practice Questions

Linked List Practice Questions Linked List Practice Questions 1. The following function reverse() is supposed to reverse a singly linked list. There is one line missing at the end of the function. /* head_ref is a double pointer which

More information

Frequently asked Data Structures Interview Questions

Frequently 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 information

DATA STRUCUTRES. A data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.

DATA STRUCUTRES. A data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently. DATA STRUCUTRES A data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently. An algorithm, which is a finite sequence of instructions, each of which

More information

//2D TRANSFORMATION TRANSLATION, ROTATING AND SCALING. #include<stdio.h> #include<conio.h> #include<graphics.h> #include<math.h> #include<stdlib.

//2D TRANSFORMATION TRANSLATION, ROTATING AND SCALING. #include<stdio.h> #include<conio.h> #include<graphics.h> #include<math.h> #include<stdlib. //2D TRANSFORMATION TRANSLATION, ROTATING AND SCALING #include #include #include #include #include void main() int gd=detect,gm,i,x[10],y[10],a,b,c,d,n,tx,ty,sx,sy,ch;

More information

DATA STRUCTURES LAB MANUAL USING C (CS,IT,MCA)

DATA STRUCTURES LAB MANUAL USING C (CS,IT,MCA) DATA STRUCTURES LAB MANUAL USING C (CS,IT,MCA) DATA STRUCTURES LAB LIST OF EXPERIMENTS 1) Write a program to perform the following in one dimensional array, Insertion, Deletion, and Searching (Linear and

More information

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #10

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #10 Department of Computer Science & Engineering Indian Institute of Technology Kharagpur Practice Sheet #10 Topic: Linked Lists Date: 01-03-2017 1. You are given a linked list. Your task is to create two

More information