CSU22014 Systems Programming Term 2022 p1
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
CSU22014
Michaelmas Term 2022
Systems Programming
1. The most common representation of character strings is as an array of characters, but it is also possible to represent strings using linked lists. When strings are represented with a
linked list, each character of the string occupies one node of the linked list.
Write a C abstract data type (ADT) called mystring that represents a string as a linked list
of characters. Your ADT should have functions to do the following:
a) Create a new empty string [10 marks]
b) Take a normal null-terminated array C string as a parameter, and return a new linked list-based string of type mystring. [10 marks]
c) A string copy function that takes a mystring as a parameter, and returns a newly created mystring that is a copy of the original string. [10 marks]
d) A string concatenate function, that takes two mystrings as a parameter and returns a new mystring that consists of the concatenation of the first and second string. [16 marks]
e) A string reverse function that takes a mystring as a parameter, and returns a new string that contains the same characters as the original string, but in reverse order. [16 marks]
f) A search function that takes two mystrings as parameters: a piece of text, and a string to search for. The function should search the text string for the search string, and if it finds a sequence of characters within the text that is equal to the characters in the search string it should return 1. Otherwise, the function should return 0. [26 marks]
g) A free function that frees the memory used by the string. [12 marks]
Your functions should operate directly on the linked list data structure that represents the string. You should not convert the linked list to an array or other data structure for processing.
Your string abstract data type should be implemented in the related files in the assignment for the exam on Blackboard.
2023-08-19