POLYNOMIAL ADDITION. AIM:- To write a C program to represent a polynomial as a linked list and write functions for polynomial addition.

Size: px
Start display at page:

Download "POLYNOMIAL ADDITION. AIM:- To write a C program to represent a polynomial as a linked list and write functions for polynomial addition."

Transcription

1 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 for the two polynomials to be added. 3. Add the coefficients of the respective powers. 4. Display the added polynomial. 5. Terminate the program. PROGRAM:- #include <stdio.h> #include <conio.h> #include <stdlib.h> int ch,n,i; struct poly int coeff; int exp; struct poly *next; *poly1,*poly2,*poly3,*head1,*head2,*head3,*p,*q,*temp,*r; void input1(); void input2(); void add(); void display(); void main() clrscr(); head1=(struct poly*)malloc(sizeof(struct poly)); head1->next=null; head2=(struct poly*)malloc(sizeof(struct poly)); head2->next=null; head3=(struct poly*)malloc(sizeof(struct poly)); head3->next=null; while(1) printf("\n1.input for polynomial 1\n2.Input for polynomial 2\n3.Polynomial addition\n4.result\n5.exit\n"); printf("\n Enter the choice:");

2 scanf("%d",&ch); switch(ch) case 1: input1(); case 2: input2(); case 3: add(); case 4: display(); default: exit(0); void input1() printf("\nenter the number of terms in the polynomial:"); scanf("%d",&n); for(i=1;i<=n;i++) poly1=(struct poly*)malloc(sizeof(struct poly)); printf("\n Enter the term %d co-efficient:",i); scanf("%d",&poly1->coeff); printf("\n Enter the term %d power:",i); scanf("%d",&poly1->exp); if(head1->next==null) head1->next=poly1; poly1->next=null; p=head1->next; while(p->next!=null) p=p->next; p->next=poly1; poly1->next=null; void input2()

3 printf("\nenter the number of terms in the polynomial:"); scanf("%d",&n); for(i=1;i<=n;i++) poly2=(struct poly*)malloc(sizeof(struct poly)); printf("\n Enter the term %d co-efficient:",i); scanf("%d",&poly2->coeff); printf("\n Enter the term %d power:",i); scanf("%d",&poly2->exp); if(head2->next==null) head2->next=poly2; poly2->next=null; q=head2->next; while(q->next!=null) q=q->next; q->next=poly2; poly2->next=null; void add() p=head1->next; q=head2->next; while(p!=null && q!=null) poly3=(struct poly*)malloc(sizeof(struct poly)); if(p->exp==q->exp) poly3->exp=p->exp; poly3->coeff=p->coeff+q->coeff; p=p->next; q=q->next; if(p->exp>q->exp) poly3->coeff=p->coeff; poly3->exp=p->exp; p=p->next; poly3->coeff=q->coeff; poly3->exp=q->exp;

4 q=q->next; if(head3->next==null) head3->next=poly3; r=head3->next; while(r->next!=null) r=r->next; r->next=poly3; while(p!=null) poly3=(struct poly*)malloc(sizeof(struct poly)); poly3->coeff=p->coeff; poly3->exp=p->exp; p=p->next; if(head3->next==null) head3->next=poly3->next; r=head3->next; while(r->next!=null) r=r->next; r->next=poly3; while(q!=null) poly3=(struct poly*)malloc(sizeof(struct poly)); poly3->coeff=q->coeff; poly3->exp=q->exp; q=q->next; if(head3->next==null) head3->next=poly3->next;

5 r=head3->next; while(r->next!=null) r=r->next; r->next=poly3; void display() printf("\n The resultant polynomial\n"); if(head3->next==null) printf("\n No Terms\n"); temp=head3->next; while(temp!=null) printf("%d X^%d+",temp->coeff,temp->exp); temp=temp->next; getch(); OUTPUT:- RESULT:- Thus the given C program for adding two polynomials using linked list is executed and verified successfully.

6 CONVERT INFIX TO POSTFIX EXPRESSION AIM:- To write a C program to implement stack and use it to convert infix to postfix expression. ALGORITHM:- 1. Start the program 2. Scan the Infix string from left to right. 3. Initialise an empty stack. 4. If the scannned character is an operand, add it to the Postfix string. If the scanned character is an operator and if the stack is empty Push the character to stack. If the scanned character is an Operand and the stack is not empty, compare the precedence of the character with the element on top of the stack (topstack). If topstack has higher precedence over the scanned character Pop the stack Push the scanned character to stack. Repeat this step as long as stack is not empty and topstack has precedence over the character. Repeat this step till all the characters are scanned. 5. (After all characters are scanned, we have to add any character that the stack may have to the Postfix string.) If stack is not empty add topstack to Postfix string and Pop the stack. Repeat this step as long as stack is not empty. 6. Return the Postfix string. 7. Terminate the program. PROGRAM:- #include <stdio.h> #include<conio.h> #include<string.h> #include<stdlib.h> int size =50; char infix[50],postfix[50],stack[50]; int top=-1; int precedence(char ch); char pop();

7 char topelement(); void push(char ch); void main() char ele,elem,st[2]; int i,prep,pre,popped,j=0; clrscr(); strcpy(postfix," "); printf("\n\n Enter the infix\n"); gets(infix); for(i=0;infix[i]!='\0';i++) if(infix[i]!='('&&infix[i]!=')'&&infix[i]!='^'&&infix[i]!='*'&&infix[i]!='/'&&infix[i]!='+'&&infi x[i]!='-') postfix[j++]=infix[i]; if(infix[i]=='(') elem=infix[i]; push(elem); if(infix[i]==')') while((popped=pop())!='(') postfix[j++]=popped; elem=infix[i]; pre=precedence(elem); ele=topelement(); prep=precedence(ele); if(pre > prep) push(elem); while(prep >= pre) if(ele=='#') popped=pop(); ele=topelement(); postfix[j++]=popped;

8 prep=precedence(ele); push(elem); while((popped=pop())!='#') postfix[j++]=popped; postfix[j]='\0'; printf("\n post fix :%s",postfix); getch(); int precedence(char ch) switch(ch) case '^' : return 5; case '/' : return 4; case '*' : return 4; case '+' : return 3; case '-' : return 3; default : return 0; char pop() char ret; if(top!=-1) ret =stack[top]; top--; return ret; return '#'; char topelement() char ch; if(top!=-1) ch=stack[top]; ch='#'; return ch;

9 void push(char ch) if(top!=size-1) top++; stack[top]= ch; OUTPUT:- RESULT:- Thus the given C program for converting infix to postfix expression using stack is executed and verified successfully.

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

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

/*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<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 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

Application of Stack (Backtracking)

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

Linear Data Structure

Linear Data Structure Linear Data Structure Definition A data structure is said to be linear if its elements form a sequence or a linear list. Examples: Array Linked List Stacks Queues Operations on linear Data Structures Traversal

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

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

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

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

Stacks. CONTENTS 3.1 Introduction 1. Stack as an abstract data type 2. Representation of a Stack as an array 3.2Applications of Stack.

Stacks. CONTENTS 3.1 Introduction 1. Stack as an abstract data type 2. Representation of a Stack as an array 3.2Applications of Stack. Stacks CONTENTS 3.1 Introduction 1. Stack as an abstract data type 2. Representation of a Stack as an array 3.2Applications of Stack Hours: 12 Marks: 18 3.1 Introduction to Stacks 1. Stack as Abstract

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

Data Structure & Algorithms Laboratory Manual (CS 392)

Data 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

UNIT VI. STACKS AND QUEUES

UNIT VI. STACKS AND QUEUES UNIT VI. STACKS AND QUEUES Syllabus: /*-------------------------------------------------------------------------*/ Stack: Definition: "Stack is an ordered collection of data elements having similar data

More information

S.E. Sem. III [CMPN] Data Structures. Primitive Linear Non Linear

S.E. Sem. III [CMPN] Data Structures. Primitive Linear Non Linear S.E. Sem. III [CMPN] Data Structures Time : 3 Hrs.] Prelim Paper Solution [Marks : 80 Q.1(a) Explain different types of data structures with examples. [5] Ans.: Types of Data Structure : Data Structures

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

Government Girls Polytechnic, Bilaspur

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

CS Data Structure Spring Answer Key- Assignment #3

CS Data Structure Spring Answer Key- Assignment #3 CS300-201 Data Structure Spring 2012 2013 Answer Key- Assignment #3 Due Sunday, Mar 3 rd. Q1): Find Big-O for binary search algorithm, show your steps. Solution 1- The task is to search for a given value

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

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

Infix to Postfix Conversion

Infix to Postfix Conversion Infix to Postfix Conversion Infix to Postfix Conversion Stacks are widely used in the design and implementation of compilers. For example, they are used to convert arithmetic expressions from infix notation

More information

UNIT 2: STACK & RECURSION Programs demonstrated in class. Tojo Mathew Asst. Professor CSE Dept., NIE Mysuru.

UNIT 2: STACK & RECURSION Programs demonstrated in class. Tojo Mathew Asst. Professor CSE Dept., NIE Mysuru. UNIT 2: STACK & RECURSION Programs demonstrated in class. Tojo Mathew Asst. Professor CSE Dept., NIE Mysuru. Table of Contents 1. C Program to Check for balanced parenthesis by using Stacks...3 2. Program

More information

Q 1. Attempt any TEN of the following:

Q 1. Attempt any TEN of the following: Subject Code: 17212 Model Answer Page No: 1 / 26 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

More information

Data Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1

Data Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1 Data Structure using C++ Lecture 04 Reading Material Data Structures and algorithm analysis in C++ Chapter. 3 3.1, 3.2, 3.2.1 Summary Stack Operations on a stack Representing stacks Converting an expression

More information

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

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

Keywords queue, left sub list, right sub list, output array list, output linked list, input array list, divide list, sort, combine

Keywords queue, left sub list, right sub list, output array list, output linked list, input array list, divide list, sort, combine Volume 4, Issue 12, December 2014 ISSN: 2277 128X International Journal of Advanced Research in Computer Science and Software Engineering Research Paper Available online at: www.ijarcsse.com Divide and

More information

Write a C program to add two Complex numbers using functions illustrating-

Write a C program to add two Complex numbers using functions illustrating- Scheme of valuvation Date : 29/8/2017 Marks: 40 Subject & Code : Data Structures and Applications (15CS33) Class : III A&B Name of Faculty : Ms. Saritha Time : 8:30 am to 10 am NOTE: ANSWER All FIVE QUESTIONS

More information

Model Solution for QP CODE : ( 3 Hours )

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

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

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

Dynamic Memory Allocation

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

Binary Search Tree Binary Search tree is a binary tree in which each internal node x stores an element such that the element stored in the left subtree of x are less than or equal to x and elements stored

More information

TERM PAPER ON HOSPITAL MANAGEMENT SYSTEM

TERM PAPER ON HOSPITAL MANAGEMENT SYSTEM TERM PAPER ON HOSPITAL MANAGEMENT SYSTEM Acknowledgment This project is a welcome and challenging experience for us as it took a great deal of hard work and dedication for its successful completion. It

More information

NCS 301 DATA STRUCTURE USING C

NCS 301 DATA STRUCTURE USING C NCS Data Structure Using C -8- NCS DATA STRUCTURE USING C Unit- Part- Stack Hammad Mashkoor Lari Assistant Professor Allenhouse Institute of Technology www.ncsds.wordpress.com Introduction Stack is a non

More information

Data Structures & Algorithm Analysis. Lecturer: Souad Alonazi

Data Structures & Algorithm Analysis. Lecturer: Souad Alonazi Data Structures & Algorithm Analysis Lec(3) Stacks Lecturer: Souad Alonazi What is a stack? Stores a set of elements in a particular order Stack principle: LAST IN FIRST OUT = LIFO It means: the last element

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

S.E. Sem. III [INFT] Data Structures & Analysis. Primitive Linear Non Linear

S.E. Sem. III [INFT] Data Structures & Analysis. Primitive Linear Non Linear S.E. Sem. III [INFT] Data Structures & Analysis Time : 3 Hrs.] Prelim Paper Solution [Marks : 80 Q.1(a) Explain different types of data structures with examples. [5] Ans.: Types of Data Structure : Data

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

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

Data Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1

Data Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1 Data Structure using C++ Lecture 04 Reading Material Data Structures and algorithm analysis in C++ Chapter. 3 3.1, 3.2, 3.2.1 Summary Infix to Postfix Example 1: Infix to Postfix Example 2: Postfix Evaluation

More information

BSc.(Hons.) Business Information Systems, BSc. (Hons.) Computer Science with Network Security, BSc.(Hons.) Software Engineering

BSc.(Hons.) Business Information Systems, BSc. (Hons.) Computer Science with Network Security, BSc.(Hons.) Software Engineering BSc.(Hons.) Business Information Systems, BSc. (Hons.) Computer Science with Network Security, BSc.(Hons.) Software Engineering Cohorts BIS/04 Full Time - BCNS/04 Full Time SE/04 Full Time Examinations

More information

Computers Programming Course 12. Iulian Năstac

Computers Programming Course 12. Iulian Năstac Computers Programming Course 12 Iulian Năstac Recap from previous course Strings in C The character string is one of the most widely used applications that involves vectors. A string in C is an array of

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

Lecture Data Structure Stack

Lecture Data Structure Stack Lecture Data Structure Stack 1.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

Guide for The C Programming Language Chapter 5

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

Associate Professor Dr. Raed Ibraheem Hamed

Associate Professor Dr. Raed Ibraheem Hamed Associate Professor Dr. Raed Ibraheem Hamed University of Human Development, College of Science and Technology Computer Science Department 2015 2016 1 What this Lecture is about: Stack Structure Stack

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

List of Programs: Programs: 1. Polynomial addition

List of Programs: Programs: 1. Polynomial addition List of Programs: 1. Polynomial addition 2. Common operations on vectors in c 3. Matrix operation: multiplication, transpose 4. Basic Unit conversion 5. Number conversion: Decimal to binary 6. Number conversion:

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

DATA STRUCTURES LABORATORY

DATA STRUCTURES LABORATORY DATA STRUCTURES LABORATORY [As per Choice Based Credit System (CBCS) scheme] (Effective from the academic year 2015-2016) SEMESTER III Laboratory Code 15CSL38 IA Marks 20 Number of Lecture Hours/Week 01I

More information

The program simply pushes all of the characters of the string into the stack. Then it pops and display until the stack is empty.

The program simply pushes all of the characters of the string into the stack. Then it pops and display until the stack is empty. EENG212 Algorithms & Data Structures Fall 0/07 Lecture Notes # Outline Stacks Application of Stacks Reversing a String Palindrome Example Infix, Postfix and Prefix Notations APPLICATION OF STACKS Stacks

More information

Vivekananda College of Engineering & Technology. Data Structures and Applications

Vivekananda College of Engineering & Technology. Data Structures and Applications 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 information

Stack. 4. In Stack all Operations such as Insertion and Deletion are permitted at only one end. Size of the Stack 6. Maximum Value of Stack Top 5

Stack. 4. In Stack all Operations such as Insertion and Deletion are permitted at only one end. Size of the Stack 6. Maximum Value of Stack Top 5 What is Stack? Stack 1. Stack is LIFO Structure [ Last in First Out ] 2. Stack is Ordered List of Elements of Same Type. 3. Stack is Linear List 4. In Stack all Operations such as Insertion and Deletion

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 Structure (MCA) Nitasha Jain Assistant Professor Department of IT Biyani Girls College, Jaipur

Data Structure (MCA) Nitasha Jain Assistant Professor Department of IT Biyani Girls College, Jaipur Biyani's Think Tank Concept based notes Data Structure (MCA) Nitasha Jain Assistant Professor Department of IT Biyani Girls College, Jaipur 2 Published by : Think Tanks Biyani Group of Colleges Concept

More information

Stacks. Chapter 5. Copyright 2012 by Pearson Education, Inc. All rights reserved

Stacks. Chapter 5. Copyright 2012 by Pearson Education, Inc. All rights reserved Stacks Chapter 5 Contents Specifications of the ADT Stack Using a Stack to Process Algebraic Expressions A Problem Solved: Checking for Balanced Delimiters in an Infix Algebraic Expression A Problem Solved:

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 Applications. Lecture 27 Sections Robb T. Koether. Hampden-Sydney College. Wed, Mar 29, 2017

Stack Applications. Lecture 27 Sections Robb T. Koether. Hampden-Sydney College. Wed, Mar 29, 2017 Stack Applications Lecture 27 Sections 18.7-18.8 Robb T. Koether Hampden-Sydney College Wed, Mar 29, 2017 Robb T. Koether Hampden-Sydney College) Stack Applications Wed, Mar 29, 2017 1 / 27 1 Function

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 Week #3. Stacks

Data Structures Week #3. Stacks Data Structures Week #3 Stacks Outline Stacks Operations on Stacks Array Implementation of Stacks Linked List Implementation of Stacks Stack Applications October 5, 2015 Borahan Tümer, Ph.D. 2 Stacks (Yığınlar)

More information

LAB MANUAL CS6212- PROGRAMMING AND DATA STRUCTURES LABORATORY I. Dharmapuri Regulation : 2013 Branch : B.E. CSE

LAB MANUAL CS6212- PROGRAMMING AND DATA STRUCTURES LABORATORY I. Dharmapuri Regulation : 2013 Branch : B.E. CSE Dharmapuri 636 703 LAB MANUAL Regulation : 2013 Branch Year & Semester : B.E. CSE : I Year / II Semester CS6212- PROGRAMMING AND DATA STRUCTURES LABORATORY I ANNA UNIVERSITY CHENNAI REGULATION-2013 CS6212

More information

DHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING EC6301 OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES

DHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING EC6301 OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES DHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING EC6301 OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES UNIT III LINEAR DATA STRUCTURES PART A 1. What is meant by data

More information

1. Simple if statement. 2. if else statement. 3. Nested if else statement. 4. else if ladder 1. Simple if statement

1. Simple if statement. 2. if else statement. 3. Nested if else statement. 4. else if ladder 1. Simple if statement UNIT- II: Control Flow: Statements and Blocks, if, switch statements, Loops: while, do-while, for, break and continue, go to and Labels. Arrays and Strings: Introduction, One- dimensional arrays, Declaring

More information

INTRODUCTION TO DATA STRUCTURES

INTRODUCTION TO DATA STRUCTURES INTRODUCTION TO DATA STRUCTURES Data Structure is defined as the way in which data is organized in the memory location. There are 2 types of data structures: Linear Data Structure: In linear data structure

More information

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

It is necessary to have a single function main in every C program, along with other functions used/defined by the programmer.

It is necessary to have a single function main in every C program, along with other functions used/defined by the programmer. Functions A number of statements grouped into a single logical unit are called a function. The use of function makes programming easier since repeated statements can be grouped into functions. Splitting

More information

Some Applications of Stack. Spring Semester 2007 Programming and Data Structure 1

Some Applications of Stack. Spring Semester 2007 Programming and Data Structure 1 Some Applications of Stack Spring Semester 2007 Programming and Data Structure 1 Arithmetic Expressions Polish Notation Spring Semester 2007 Programming and Data Structure 2 What is Polish Notation? Conventionally,

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

DATA STRUCTURES LABORATORY

DATA STRUCTURES LABORATORY DATA STRUCTURES LABORATORY [As per Choice Based Credit System (CBCS) scheme] (Effective from the academic year 2017-2018) SEMESTER - III Laboratory Code 15CSL38 IA Marks 20 Number of Lecture Hours/Week

More information

DATA STRUCTURES LAB MANUAL

DATA STRUCTURES LAB MANUAL DATA STRUCTURES LAB MANUAL Year : 2016-2017 Course Code : ACS102 Regulations : R16 Semester : I B.Tech II Semester Branch : CSE / IT Prepared by Ms. N. JAYANTHI ASSOCIATE PROFESSOR INSTITUTE OF AERONAUTICAL

More information

CS 171: Introduction to Computer Science II. Stacks. Li Xiong

CS 171: Introduction to Computer Science II. Stacks. Li Xiong CS 171: Introduction to Computer Science II Stacks Li Xiong Today Stacks operations and implementations Applications using stacks Application 1: Reverse a list of integers Application 2: Delimiter matching

More information

March 13/2003 Jayakanth Srinivasan,

March 13/2003 Jayakanth Srinivasan, Statement Effort MergeSort(A, lower_bound, upper_bound) begin T(n) if (lower_bound < upper_bound) Θ(1) mid = (lower_bound + upper_bound)/ 2 Θ(1) MergeSort(A, lower_bound, mid) T(n/2) MergeSort(A, mid+1,

More information

Data Structure. Chapter 3 Stacks and Queues. Department of Communication Engineering National Central University Jhongli, Taiwan.

Data Structure. Chapter 3 Stacks and Queues. Department of Communication Engineering National Central University Jhongli, Taiwan. Data Structure Chapter 3 Stacks and Queues Instructor: Angela Chih-Wei Tang Department of Communication Engineering National Central University Jhongli, Taiwan 29 Spring Outline Stack Queue A Mazing Problem

More information

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

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) Subject Code: 17212 Model Answer Page No: 1/28 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

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

DS Assignment II. Full Sized Image

DS Assignment II. Full Sized Image DS Assignment II 1. A) For the Towers of Hanoi problem, show the call tree during the recursive call Towers(3, A, C, B). In the tree, label the root node as Towers (3, A, C, B) while marking all the intermediate

More information

PES INSTITUTE OF TECHNOLOGY-BSC SESSION: JULY 2018 DECEMBER 2018

PES INSTITUTE OF TECHNOLOGY-BSC SESSION: JULY 2018 DECEMBER 2018 PES INSTITUTE OF TECHNOLOGY-BSC 1Km before Electronic City, Hosur Road, Bangalore-560100. DEPARTMENT OF INFORMATION SCIENCE AND ENGINEERING DATA STRUCTURES WITH C LABORATORY LAB MANUAL [As per Choice Based

More information

Bangalore South Campus

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

Case Control Structure. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan

Case Control Structure. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan Case Control Structure DCS COMSATS Institute of Information Technology Rab Nawaz Jadoon Assistant Professor COMSATS IIT, Abbottabad Pakistan Introduction to Computer Programming (ICP) Decision control

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

DATA STRUCTURES USING C

DATA STRUCTURES USING C DATA STRUCTURES USING C DATA STRUCTURES USING C LECTURE NOTES Prepared by Dr. Subasish Mohapatra Department of Computer Science and Application College of Engineering and Technology, Bhubaneswar Biju Patnaik

More information

Data Structures and Algorithms

Data Structures and Algorithms Data Structures and Algorithms Prof. Ajit A. Diwan Prof. Ganesh Ramakrishnan Prof. Deepak B. Phatak Department of Computer Science and Engineering Session: Infix to Postfix (Program) Ajit A. Diwan, Ganesh

More information

Stack and Its Implementation

Stack and Its Implementation Stack and Its Implementation Tessema M. Mengistu Department of Computer Science Southern Illinois University Carbondale tessema.mengistu@siu.edu Room - 3131 1 Definition of Stack Usage of Stack Outline

More information

Programming for Engineers Pointers

Programming for Engineers Pointers Programming for Engineers Pointers ICEN 200 Spring 2018 Prof. Dola Saha 1 Pointers Pointers are variables whose values are memory addresses. A variable name directly references a value, and a pointer indirectly

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

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

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

#06 More Structures LIFO FIFO. Contents. Queue vs. Stack 3. Stack Operations. Pop. Push. Stack Queue Hash table

#06 More Structures LIFO FIFO. Contents. Queue vs. Stack 3. Stack Operations. Pop. Push. Stack Queue Hash table Contents #06 More Structures -07 FUNDAMENTAL PROGRAMMING I Stack Queue Hash table DEPARTMENT OF COMPUTER ENGINEERING, PSU v. Queue vs. Stack Stack Operations IN IN OUT Push: add an item to the top Pop:

More information

CS 206 Introduction to Computer Science II

CS 206 Introduction to Computer Science II CS 206 Introduction to Computer Science II 03 / 31 / 2017 Instructor: Michael Eckmann Today s Topics Questions? Comments? finish RadixSort implementation some applications of stack Priority Queues Michael

More information

PROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE

PROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE PROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE 1. Write a C program to perform addition, subtraction, multiplication and division of two numbers. # include # include int a, b,sum,

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 the model answer scheme. 2) The model answer and the answer written by candidate

More information

SRI CHANDRASEKHARENDRA SARASWATHI VISWA MAHAVIDYALAYA (UNIVERSITY ESTABLISHED UNDER SECTION 3 OF UGC ACT 1956) ENATHUR - KANCHIPURAM

SRI CHANDRASEKHARENDRA SARASWATHI VISWA MAHAVIDYALAYA (UNIVERSITY ESTABLISHED UNDER SECTION 3 OF UGC ACT 1956) ENATHUR - KANCHIPURAM SRI CHANDRASEKHARENDRA SARASWATHI VISWA MAHAVIDYALAYA (UNIVERSITY ESTABLISHED UNDER SECTION 3 OF UGC ACT 1956) ENATHUR - KANCHIPURAM 631 561 DATA STRUCTURES LAB LABORATORY RECORD Name : Register. No :

More information

STACKS AND QUEUES. Problem Solving with Computers-II

STACKS AND QUEUES. Problem Solving with Computers-II STACKS AND QUEUES Problem Solving with Computers-II 2 Stacks container class available in the C++ STL Container class that uses the Last In First Out (LIFO) principle Methods i. push() ii. iii. iv. pop()

More information

CS Data Structure Spring Answer Key- Assignment #4

CS Data Structure Spring Answer Key- Assignment #4 CS300-201 Data Structure Spring 2012 2013 Answer Key- Assignment #4 Due Sunday, Mar 3 rd. Q1): Write a program to convert an infix expression that includes (, ), +, -, *, /, and ^ exponentiation operator

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

STACKS. A stack is defined in terms of its behavior. The common operations associated with a stack are as follows:

STACKS. A stack is defined in terms of its behavior. The common operations associated with a stack are as follows: STACKS A stack is a linear data structure for collection of items, with the restriction that items can be added one at a time and can only be removed in the reverse order in which they were added. The

More information

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours TED (10)-3071 Reg. No.. (REVISION-2010) (Maximum marks: 100) Signature. FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours PART

More information

Computers Programming Course 7. Iulian Năstac

Computers Programming Course 7. Iulian Năstac Computers Programming Course 7 Iulian Năstac Recap from previous course Operators in C Programming languages typically support a set of operators, which differ in the calling of syntax and/or the argument

More information