/*Addition of two polynomials*/ #include<stdio.h> #include<malloc.h> #include<conio.h> struct link { int coeff; int pow; struct link *next; }; struct
|
|
- Herbert Fisher
- 5 years ago
- Views:
Transcription
1 /*Addition of two polynomials*/ #include<stdio.h> #include<malloc.h> #include<conio.h> struct link int coeff; int pow; struct link *next; ; struct link *poly1=null,*poly2=null,*poly=null; void create(struct link *node) char ch; do printf("\nenter the coefficient :"); scanf("%d",&node->coeff); printf("\nenter the power :"); scanf("%d",&node->pow); node->next=(struct link *)malloc(sizeof(struct link)); node=node->next; node->next=null; printf("\ncontinue??? (Y/N) :"); ch=getch(); while(ch=='y' ch=='y'); void display(struct link *node) while(node->next!=null) printf("%dx^%d",node->coeff,node->pow); node=node->next; if(node->next!=null) printf(" + "); void polyadd(struct link *poly1,struct link *poly2,struct link *poly) while(poly1->next && poly2->next) if(poly->pow > poly2->pow) poly->pow=poly1->pow; poly->coeff=poly1->coeff; poly1=poly1->next; if(poly1->pow < poly2->pow) poly->pow=poly2->pow; poly->coeff=poly2->coeff; poly2=poly2->next;
2 poly->pow=poly1->pow; poly->coeff=poly1->coeff+poly2->coeff; poly1=poly1->next; poly2=poly2->next; poly->next=(struct link *)malloc(sizeof(struct link)); poly=poly->next; poly->next=null; while(poly1->next poly2->next) if(poly1->next) poly->pow=poly1->pow; poly->coeff=poly1->coeff; poly1=poly1->next; if(poly2->next) poly->pow=poly2->pow; poly->coeff=poly2->coeff; poly2=poly2->next; poly->next=(struct link *)malloc(sizeof(struct link)); poly=poly->next; poly->next=null; void main() poly1=(struct link *)malloc(sizeof(struct link)); poly2=(struct link *)malloc(sizeof(struct link)); poly=(struct link *)malloc(sizeof(struct link)); clrscr(); printf("\nenter the first polynomial::"); create(poly1); printf("\nfirst polynomial is :: \n"); display(poly1); printf("\nenter the second polynomial::"); create(poly2); printf("\nsecond polynomial is :: \n"); display(poly2); polyadd(poly1,poly2,poly); printf("\naddition of the two polynomials::"); display(poly); getch();
3 /**Stack operations**/ #include<stdio.h> #include<conio.h> #include<stdlib.h> #define size 5 struct stack int s[size]; int top; st; int stfull() if(st.top>=size-1) return 1; return 0; void push (int item) st.top++; st.s[st.top]=item; int stempty() if(st.top==-1) return 1; return 0; int pop() int item; item=st.s[st.top]; st.top--; return(item); void display() int i; if(stempty()) printf("\stack is Empty"); for(i=st.top;i>=0;i--) printf("\n%d",st.s[i]); void main(void) int item,choice; char ans; st.top=-1;
4 clrscr(); printf("\n\t\t Implementation of stack"); do printf("\n1.push\n2.pop\n3.display\n4.e\xit"); printf("\nenter your choice"); scanf("%d",&choice); switch(choice) case 1:printf("\n enter teh item to be pushed"); scanf("%d",&item); if(stfull()) printf("\n stack is full"); push(item); case 2:if(stempty()) printf("\n empty stack"); item=pop(); printf("\n the popped element is %d",item); case 3:display(); case 4:exit(0); printf("\n do you want to continue"); ans=getche(); while(ans=='y' ans=='y'); getch();
5 /**Conversion of Infix expression to Postfix form**/ #include<stdio.h> #include<conio.h> #include<alloc.h> char inf[40],post[40]; int top=0,st[20]; void postfix(); void push(int); char pop(); void main(void) clrscr(); printf("\n\tenter the infix expression :: \n\n\t\t"); scanf("%s",inf); postfix(); getch(); void postfix() int i,j=0; for(i=0;inf[i]!='\0';i++) switch(inf[i]) case '+' : while(st[top] >= 1) push(1); case '-' : while(st[top] >= 1) push(2); case '*' : while(st[top] >= 3) push(3); case '/' : while(st[top] >= 3) push(4); case '^' : while(st[top] >= 4) push(5); case '(' : push(0); case ')' : while(st[top]!= 0) top--; default : post[j++] = inf[i];
6 while(top>0) printf("\n\tpostfix expresion is =>\n\n\t\t %s",post); void push(int ele) top++; st[top] = ele; char pop() int el; char e; el = st[top]; top--; switch(el) case 1 : e = '+'; case 2 : e = '-'; case 3 : e = '*'; case 4 : e = '/'; case 5 : e = '^'; return(e);
7 /** Evaluation of postfix expression**/ #include<stdio.h> #include<conio.h> #include<ctype.h> #include<string.h> #define maxsize 10 struct stackarray int top; int operand[maxsize]; stack; void push(int oprd) stack.top++; stack.operand[stack.top]=oprd; int pop() int tmp; tmp=stack.operand[stack.top]; stack.top--; return(tmp); void main() int len,i,op1,op2,result; char exp[20]; stack.top=-1; clrscr(); printf("\nenter postfix expresion :"); scanf("%s",&exp); len=strlen(exp); for(i=0;i<len;i++) if(isdigit(exp[i])) push(exp[i]-'0'); op1=pop(); op2=pop(); switch(exp[i]) case'+': result=op1+op2; case '-': result=op1-op2; case '*': result=op1*op2;
8 case '/': result=op1/op2; push(result); printf("\nthe result of given expresion is%d",result); getch();
9 /**Queue**/ #include<stdio.h> #include<conio.h> #include<stdlib.h> #define size 5 struct queue int que[size]; int front,rear; Q; Qfull() if(q.rear>=size-1) return 1; return 0; int insert(int item) if(q.front==-1) Q.front++; Q.que[++Q.rear]=item; return Q.rear; int Qempty() if(q.front==-1 (Q.front>Q.rear)) return 1; return 0; int delete() int item; item=q.que[q.front]; Q.front++; printf("\n The deleted item is %d",item); return Q.front; void display() int i; for(i=q.front;i<=q.rear;i++) printf(" %d",q.que[i]); void main(void) int choice,item; char ans; clrscr(); Q.front=-1;
10 Q.rear=-1; do printf("\n Main menu"); printf("\n 1.Insert\n 2.Delete\n 3.Display"); printf("\n Enter your choice"); scanf("%d",&choice); switch(choice) case 1:if(Qfull()) printf("\n can not insert the element"); printf("\n Enter the element"); scanf("%d",&item); insert(item); case 2:if(Qempty()) printf("\n Queue underflow"); delete(); case 3:if(Qempty()) printf("\n queue is empty"); display(); default:printf("\n wrong choice"); printf("\n do u want continue"); ans=getche(); while(ans=='y' ans=='y');
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 informationUNIT VI. STACKS AND QUEUES
UNIT VI. STACKS AND QUEUES Syllabus: /*-------------------------------------------------------------------------*/ Stack: Definition: "Stack is an ordered collection of data elements having similar data
More informationAIM:- To write a C program to create a singly linked list implementation.
SINGLY LINKED LIST AIM:- To write a C program to create a singly linked list implementation. ALGORITHM:- 1. Start the program. 2. Get the choice from the user. 3. If the choice is to add records, get the
More informationApplication of Stack (Backtracking)
Application of Stack (Backtracking) Think of a labyrinth or maze How do you find a way from an entrance to an exit? Once you reach a dead end, you must backtrack. But backtrack to where? to the previous
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) WINTER 16 EXAMINATION Model Answer Subject Code:
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate
More informationModel Solution for QP CODE : ( 3 Hours )
Model Solution for QP CODE : 24788 ( 3 Hours ) All answers are for reference only. Any alternate answer that solves the problem should be considered eqully valid. 1. (a) Define data structure? Give its
More information/* Polynomial Expressions Using Linked List*/ #include<stdio.h> #include<conio.h> #include <malloc.h> struct node. int num; int coeff;
/* Polynomial Expressions Using Linked List*/ #include #include #include struct node int num; int coeff; struct node *next; ; struct node *start1 = NULL; struct node *start2
More informationSTACKS 3.1 INTRODUCTION 3.2 DEFINITION
STACKS 3 3.1 INTRODUCTION A stack is a linear data structure. It is very useful in many applications of computer science. It is a list in which all insertions and deletions are made at one end, called
More informationWrite 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 informationUNIT 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 informationSolution for Data Structure
Solution for Data Structure May 2016 INDEX Q1 a 2-3 b 4 c. 4-6 d 7 Q2- a 8-12 b 12-14 Q3 a 15-18 b 18-22 Q4- a 22-35 B..N.A Q5 a 36-38 b N.A Q6- a 39-42 b 43 1 www.brainheaters.in Q1) Ans: (a) Define ADT
More informationDS Lab Manual -17CS33
Chethan Raj C Assistant Professor Dept. of CSE 6. Design, Develop and Implement a menu driven Program in C for the following operations on Circular QUEUE of Characters (Array Implementation of Queue with
More informationNCS 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 informationBachelor of Engineering First Year II SEMESTER CS6212 PROGRAMMING AND DATA STRUCTURES LABORATORY I LAB MANUAL DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Page 1 CS6212 PROGRAMMING AND DATA STRUCTURES
More informationUnit-2. Stacks: Introduction-Definition-Representation of Stack-Operations on Stacks- Applications of Stacks.
Unit-2 Stacks: Introduction-Definition-Representation of Stack-Operations on Stacks- Applications of Stacks. Queues: Introduction, Definition- Representations of Queues- Various Queue Structures- Applications
More informationPrepared By:- Dinesh Sharma Asstt. Professor, CSE & IT Deptt. ITM Gurgaon
Data Structures &Al Algorithms Prepared By:- Dinesh Sharma Asstt. Professor, CSE & IT Deptt. ITM Gurgaon What is Data Structure Data Structure is a logical relationship existing between individual elements
More informationCase 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 informationDATA 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 informationS.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 informationStacks. 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 informationGovernment Girls Polytechnic, Bilaspur
Government Girls Polytechnic, Bilaspur Name of the Lab: Programming Lab Practical: Data Structure Lab Class: 4 th Semester (Computer Science & Engineering) Teachers Assessment: 30 End Semester Examination:70
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
WINTER 18 EXAMINATION Subject Name: Data Structure using C Model wer Subject Code: 22317 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given
More informationClass / Sem: I CSE / II Semester Subject Code: CS 6202 Subject: Programming and Data Structures I Prepared by T. Vithya Unit IV - LINEAR DATA STRUCTURES STACKS AND QUEUES Stack ADT Evaluating arithmetic
More informationThe 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 informationDarshan Institute of Engineering & Technology for Diploma Studies Unit 3
Linear and Non-Linear Data Structures Linear data structure: Linear data structures are those data structure in which data items are arranged in a linear sequence by physically or logically or both the
More informationPESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Computer Science and Engineering
USN 1 P E PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Computer Science and Engineering SOLUTION FOR INTERNAL ASSESSMENT TEST 2 Date : 6/10/2017 Marks:
More informationDATA 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 informationSingle linked list. Program: #include<stdio.h> #include<conio.h> #include<alloc.h> struct node. int info; struct node *next; void main()
Single linked list Program: #include #include #include struct node int info; struct node *next; ; void main() struct node *s,*start,*prev,*new1,*temp,*temp1,*ptemp; int cho,i,j,x,n,p;
More informationBE ISE 3 rd Semester
Scheme of valuvation 1 What is a Binary tree? State its properties? How it is represented using array and linked list, give example. binary tree is a tree data structure in which each node has at most
More informationThe Queues. Front. Rear. Front. Rear. Rear = 0 Front = 0. Fig Queue is empty. Fig push(10) Rear = 1 Front = 0. Fig. 4.3.
4 The Queues A queue is logically a first in first out (FIFO or first come first serve) linear data structure. The concept of queue can be understood by our real life problems. For example a customer come
More informationLinked List in Data Structure. By Prof. B J Gorad, BECSE, M.Tech CST, PHD(CSE)* Assistant Professor, CSE, SITCOE, Ichalkaranji,Kolhapur, Maharashtra
Linked List in Data Structure By Prof. B J Gorad, BECSE, M.Tech CST, PHD(CSE)* Assistant Professor, CSE, SITCOE, Ichalkaranji,Kolhapur, Maharashtra Linked List Like arrays, Linked List is a linear data
More informationCS11001/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 informationFrequently asked Data Structures Interview Questions
Frequently asked Data Structures Interview Questions Queues Data Structure Interview Questions How is queue different from a stack? The difference between stacks and queues is in removing. In a stack we
More informationUNIT 3: QUEUE Programs demonstrated in class. Tojo Mathew Asst. Professor CSE Dept., NIE Mysuru.
UNIT 3: QUEUE Programs demonstrated in class. Tojo Mathew Asst. Professor CSE Dept., NIE Mysuru. Table of Contents 1. Simple Queue Implementation with arrays...3 2. Circular queue with global container
More informationAshish Gupta, Data JUET, Guna
Categories of data structures Data structures are categories in two classes 1. Linear data structure: - organized into sequential fashion - elements are attached one after another - easy to implement because
More informationS.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 informationUNIT-2 Stack & Queue
UNIT-2 Stack & Queue 59 13. Stack A stack is an Abstract Data Type (ADT), commonly used in most programming languages. It is named stack as it behaves like a real-world stack, for example a deck of cards
More informationGuide for The C Programming Language Chapter 5
1. Differentiate between primitive data type and non-primitive data type. Primitive data types are the basic data types. These data types are used to represent single values. For example: Character, Integer,
More informationMAHARASHTRASTATE 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 informationLinear 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 informationVivekananda 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 informationDATA 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 informationData 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 informationDC54 DATA STRUCTURES JUNE 2013
Q 2 (a) Define storage class and its functions. Explain in detail scope, storage allocation and purpose of each storage class. 'Storage' refers to the scope of a variable and memory allocated by compiler
More informationSINGLE LINKED LIST. Algorithm for allocating memory for the new node
SRI CHANDRASEKHARENDRA SARASWATHI VISWA MAHAVIDYALAYA SCSVMV UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Faculty: S.Gokulakrishnan AP/CSE SINGLE LINKED LIST Aim:- Write a C program to implement
More informationCS6202 - 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/*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 informationModule III. Linear Data Structures and their Linked Storage Representation
Module III Linear Data Structures and their Linked Storage Representation 3.1 Linked List Linked list is the collection of inter connected nodes with a head node representing the first node and a tail
More informationDiscussion of project # 1 permutations
Discussion of project # 1 permutations Algorithm and examples. The main function for generating permutations is buildp. We don t need a separate class for permutations since the permutations objects are
More informationSree 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 informationCOMP 433 THEORY OF COMPILERS
KINDGOM OF SAUDI ARABIA MINISTRY OF HINGER EDUCATION :: JAZAN UNIVERSITY COLLEGE OF COMPUTER SCIENCE & INFORMATION SYSTEMS DEPARTMENT OF COMPUTER SCIENCE L A B M A N U A L COMP 433 THEORY OF COMPILERS
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in themodel answer scheme. 2) The model answer and the answer written by candidate may
More informationAbstract Data Types (ADTs) Source:
Source: www.csitportal.com Prerequisites: Knowledge of C Note:- The complete C programs involved in this note are not study in detailed for the point of exam view these are only for practical purpose.
More informationDHANALAKSHMI 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 informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
WINTER 17 EXAMINATION Subject Name: Data Structure Using C Model Answer Subject Code: 17330 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as
More informationData 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 informationDuration: 110 minutes
EASTERN MEDITERRANEAN UNIVERSITY Computer Engineering Department CMPE-231 DATA STRUCTURES FINAL EXAMINATION 13 June 2014 Duration: 110 minutes Name, Surname. SOLUTION KEY......... Student ID #..........
More informationVtusolution.in DATA STRUCTURES WITH C. (Common to CSE & ISE) Subject Code: 10CS35 I.A. Marks : 25. Hours/Week : 04 Exam Hours: 03
DATA STRUCTURES WITH C (Common to CSE & ISE) Subject Code: I.A. Marks : 25 Hours/Week : 04 Exam Hours: 03 Total Hours : 52 Exam Marks: 100 UNIT - 1 PART A 8 Hours BASIC CONCEPTS: Pointers and Dynamic Memory
More informationStack. Data structure with Last-In First-Out (LIFO) behavior. Out
Stack and Queue 1 Stack Data structure with Last-In First-Out (LIFO) behavior In Out C B A B C 2 Typical Operations Pop on Stack Push isempty: determines if the stack has no elements isfull: determines
More informationLecture 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 informationData 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 informationProblem # 1. calculate the grade. Allow a student the next grade if he/she needs only 0.5 marks to obtain the next grade. Use else-if construction.
ME 172 Lecture 6 Problem # 1 Write a program to calculate the grade point average of a 3.00 credit hour course using the data obtained from the user. Data contains four items: attendance (30), class test
More informationWhat is recursion. WAP to find sum of n natural numbers using recursion (5)
DEC 2014 Q1 a What is recursion. WAP to find sum of n natural numbers using recursion (5) Recursion is a phenomenon in which a function calls itself. A function which calls itself is called recursive function.
More informationDarshan Institute of Engineering & Technology for Diploma Studies Unit 1
Darshan Institute of Engineering & Technology for Diploma Studies Unit 1 Introduction Computer is an electronic machine which is used for data processing and manipulation. In order to make computer work
More informationData 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 informationTPCT s College of Engineering, Osmanabad. Laboratory Manual DATA STRUCTURE USING C. For. Second Year Students. Manual Prepared by. Mr. T.K.
TPCT s College of Engineering, Osmanabad Laboratory Manual DATA STRUCTURE USING C For Second Year Students Manual Prepared by Mr. T.K.Takbhate Author COE, Osmanabad TPCT s College of Engineering Solapur
More informationDynamic Memory Allocation
Dynamic Memory Allocation The process of allocating memory at run time is known as dynamic memory allocation. C does not Inherently have this facility, there are four library routines known as memory management
More informationMODULE V: POINTERS & PREPROCESSORS
MODULE V: POINTERS & PREPROCESSORS INTRODUCTION As you know, every variable is a memory-location and every memory-location has its address defined which can be accessed using ampersand(&) operator, which
More informationDATA 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 informationINDEX BUBBLE SORT INSERTION SORT SELECTION SORT PATTREN MATCHING LINEAR SEARCH BINARY SEARCH QUICK SORT MERGE SORT STACK OPERATION USING ARRAY
INDEX S.No. Date Title Page No. Teacher s Sign 1. BUBBLE SORT 2. INSERTION SORT 3. SELECTION SORT 4. PATTREN MATCHING 5. LINEAR SEARCH 6. BINARY SEARCH 7. QUICK SORT 8. MERGE SORT 9. STACK OPERATION USING
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 #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 informationPrepared by: Shraddha Modi
Prepared by: Shraddha Modi Introduction Operator: An operator is a symbol that tells the Computer to perform certain mathematical or logical manipulations. Expression: An expression is a sequence of operands
More informationImplementation of Singly Linked List. To write a program to implement the concept of singly linked list.
Ex. No: Date: Implementation of Singly Linked List. AIM: To write a program to implement the concept of singly linked list. ALGORITHM: 1. Start 2. Creation: Get the number of elements, and create the nodes
More informationData Structure & Algorithms Laboratory Manual (CS 392)
Institute of Engineering & Management Department of Computer Science & Engineering Data Structure Laboratory for 2 nd year 3 rd semester Code: CS 392 Data Structure & Algorithms Laboratory Manual (CS 392)
More informationData Structures. Lecture 4 : The Queues. Dr. Essam Halim Houssein Lecturer, Faculty of Computers and Informatics, Benha University
0 Data Structures Lecture 4 : Dr. Essam Halim Houssein Lecturer, Faculty of Computers and Informatics, Benha University 2 A queue is logically a first in first out (FIFO or first come first serve) linear
More informationStack. 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 informationChapter 6. Data Structure. /* start contains the address of the first node */ start = &elephant1; print_elephants( start ); return EXIT_SUCCESS;
Chapter 6 Data Structure Introductory notes are included in PowerPoint file. The programs illustrated are as follows: //elephnt1.c // This example is from C for Scientists and Engineers #include
More informationS.Y. Diploma : Sem. III [CO/CM/IF/CD/CW] Data Structure using C
S.Y. Diploma : Sem. III [CO/CM/IF/CD/CW] Data Structure using C Time: 3 Hrs.] Prelim Question Paper Solution [Marks : 100 Q.1 (a) Attempt any SIX of the following : [12] Q.1 (a) (i) Define time complexity
More informationData Structures. Lecture 5 : The Queues
0 Data Structures Lecture 5 : Dr. Essam Halim Houssein Lecturer, Faculty of Computers and Informatics, Benha University http://bu.edu.eg/staff/esamhalim14 2 A queue is logically a first in first out (FIFO
More information/****************************************** Application: Linked List Example Compiled on: Borland Turbo C++ 3.0
/****************************************** Application: Linked List Example Compiled on: Borland Turbo C++ 3.0 ******************************************/ #include #include /* Structure
More informationProcedural Programming
Exercise 6 (SS 2016) 04.07.2015 What will I learn in the 6. exercise Math functions Dynamic data structures (linked Lists) Exercise(s) 1 Home exercise 4 (3 points) Write a program which is able to handle
More informationAbstract Data Type: Stack
Abstract Data Type: Stack Stack operations may involve initializing the stack, using it and then de-initializing it. Apart from these basic stuffs, a stack is used for the following two primary operations
More informationBangalore South Campus
USN: 1 P E PESIT Bangalore South Campus Hosur road, 1km before ElectronicCity, Bengaluru -100 Department of Basic Science and Humanities INTERNAL ASSESSMENT TEST 3 Date: 22/11/2017 Time:11:30am- 1.00 pm
More informationUNIT 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 informationAssociate 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 informationLecture 4 Stack and Queue
Lecture 4 Stack and Queue Bo Tang @ SUSTech, Spring 2018 Our Roadmap Stack Queue Stack vs. Queue 2 Stack A stack is a sequence in which: Items can be added and removed only at one end (the top) You can
More informationData 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[ DATA STRUCTURES ] Fig. (1) : A Tree
[ DATA STRUCTURES ] Chapter - 07 : Trees A Tree is a non-linear data structure in which items are arranged in a sorted sequence. It is used to represent hierarchical relationship existing amongst several
More informationVTU NOTES QUESTION PAPERS NEWS RESULTS FORUMS THE STACK
Contents: Definition and Examples Representing stacks in C Example: infix, prefix, and postfix Exercises THE STACK Definition and Examples A stack is an ordered collection of items into which new items
More informationDS 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 informationDATA STRUCTURES AND ALGORITHMS
LECTURE 8 Babeş - Bolyai University Computer Science and Mathematics Faculty 2017-2018 In Lecture 7... ADT Queue ADT Matrix ADT List ADT Stack Today ADT Queue 1 ADT Queue 2 3 4 Note ADT Queue We will not
More informationThis document can be downloaded from with most recent updates. 1 Data Structures using C: Module 4 (16MCA11) LINKED LISTS
1 Data Structures using C: Module 4 (16MCA11) LINKED LISTS 4.1 MEMORY MANAGEMENT 4.1.1 Basics about Memory When a C program is compiled, the compiler translates the source code into machine code. Now the
More informationData Structures and Algorithms
Data Structures and Algorithms Alice E. Fischer Lecture 6: Stacks 2018 Alice E. Fischer Data Structures L5, Stacks... 1/29 Lecture 6: Stacks 2018 1 / 29 Outline 1 Stacks C++ Template Class Functions 2
More informationStack & Queue on Self-Referencing Structures
C Programming 1 Stack & Queue on Self-Referencing Structures C Programming 2 Representation of Stack struct stack { int data ; struct stack *next ; ; typedef struct stacknode node, *stack ; C Programming
More informationAE52/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 informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
WINTER 18 EXAMINATION Subject Name: Data Structure Model wer Subject Code: 17330 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in
More informationDC54 DATA STRUCTURES DEC 2014
Q.2 a. Write a function that computes x^y using Recursion. The property that x^y is simply a product of x and x^(y-1 ). For example, 5^4= 5 * 5^3. The recursive definition of x^y can be represented as
More informationDATA STRUCTURE. o DYNAMIC MEMORY. ALLOCATION o SELF-REFERENTIAL STRUCTURE o TYPEDEF LINK LIST STACK QUEUE TREE
DATA STRUCTURE TOPICS PAGE o DYNAMIC MEMORY 2-5 ALLOCATION o SELF-REFERENTIAL STRUCTURE o TYPEDEF LINK LIST 5-16 STACK 17-28 o APPLICATION OF STACK 28-38 QUEUE 39-43 TREE o BINARY SEARCH TREE o HEAP GRAPH
More informationGraphs: Graph Data Structure:
Graphs: A graph is a pictorial representation of a set of objects where some pairs of objects are connected by links. The interconnected objects are represented by points termed as vertices, and the links
More informationthe Queue queue ADT using the STL queue designing the simulation simulation with STL queue using STL list as queue using STL vector as queue
the Queue 1 The Queue Abstract Data Type queue ADT using the STL queue 2 Simulating a Printer Queue designing the simulation simulation with STL queue 3 adapting STL list and vector using STL list as queue
More information