unit 2 (1)(1).docx
unit 2 (1)(1).docx
Input Format
Constraints
1≤n≤10^5
1≤q≤10^5
−10^9≤x≤10^9
Output Format
b)
Subject Name: Basic Data Structures using C++
Subject Code : 24CSH-103
Agenda: Integration of Course Content with Competitive Coding Scenario
Chandigarh University is building a database management
system to keep track of a list of students, such as UIDs. As
part of the system, they need functionality that allows
users to
message:
Input Format:
Constraints:
1≤n≤10^5
1≤q≤10^5
−10^9≤x≤10^9
Output Format:
Input Format:
The first line contains an integer nnn, representing the
number of participants.
The second line contains nnn space-separated integers,
each representing a participant's score. Constraints:
1≤n≤10^5
−10^9≤score≤10^9
Output Format:
5 a) Program to a.
A university is developing a student information system
demonstrate the use that allows professors to efficiently search for student roll
of linear search to numbers in the records. The system should enable a
professor to input the total number of students, their
search a given respective roll numbers, and a specific roll number they
element in an array. want to search for.
Subject Name: Basic Data Structures using C++
Subject Code : 24CSH-103
Agenda: Integration of Course Content with Competitive Coding Scenario
b) Program to The program should determine whether the given roll
number exists in the records. If found, it should display the
demonstrate the use position of its first occurrence (starting from 0).
of binary search to Otherwise, it should display "Not found."
Input Format:
search a given
The first line contains an integer nnn, representing the
element in a sorted
number of students.
array in ascending The second line contains nnn space-separated integers,
each representing a student’s roll number.
order.
The third line contains an integer xxx, the roll number
to be searched.
Constraints:
1≤n≤10^5
Output Format:
If the roll number is found, print its first occurrence
position (0-based index).
If not found, print "Not found".
b. A student is developing a feature for an online
bookstore where customers can search for the position of a
specific book ID in a sorted list of available books. The
system should allow the administrator to input the sorted
list of book IDs and then search for a specific book ID.
The program should efficiently determine whether the
given book ID exists in the list. If found, it should display
its position (starting from index 0). If the book ID is not
found, the program should display "Not found."
InputFormat
Subject Name: Basic Data Structures using C++
Subject Code : 24CSH-103
Agenda: Integration of Course Content with Competitive Coding Scenario
The first line contains an integer nnn, representing the
number of available books.
The second line contains nnn space-separated integers,
each representing a book ID (sorted in ascending order).
The third line contains an integer xxx, the book ID to
search for.
Constraints
1≤n≤10^5
OutputFormat
If the book ID is found, print its index (0-based).
Otherwise, print "Not found."
SampleInput0
13579
Sample Output 0
3
Subject Name: Basic Data Structures using C++
Subject Code : 24CSH-103
Agenda: Integration of Course Content with Competitive Coding Scenario
6 Program to sort an array of An online store receives customer orders with timestamps
indicating their arrival times. However, due to processing
integers in ascending order delays, these timestamps may not always be in the correct
using order. To generate an accurate daily report, the store
manager needs the orders arranged by their arrival times in
a. bubble sort chronological order.
Write a program that takes the list of order timestamps and
b. selection sort reorders them in ascending order so that the report reflects
the correct sequence of order arrivals.
c. insertion sort Input Format:
The first line contains an integer nnn, representing the
number of orders received.
The second line contains nnn space-separated integers,
each representing an order's timestamp.
Constraints:
1≤n≤10^3
Output Format: