You are on page 1of 2

DS LAB - Practice set I 1.REVARR Given an array of integers, write a C program to reverse the array using recursion. 2.

.MATMUL Given two matrices P and Q, write a program to check whether the matrix R=P x Q can be computed. If possible, find R, using recursive matrix multiplication. Note: implement the simple recursive algorithm given in http: en.wikipedia.org wiki !trassen"algorithm#$lgorithm 3.STRC U!T Given a word str and the name %or path& of text file, write a program to find the total number of occurrences of str in the specified file. Str will consist only of letters from the 'nglish alphabet (a)*$)+, ".REPLACE Given a string %a sentence or a paragraph& str and two other strings s1 and s2, write a program to find all occurrences of s1 in str and replace all of them with s2. $ll of str, s1 and s2 can contain letters from the 'nglish alphabet (a)*$)+,,digits(-).,, space, comma, period, and or exclamation mark. #.STRCAT Given two strings, say s1 and s2, write a program to concatenate the two. /he final string %which should be in s1& should have the contents of s0 followed by that of s1. /he program must use pointers to access the strings. $.%CDLCM Given two non)negative integres, say & and ', find %CD%m,n& and LCM%m,n&. (.)IB !ACCI Given a positive integer ', find the 't* 2ibonacci number. /he 't* 2ibonacci number 2n is given by 2'32'-142'-2 with 2132230

+.QUADRATIC Given three real numbers a,- and c, find the roots of the 5uadratic e5uation ax 14bx4c3-. Use quadratic formula. 2ind both the roots, irrespective of whether the roots are real or imaginary. ..SIEVE Given an integer n%say, n30---&, write a program that uses the sie/e 01 Erat0st*e'es to find all primes up to and including n. 12.LI!SEARC3 Given an array of n integers, write a program to search whether a particular integer, say 4, is present in the array. If present, return the index of the same. 6therwise, return )0.7se linear search. 11.BI!SEARC3 Given a sorted array of ' integers, write a program to search whether a particular integer, say 4, is present in the array. If present return the index of the same. 6therwise, return )0. Use binary search.

You might also like