Lab 12, Esc101, 2004-05 Semester-II

Solve the following problems


Problem 1

In a matrix,

Write a O(nlog(m)) program to search for a given element in the matrix, where the matrix is of dimension n x m.

For extra interest: write a log(n) * log(m) algorithm for the same.



Problem 2   

Write a program which opens a file for reading, and replaces each line with a line in which each word is its reverse, and writes it back to another file.

If  a line in input file is

Hello! Welcome to Esc101 Course

then it should be replaced by

!olleH emocleW ot 101csE esruoC