Structures and Pointers – Strings – Problem #2
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
In this program, you will search for a prefix in a list of student records sorted by roll numbers. (Definition of prefix will be explained. Ex: The string “abc” has three prefixes – “a”, “ab”, “abc”.) Define a global structure named student as given in the first problem. Ask the user for the number of student records. Then dynamically allocate an array of structures of appropriate size. Populate it with user input. Assume that the user enters student records in increasing (lexicographic) order of the roll numbers. The user should then enter a search string s. The program should then use binary search to search for and print all student records that have s as a prefix.