-
(a)Explain the difference between linear and non-linear data structures. Provide two examples of each and discuss a scenario where choosing one type over the other would significantly affect algorithm efficiency. (3 marks)
(b)Explain how strings are represented in memory as character arrays. Discuss the differences between ASCII and Unicode encoding, and describe how these encodings affect string storage. (4 marks)
-
(a)Explain the different primitive data types commonly used in programming. How does memory representation differ for integers, floats, characters, and Booleans? (4 marks)
(b)Describe the brute-force string matching algorithm and the Knuth–Morris–Pratt (KMP) algorithm. Compare their time complexities and explain why KMP is more efficient for large text searching. (4 marks)
