Posts

Data Structures Lab PCCSL 307 KTU BTech 2024 Scheme - Experiments and Reference

  Expt. No. Experiments 1 Find the sum of two sparse polynomials using arrays 2 Find the transpose of a sparse matrix and sum of two sparse matrices. 3 Convert infix expression to postfix(or prefix)and then evaluate using stack, 4 Implement Queue,DEQUEUE,and Circular Queue using arrays. 5 Implement backward and forward navigation of visited web pages in a web browser(i.e.back and forward buttons)using doublyl inked list operations. 6 Implement addition and multiplication of polynomials using singly linked lists. 7 Create a binary tree for a given simple arithmetic expression and find the prefix /postfix equivalent. 8 Implement a dictionary of word-meaning pairs using binary search trees. 9 Find the shortest distance of every cell from a land mine inside a maze.   ...

Lab Assignments

Lab Cycle-1  Week-1 July 2025 Learning Outcome: Learn to use arrays and develop application programs.Analyse the performance. (Show the output after completing all the programs. Evaluation is done based on this) Write C programs to do the following: 1) Write a function rotate(int a[],int n,char d,int cr) to rotate given array elements. The function will take the array, number of elements in the array, direction of rotation(l-left r-right) and count of rotation( how many times to rotate) Eg: input array a[]=2 3 4 5 6 7 rotate(a,6,l,2) output:4 5 6 7 2 3 rotate(a,6,r,2) output:6 7 2 3 4 5 2) Find the mean, median and mode of list of elements. Use array to implement the same.(assume Unimode ). Write separate functions. l=[1,2,3,5,4,5,6,3,1,1] Mean-3.1 Median-3.0 Mode-1 3) Find the frequency of occurrence of each character in the string ( histogram) Eg: input: This is a test string Output:t-3, h-1,i-3,s-4,’ ‘-4…….etc 4)Consider two sets S1={1,2,3,4}, and S2={3,4,5}. Find the intersect...

Polynomial Addition using Arrays

Polynomial  Addition We can represent a polynomial as a collection of terms and every term is having a coefficient and exponent. So, we can represent this as a list of terms having coefficients and exponents.  Each term of a polynomial (like 3 x 2 3x^2 , 5 x 1 5x^1 , − 7 x 0 -7x^0 ) can be stored in a structure having two parts: coefficient (like 3, 5, -7) exponent (like 2, 1, 0) An array of such structures represents the whole polynomial. Structure Definition (Example in C) struct Term { int coeff; // Coefficient of the term int expo; // Exponent of the term }; And then you can declare: struct Term poly1 [10], poly2 [10], polyResult [20]; to represent polynomials. Algorithm to Add Two Polynomials Assumption : Both polynomials are sorted in decreasing order of exponents . Steps : Initialize three pointers (indexes): i = 0 for first polynomial (poly1), j = 0 for second polynomial (poly2), k = 0 for result polynomial (polyR...