Structures and Pointers – Strings – Problem #2

IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive

Difficulty: medium

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.

Back to Lab Problems
Structures and Pointers/Strings/Problem #2

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #2

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.