CS计算机代考程序代写 FTP algorithm Assignment-March-3

Assignment-March-3

Assignment_Sep-25
In all assignments, if possible, you should make full use of ADTs (such as list/stack ADT) placed in ftp

Lec01-intro

Problem 1:

Write a function that will search a string for any one of a given set of characters. Your function should match this prototype:
char *find_char(char const *source, char const *chars);
The basic idea is to locate the first character in the source string that matches any of the characters in the chars string. The function then returns a pointer to the place in source where the first match was found. If none of the characters in source match any of the chars, then a NULL pointer is returned. If either argument is NULL, or either string is empty, then a NULL pointer is returned.
To illustrate, suppose source points to ABCDEDG. If chars points to XYZ, JURY, or QQQQ, the function should return NULL. If chars points to XRCQEF, the function should return a pointer to the C in source. The strings that the arguments point to are never modified.
As it happens, there is a function in the C library called strpbrk that behaves almost exactly the same as the one you are to write. But the object of this program is for you to manipulate the pointers yourself, so
a. You may not use any of the library string routines (for example, strcpy, strcmp, index, etc.), and
b. you may not use subscripts anywhere in your function.

Problem 2:

Write a function that delete a portion of a string. Here is its prototype:
int del_substr(char *str, char const *substr)
The function should first determine where the string substr occurs in str. If it does not, the value 0 should be returned. If the substring does appear, the function should remove it by copying the characters in str that follow the substring over the substring itself. the value 1 should then be returned. If the substring appears several times in the first argument, only the first occurrence should be deleted. The second argument should never be changed.
To illustrate, suppose str points to ABCDEFG. If substr points to FGH, CDF, or XABC. the function should return 0 and leave str unchanged. But if substr points to CDE, the function should change str to ABFG by copying the characters F, G, and the NUL byte. The function should then return 1. In no event is the second argument string ever modified.
As with the last program:
a. you may not use any of the library string routines (e.g., strcpy, strcmp, etc), and
b. you may not use any subscripts in your function.
On a philosophical note, the empty string is a substring of every string but removing an empty substring produces no change in the string.

Lec02-algorithm

Exercises (Textbook pp.35)
Ex. 2.1
Ex. 2.6 a.

Lec03-linear-list

Exercises (Textbook pp.86)
Ex. 3.15 a
Ex. 3.16 a, b’, c, where problem b’ is given as follows:
b’: Write a complete array implementation to finish the operation in Figure 3.61.
Hints:
Refer to ~\Proj_example\Proj_Larray on ftp
Requirements:
You are required to use the delete function included in Proj_Larray, i.e., void Delete(int x,LIST L)

Lec04-linked-list

Exercises (Textbook pp.86)
Ex. 3.15 b
Ex. 3.16 b’’, where problem b’’ is given as follows:
b’’ : Write a complete singly-linked list implementation to finish the operation in Figure 3.61.
Hints:
Refer to ~\Proj_example\ Proj_Llinked on ftp
Requirements:
You are required to use the delete function included in Proj_Llinked, i.e., void Delete(ElementType X, List L)