CSE1001-Fall'20-Practice Problems 4
CSE1001-Fall'20-Practice Problems 4
1.
Input Format:
...
Next line contains the register number ‘r’ that has to be searched
Output Format:
Boundary Conditions:
Sparse Matrix
Write an algorithm and the subsequent Python program to check whether the given
matrix is sparse or not. A matrix is said to be a “Sparse” if the number of zero entries
in the matrix, is greater than or equal to the number of non-zero entries. Otherwise
it is “Not sparse”. Check for boundary conditions and print 'Invalid input' when not
satisfied.
Input Format:
The first line will contain the number of rows in the matrix, rows
The Second line will contain the number of columns in the matrix, cols
The next (rows * cols) lines will contain the elements of the matrix, entered row wise
Output Format:
Boundary Conditions:
3.
Polynomial Addition
Write an algorithm and the subsequent Python program to add the two given
polynomials. Assume that the coefficients of each polynomial are stored in a separate
list.
Input Format:
...
Output Format:
4.
When you are coding in the online judge (SkillRack), use rstrip() function to remove
carriage return from the input string.
Input Format:
….
stop
Output Format:
Number of friends
5.
Arrangement of Plants
A gardener has the practice of assigning ID to the plants during plantation. One day,
he makes a note of the heights of plants in his garden. He writes the height of the
plant against the ID of the plant. He then instructs his employee to keep the plants,
in ascending order of its height. Design an algorithm and write the Python code to
display the list of ID numbers of plants in ascending order of their height. IDs are also
numbers. Check for boundary conditions and print 'Invalid input' for wrong input. For
example, if there are three trees with IDs as 175, 160, 120 and height as 47, 73 and 23
then the output should be [120, 175, 160].
Input Format:
...
Output Format:
Boundary Conditions: