Programming Lab Assignment A3
Programming Lab Assignment A3
INSTRUCTIONS FOR FILE a. Students should write an algorithm first and then code for the problem. b. Complexity of the algorithm should be as minimum as possible. A brute force solution would not be considered for evaluation. c. The code should be well commented and aligned. d. No student should copy the assignment with any other students, if anybody is found doing so; strict action will be taken against him/her. PROGRAMMING LAB ASSIGNMENT
1. Given a integer x, write a function that multiplies x with 3.5 and returns the integer result. You are not allowed to use %, /, *. Examples: Input: Output: 7 Input: Output: 17 (Ignore the digits after decimal point) 5 2
2. Given a circular link list, implement an algorithm which returns the node at the beginning of the loop.
DEFINITION- Circular link list: a (corrupt) link list in which a nodes node pointer points to an earlier node, so as to make a loop in the link list.
Output C
4. Given an image represented by a NxN matrix, where each pixel in a image is 4 byte, write a method to rotate the image by 90 degrees. Can you do this in place?
7. write a program that searches a given text pattern in the given text function and prints all occurrences of pattern in the text. (give a O(n) solution) EXAMPLE INPUTText- do this program in the most efficient way Pattern - ici
OUTPUTPattern found at index 32 8. given an array A of n elements. Find three indices i,j and k such that A[i]2+A[j]2=A[k]2
9. Given an array with the both positive and negative numbers. Find the two element such that their sum is closest to zero. For the below array , algorithm should give -80 and 85.(brute force solution is not recommended)
10. Given an array of n numbers, give an algorithm for finding a contiguous subsequence A(i)A(j) for which the sum of the element is maximum.