Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
43 views

Programming Lab Assignment A3

The document provides instructions for a programming lab assignment. It lists 10 programming problems students must solve, with examples provided for some problems. It instructs students to write algorithms first before coding, use efficient algorithms, comment code clearly, and not copy answers from others.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Programming Lab Assignment A3

The document provides instructions for a programming lab assignment. It lists 10 programming problems students must solve, with examples provided for some problems. It instructs students to write algorithms first before coding, use efficient algorithms, comment code clearly, and not copy answers from others.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Programming lab assignment

COE III year A2 Batch

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.

EXAMPLEInput ABCDEC [the same C as eairlier]

Output C

3. Implement a function to check if a link list is a palindrome.

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?

5. Implement an algorithm to find depth of a tree.

6. Implement an algorithm for reversing the word of a sentence.

EXAMPLE INPUT- this is a sentence. OUTPUT- sentence a is this.

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)

Array 1 , 60 , -10 , 70 , -80 , 85

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.

EXAMPLE - {-2,11,-4,13,-5,2}20 {1,-3,4,-2,-1,6}7

You might also like