The assignment name for turnin is cs352_hw4
1- Word Processing
One important feature in word processing is the alignment of words to both the left and right margins of a page. This justification can be achieved by inserting one or more blank characters between each of the words in a line so that the rightmost word aligns with the right margin.
Write a program that reads several lines of text from the standard input and prints the text in justified format. Your program should print 65 characters per line, and it should distribute the blank characters among existing words evenly.("word1 5spaces word2 1space word3 2space word4 1space word5" is not a good distribution, it should be "word1 3spaces word2 2spaces word3 2spaces word4 2spaces word5". Note that the following word, i.e., word6 should be more than 4 characters, ow. we could fit word6 on that line also.) Name your program wordprocess.c
2- Maze Traversal
The following grid of ones and zeros is a double-subscripted array representation of a maze:
The ones represent the walls, and the zeros represent squares in the possible paths.
There is a simple alrithm for walking through a maze that guarantees finding the exit(if there's one) Place your right hand on the wall to your right and begin walking forward. Never remove your hand from the wall. If the maze turns to the right, you follow the wall to the right. This way you will eventually arrive at the exit.
a) Write a recursive function Traverse to walk through the maze. The prototype is as:
int Traverse(char maze[][], int n, int m, int x, int y);
where maze is an n*m character array, and the starting position is maze[x,y]. As "Traverse" attempts to locate the exit, it should place the character "X" in each square in the path. The function should display the maze after each move so the user can watch as the maze is solved.
b) Write a function Generate that has the following prototype:
char **Generate(int n, int m, int *x, int *y);
which creates a random maze of size n*m, and returns the maze. It also provides a random start position by assigning random values to *x, and *y.
Put your functions into a file called maze.c.
3- Merge sort
Note that the mergesort program we saw in class worked just when the size was a power of two. Modify mergesort.c in /home/cs352/SUMMER02/lecture9progs/ so that it can be used with an array of any size.(Hint: Recall that any positive integer can be expressed as a sum of powers of two. For example, 19=16+2+1. Consider the array as a collection of subarrays of sizes that are powers of two. Sort the subarrays and then use merge() to produce the final sorted array.) Your program should be called mergesort.c
4- String Manipulation
Write a function subseq in a file subseq.c that has the prototype:
char **subseq(char *str1, char*str2);
and returns an array of pointers if str2 is a subsequence of str1. Each pointer points to the (leftmost possible)corresponding character in str1.(If str2=afkm then str1=...a...f...k...m... For example str1=bffhaabkfkftm, then the returned array is an array of size 4, with elems p1, p2, p3, p4, where p1 is a pointer to the first a in str1, p2 is a pointer to the 3rd f, p3 is a pointer to the 2nd k, and p4 is a pointer to the m in str1.) If str2 is not a subsequence of str1 then it simply returns NULL.