Lab Manual. Data Structures (Pr): COT-213 Data Structures (P): IT-215



Similar documents
PES Institute of Technology-BSC QUESTION BANK

10CS35: Data Structures Using C

DATA STRUCTURES USING C

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

Data Structure [Question Bank]

Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT. Course Curriculum. DATA STRUCTURES (Code: )

Data Structure and Algorithm I Midterm Examination 120 points Time: 9:10am-12:10pm (180 minutes), Friday, November 12, 2010

Sample Questions Csci 1112 A. Bellaachia

Exam study sheet for CS2711. List of topics

Unit Write iterative and recursive C functions to find the greatest common divisor of two integers. [6]

Java Software Structures

5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.

Binary Search Trees CMPSC 122

Data Structures. Level 6 C Module Descriptor

Analysis of a Search Algorithm

Questions 1 through 25 are worth 2 points each. Choose one best answer for each.

1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) Total 92.

Atmiya Infotech Pvt. Ltd. Data Structure. By Ajay Raiyani. Yogidham, Kalawad Road, Rajkot. Ph : ,

Lab Manual. Advanced Pr I IT 314

International Journal of Software and Web Sciences (IJSWS)

A TOOL FOR DATA STRUCTURE VISUALIZATION AND USER-DEFINED ALGORITHM ANIMATION

BCS2B02: OOP Concepts and Data Structures Using C++

Ordered Lists and Binary Trees

MAX = 5 Current = 0 'This will declare an array with 5 elements. Inserting a Value onto the Stack (Push)

Objected oriented Programming: C++ Unit 1 1. Introduction 1.1. Introduction to Object Oriented Programming C++ fundamentals.

Bangalore University B.Sc Computer Science Syllabus ( Semester System)

Abstract Data Type. EECS 281: Data Structures and Algorithms. The Foundation: Data Structures and Abstract Data Types

Binary Heap Algorithms

Chapter 3: Restricted Structures Page 1

To My Parents -Laxmi and Modaiah. To My Family Members. To My Friends. To IIT Bombay. To All Hard Workers

Any two nodes which are connected by an edge in a graph are called adjacent node.

Binary Search Trees. A Generic Tree. Binary Trees. Nodes in a binary search tree ( B-S-T) are of the form. P parent. Key. Satellite data L R

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING LESSON PLAN

AP Computer Science AB Syllabus 1

University of Pune Revised Structure for the B. Sc. (Computer Science) Course (Second Year to be implemented from Academic Year )

Data Structures and Algorithms

Module 2 Stacks and Queues: Abstract Data Types

EE2204 DATA STRUCTURES AND ALGORITHM (Common to EEE, EIE & ICE)

Common Data Structures

CHAPTER 4 ESSENTIAL DATA STRUCTRURES

Converting a Number from Decimal to Binary

Syllabus for Computer Science. Proposed scheme for B.Sc Programme under Choice Based Credit System

Dynamic Programming. Lecture Overview Introduction

The following themes form the major topics of this chapter: The terms and concepts related to trees (Section 5.2).

St S a t ck a ck nd Qu Q eue 1

2. (a) Explain the strassen s matrix multiplication. (b) Write deletion algorithm, of Binary search tree. [8+8]

Data Structures and Data Manipulation

Binary Search Trees (BST)

ECE 250 Data Structures and Algorithms MIDTERM EXAMINATION /5:15-6:45 REC-200, EVI-350, RCH-106, HH-139

Binary Heaps * * * * * * * / / \ / \ / \ / \ / \ * * * * * * * * * * * / / \ / \ / / \ / \ * * * * * * * * * *

DATA STRUCTURE - QUEUE

Sorting Algorithms. Nelson Padua-Perez Bill Pugh. Department of Computer Science University of Maryland, College Park

CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team

Data Structures UNIT III. Model Question Answer

Data Structures. Topic #12

A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:

Data Structure with C

Lecture 11 Doubly Linked Lists & Array of Linked Lists. Doubly Linked Lists

INTERNATIONAL JOURNAL OF PURE AND APPLIED RESEARCH IN ENGINEERING AND TECHNOLOGY

Data Structures Using C++ 2E. Chapter 5 Linked Lists

CSE373: Data Structures and Algorithms Lecture 1: Introduction; ADTs; Stacks/Queues. Linda Shapiro Spring 2016

TREE BASIC TERMINOLOGIES

Data Structures, Practice Homework 3, with Solutions (not to be handed in)

7.1 Our Current Model

Home Page. Data Structures. Title Page. Page 1 of 24. Go Back. Full Screen. Close. Quit

Introduction to Data Structures

ML for the Working Programmer

Algorithms and Data Structures

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

AP Computer Science Java Mr. Clausen Program 9A, 9B

The Elective Part of the NSS ICT Curriculum D. Software Development

Chapter 13: Query Processing. Basic Steps in Query Processing

root node level: internal node edge leaf node Data Structures & Algorithms McQuain

ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology)

CompSci-61B, Data Structures Final Exam

1. Define: (a) Variable, (b) Constant, (c) Type, (d) Enumerated Type, (e) Identifier.

Pseudo code Tutorial and Exercises Teacher s Version

Heaps & Priority Queues in the C++ STL 2-3 Trees

Symbol Tables. Introduction

Chapter 14 The Binary Search Tree

Algorithms and data structures

I PUC - Computer Science. Practical s Syllabus. Contents

Universidad Carlos III de Madrid

COMPUTER SCIENCE. Paper 1 (THEORY)

Data Structures and Algorithm Analysis (CSC317) Intro/Review of Data Structures Focus on dynamic sets

AFF 808. Sub. Code 4BIT1C1. B.Sc. DEGREE EXAMINATION, NOVEMBER First Semester. Information Technology

Introduction to Data Structures and Algorithms

Previous Lectures. B-Trees. External storage. Two types of memory. B-trees. Main principles

A binary search tree is a binary tree with a special property called the BST-property, which is given as follows:

Data Structures Using C++

Data Structures Fibonacci Heaps, Amortized Analysis

1.2 Solving a System of Linear Equations

Analysis of Algorithms I: Binary Search Trees

22c:31 Algorithms. Ch3: Data Structures. Hantao Zhang Computer Science Department

Big Data and Scripting. Part 4: Memory Hierarchies

Sequential Data Structures

Sorting revisited. Build the binary search tree: O(n^2) Traverse the binary tree: O(n) Total: O(n^2) + O(n) = O(n^2)

S. Muthusundari. Research Scholar, Dept of CSE, Sathyabama University Chennai, India Dr. R. M.

Transcription:

Lab Manual Data Structures (Pr): COT-213 Data Structures (P): IT-215

!" #$%&'() * +, -. 951/6201617535973417*37311 235678976: ;7<361753092975147297514<1=0343597237297514597=59729751437<343> <>736=61694>309=35970175979?094560353?@543=597+1494637=1?730>A B13416175;0137<410351<9214359771 '3!C96D68796D%!C69E!" F134=751=7G1/*713437<H734>F945751=7G1/F101=597H@@01714597B141945 I=945*537<3@01F94571 )39JKL!!"?43>/0175979343>?43>594312341343>M4372913<<59737<60520=359792341 6354=1F53=37<I1137<5143220=35971241971N303597?63O7249@016M605201 53=37<G11737343>1 P3Q96R!8!" *71<*5M<17597309=35979453=37<G111362019071<05290>796303<<597 =962349791G1753037<071<309=3597959431M7N1497=97=35173597A=92>7951051 6201617535977037311 09@0>*71<*5/0175979=4=03437<<9@0>071<0513<1479<171459737<<1015972341 63544124117535977<9@0>071<05136201943220=35979<9@0>071<05M<>736= 59431637316175M79<154=5414957194309=359737<<1309=3597171430O1<0537<41=4N1 30945694=92>737<=96234979051 S3T8U6!8!" 411H3==97=12537<<1759793541137<@734>541137<39=351<51467909>H734>5411 543N143051=7G1H734>5411412411753597954115437946359795411759@734>54119616941 9214359797@734>5411H734>F134=411V13237<132945413<1<@734>5411W432/ X12411753597943237<514543N1430B766=95F237774111 YZZ[\ ^1V949`5O37<F1F37/;7<361753090353F54=5417F1=97<<597a7N1451+41 V><143@3<1-1X1H1+3510/21450353F54=54173773+@014-bb^1 c1x1*141/0353f54=541a+494360177+v1,101;175/13459962514+4943667d90^3493+@0=3597^efg1 g1h>497f1w9541<ah3@43/194>37<+49@0169+4943667`5*3731f=36 F141BV-bbg1 0123456175996251477114741543

01214256726589!" #$%"&'"&$!$("!)*!)+,- /25016720/3 4$5*6$4$!"'$!$7$)78"!$)'$*&97'!6:556&!"76!!6$75!$! $'!55!$!9;6$78*5!&$!"8'$(7'$56"!!$7'!)'$$8*6$7 '$!5<5!!75!&6&&!"6!$7'!$'$7'$!5=<5!!>?"!5"!$5'!$(+ - 48157@2/A1/14052/A87@/2B689 C8668!")$&$&8$&!5$!)D*&$7E<$!$7!6)$6D*!!5F!7$)$6D*"6$7F*99"74$7G)$7H*6:$!5I!5J$ K- 42LMN801214256726589 %!!J&!$658$8!!7'$!$8!!$!)7!55&!'')8*6$7!66 $!9"&$58$!)8!!7'!!!7&!'*"!$$!'7!55$&*"$'"6!$8'! &!$67J!&'"8!''"6!$8$!6:7J'O!"*!$7&!P)'9"&7D*$!"!"6!$ 8$!6:!5D**>&*"$'"$!6:!5D**+ Q- R2/S8101214256726589 :5$>58$7!"6!$8$!6:!5D**+CJ!&'"8":5"$7'"&!"!55$7 6&'!8D*$!"!5":5!"6!$8$!)>O766!$!$T6')8$"$+ U*9":5$U8$866*"!!55*9"":5"$7!557$!55"$7 '!&!$J7'$!$*)5*9"":5"$+CJ!&'"8!''"6!$85*9"":5"$> 5!&6$!)&!!)&$>5$*6$*7*$8!"6!$!55!"6!$7)!"P5"$!56*O!")$&86')!56&'!8"$+ - V1W1/78101214256726589 7F!666'$!558$8!$!59!$!5!6!$5$&")7J!&'"8 $$*6$*+F!$$!O!"7F!$'$!$8$7$!8&!$8$$ 9!$7&&'!$9!$+X!'I'$!$8)!'!5$ $!O!"+ YZZ[4 +C]^$P!5+!?*5!&$!"8U!$!$*6$*7X!")$!7 =+I+F+`!$"CJ'$U!$!$*6$*(7a!!`*9"7=+ b+i++a*u!$!$*6$*t`)!&u)(7`]4+ +U+?+a *$!$8(&'*$`)!&&)c"7#!!`*9"6!$7_de+ -F+X$85!5`9"&8`)!&&)^$(!)*!)76!*&7G]7 d+

Lab Instructions Several practicals / programs? Whether an experiment contains one or several practicals /programs One practical / program Lab Teacher forms groups of the students based on All Students need to perform the practical/program Assign all practicals /programs among all groups Teacher decides whether the completed practicals / programs can be appropriately described using flow chart, algorithm, query statement, etc. Teacher issues necessary instructions to the students for writing practicals / programs accordingly Students write experiments in practical files and get them signed by the lab teacher Students make entries in the list of contents of the practical files and get them signed by the lab teacher Whether practical has been verified and signed by the lab teacher?? If a student has not completed a practical, he/she is expected to complete it at his/her own with the help of his/her fellow students in his/her hostel The student completes the practical file and submits it to the concerned teacher in his/her office or mail box on next working day In case of an experiment containing several practicals, a lab teacher needs to think whether a practical performed by the students in one group needs to be repeated by the other groups in lab on the same day? OR A practical performed by the students in one group needs to be repeated as assignments to be completed by the students of other groups in their hostels? Here, an assignment includes both executing a program on computer and also writing the same in practical file. OR A practical performed by the students in one group needs to be repeated as assignments, only writing practicals in their practical files, for the students of other groups in their hostels? Teacher issues necessary instructions to the students accordingly.

L T P - - 3 Lab Manual Data Structures (P) COT-213 and IT-215 Practical exam: 40 Sessional: 60 Experiment 1 (Programs on Strings and Passing Pointers to Functions) I. Write a function that accepts as input a string and determines the frequency of occurences of each of the distinct characters in string. Test your function using suitable data. II. Write a function, strndel, that accepts a string and two integers, start and length. Return a new string that is equivalent to the original string, except that length characters beginning at start have been removed. III. Write a function, strdel, that accepts a string and a character. The function returns string with the first occurence of character removed. IV. WAP with function to swap two numbers using call by reference. V. WAP with function to swap two integer arrays of same size using call by reference. VI. WAP to reverse an array by swapping (without using additional memory). VII. WAP with function to swap two strings using pointers. VIII. WAP to find the number of Non Repeated elements in an Array. IX. WAP to identify the missing numbers in a given Array within the range [1...N]. Experiment 2 (Dynamic Memory Allocation and File Operations) I. WAP to find the Median of the elements after merging the two sorted Arrays of same size. II. WAP to store an information in array of structure, dynamically, and also give a function to display the current information. The program should give user a choice for inserting a data or to display the current data. Implement the program for Student structures (contains student_name, student_roll_no, total_marks). III. Implement the above program for Employee structures (contains employee_name, emp_no, emp_salary). IV. Implement the above program for Faculty structures (contains faculty_name, faculty_id, subject_codes, class_names). V. WAP to Create a new file, Open an existing file, read the file to search a given word, write into the file and close the file. 1

Experiment 3 (Searching and Sorting in Non-decreasing order) Test the following programs on various cases such as already sorted, reverse sorted and average sorted cases. Also verify whether the sorting algorithm is stable. Count the number of swaps and number of comparisons taken place. I. WAP to implement Linear search and Binary search on 1D array of Integers. II. WAP to implement Insertion and Selection sort on 1D array of strings. III. WAP to implement Quick sort on 1D array of characters. IV. WAP to implement Merge Sort on 1D array of Student structures (contains student_name, student_roll_no, total_marks) with key as student_roll_no. V. WAP to implement Bubble and Radix sort on 1D array of Faculty structures (contains faculty_name, faculty_id, subject_codes, class_names) with key as faculty_id. Experiment 4 (Sparse Arrays and Matrix Operations) I. WAP to store and display a Lower-Right triangular matrix in RMO and CMO fashion. II. WAP to store and display an Upper-Right triangular matrix in RMO and CMO fashion. III. WAP to store and display a Tri-Diagonal matirx in RMO and CMO fashion. IV. WAP to store and display a Lower-Left triangular matrix in RMO and CMO fashion. V. WAP to store and display an Upper-Left triangular matrix in RMO and CMO fashion. VI. WAP to store and display a C matrix in RMO and CMO fashion. (C matrix contains non-zero elements in first row, last row and first column only) VII. WAP to store and display a Z matrix in RMO and CMO fashion. (Z matrix contains nonzero elements in first row, last row and right diagonal only.) VIII. WAP using switch statement to perform the following functions: Transpose of a matrix, computing determinant of a matirx, addition of two matrices and multiplication of two matrices. The program should handle a wrong input exceptions such as size mis-match, etc. IX. WAP for addition and multiplication of two sparse matrices. The matrices can be any of the following type, a. Lower-Right triangularmatrix b. Upper-Right triangular matrix c. Tri-Diagonal matrix d. Lower-Left triangular matrix e. Upper-Left triangular matrix Firstly the program should ask the user about the type(s) of input matrices, store the given matrices either in RMO or CMO fashion in 1D Array and then perform the respective operation and display the result. 2

Experiment 5 (Stacks and Queues) I. (a) WAP to implement Stack ADT using Arrays which has basic operations as Create(), IsEmpty(), Push(), Pop(), IsFull() with appropriate prototype to a functions. WAP to evaluate a given postfix expression using stack ADT. II. (a) (c) III. IV. WAP to Cyclically Permute the elements of an Array. WAP to check the given string is palindrome using stack. WAP to check the given expression is correctly parenthesized. WAP to Implement two overlapping Stacks, facing in opposite directions, using an Array and Check for Overflow & Underflow conditions. WAP to implement a 3-stacks of size m in an array of size n with all the basic operations such as IsEmpty(i), Push(i), Pop(i), IsFull(i) where i denotes the stack number (1,2,3), m n/3. Stacks are not overlapping each other. Leftmost stack facing the left direction and other two stacks are facing in the right direction. V. (a) WAP to transform infix expression into equivalent postfix expression using stack. Also use the user defined operators, $,#, etc, with appropiate priorities. Eg. A+(B*C- D/E$F)*G)*H, {*,/} > $ > {+,-} WAP to tranform infix expression into equivalent prefix expression, similar as above. VI.(a) VII.(a) WAP wihch gives the solution to the Tower of Hanoi problem for n disks. Test the program using: a) N=3, b) N=4. WAP to solve Maze problem of size mxn. WAP to implement Queue ADT using Arrays with the basic functions of Create(), IsEmpty(), Insert(), Delete() and IsFull() with suitable prototype to a functions. WAP to implement Queue using Stacks. VIII.(a) WAP to implement 2 overlapping queues in an Array of size N. There are facing in opposite direction to eachother. Give IsEmpty(i), Insert(i), Delete(i) and IsFull(i) routines for i th queue. WAP to implement Dequeue using Arrays with all the basic operations. 3

Experiment 6 (Singly Linked List) I. WAP to construct simple linear linked list using dynamic memory allocation for the given elements with the following functions, (a) Inserting a new node, Accessing a node (finding the position wrt header), (c) Removing a node with particular key value, (d) Complete deletion of a linked list, and (e) Displaying the current list. (f) Copy the linked list and return the pointer of the new list. Implement the above program for the elements as Strings. II. (a) III. (a) IV. (a) WAP to reverse a singly linked list using one auxillary pointer. And try without using any auxillary pointer. WAP to implement Stack ADT using Linked list with the basic operations as Create(), IsEmpty(), Push(), Pop(), IsFull() with appropriate prototype to a functions. WAP to implement Queue ADT using Linked list with the basic functions of Create(), IsEmpty(), Insert(), Delete() and IsFull() with suitable prototype to a functions. WAP to perform BFS on the given tree (represented in Linked list form) using Queue ADT. WAP for polynomial addition and multiplication. Represent polynomial in linked list form with suitable data structure. WAP to compare two polynomials. Represent polynomial in linked list form with suitable data structure. V. WAP to swap elements in pairs in the given linked list. (e.g.: 1->2->3->4->5->null, then result should be 2->1->4->3->5->null.) VI. (a) (c) WAP to find second last node of the given linked list. WAP to concatenate two singly linked list in sorted order either ascending or descending. WAP to sort singly linked list. VII. (a) WAP to print alternate nodes from the list. WAP to concatenate the even elements from the two linked list. (c) WAP to find first common element between two linked list. (d) WAP to find the number of occurrence of all the elements in a linked list. 4

Experiment 7 (Circular Singly Linked List and Doubly Linked List) I. WAP to create a Circular Singly Linked List for the given elements with the following functions, (a) Inserting a node, before the node with key givenkey, Inserting a node, after the node with key givenkey, (c) Accessing a node (finding the position wrt header), (d) Removing a node with particular key value, (e) Complete deletion of a list, (f) Displaying the current list, and (g) Sorting the list. Implement the above program for the elements as Strings. II. WAP to implement doubly linked list with the following operations; (a) Inserting a node, before the node with key givenkey, Inserting a node, after the node with key givenkey, (c) Inserting a node at i ith location wrt header.(assuming header at 1 st location) (d) Accessing a node (finding the position wrt header), (e) Removing a node with particular key value, (f) Complete deletion of a list, (g) Displaying the current list in clockwise fashion, (h) Displaying the current list in anti-clockwise fashion, and (i) Sorting the list. Implement the above program for the elements as Student structures (contains student_name, student_roll_no, total_marks) with key as student_roll_no. III. WAP to represent various sparse matrices using linked list and give addition function to add two sparse matrices. IV. Implement the above program (1) with the elements as Employee structures (contains employee_name, emp_no, emp_salary) with key as emp_no. V. Implement the above program (2) with the elements as Faculty structures (contains faculty_name, faculty_id, subject_codes, class_names) with key as faculty_id. Experiment 8 (Binary Trees, BST, Heaps, Heap sort and Threaded Binary Trees) I. (a) WAP to build a binary tree for the given elements (integers) and also give traversal functions : inorder, preorder, postorder. WAP to traverse a given binary tree in inorder, preorder, postorder, converse inorder, converse preorder, converse postorder fashion. (converse - traverse in a reverse direction) (c) WAP to transform given tree into a binary tree. (d) WAP to represent an arithematic expression in binary tree format. II.(a) WAP to implement BST with insertion, search and deletion operation for the elements as strings. WAP using function to find inorder-predecessor and inorder-successor for any node in 5

(c) III.(a) a BST. WAP using functions to find the height, number of levels, number of leave nodes, number of internal nodes and total number of nodes in the given BST. WAP to implement priority queues using heaps (min heap or max heap) with add and delete functions. WAP to perform heap sort on the given list of elements. Experiment 9 (Graphs) I. (a) WAP to represent the given graph in the form of adjacency list. II. (a) III. IV. WAP to find cut-set of the given graph. WAP to represent the given graph in the form of adjacency matrix. WAP to find cut-vertex of the given graph. WAP to perform BFS for any given graph. WAP to perform DFS for any given graph. Advanced Problems (Optional) I. WAP to implement Shell and Bucket sort on 1D array of Employee structures (contains employee_name, emp_no, emp_salary) with key as emp_no. II. WAP to find the middle element of the given linked list in one pass. (Hint: take 2 pointers p and q. Initially p will point to 1 st node and q will point to 2 nd node. Advance p always by 1 and q by 2. Proceed this way until q reached last node, so now p will point to the middle element. ) III. Write an efficient program to remove duplicates from a singly linked list. IV. WAP to convert BST into inorder Thereaded binary tree. V. WAP to convert BST into preorder Thereaded binary tree. VI. WAP to convert BST into postorder Thereaded binary tree. VII. WAP to find minimum cost spanning tree for the given tree using kruskal s method. VIII. WAP to find minimum cost spanning tree for the given tree using prims s method. 6