Professional Documents
Culture Documents
Cairo University
Faculty of Engineering
Computer Engineering Department
Data Structures and Algorithms
Sheet #2
Classes and Lists
1. Given two sorted (ordered) sequential lists (arrays) L1 and L2, write an efficient algorithm to
print sorted intersection L1 ∩ L2 using only the basic list operations.
Assume that L1 and L2 are sets (no duplicates) and the printed numbers mustn’t contain
duplicates too.
2. Given two sorted lists L1 and L2, write an efficient algorithm to print sorted union L1 ∪ L2 using
only the basic list operations.
Assume that L1 and L2 are sets (no duplicates) and the printed numbers mustn’t contain
duplicates too.
4. Write a C++ class “Student” to store student information. The class should store the following
information:
- Student Name (max. 150 characters)
- Student ID
- Student grades in 40 courses
5. Write a global C++ function that searches an array of Student class objects (as specified in
problem 4) for a student with a specified ID. What should be the output of that function?
9. Write an algorithm to insert an element x in a sorted array. The element should be inserted in
the position that keeps the array sorted. If the element already exists in the array, it should not
be inserted.