Professional Documents
Culture Documents
DSA MidTerm Exam 20202021 Sample001
DSA MidTerm Exam 20202021 Sample001
DSA MidTerm Exam 20202021 Sample001
Name: ………………………………………………………………………………………..
Q1. a) Write a C++ function evenNo( ) to return the count of even numbers in a
8
positive integer array with n elements.
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
b) Write a code to call this function for an integer array A with 5 elements. Assign the returned value to an
integer variable x.
…………………………………………………………………………………………………………………
c) Run the code in (b); since the array A is given as: { 12, 13, 15, 3, 2}.
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
Page 1 of
SAMPLE0
Data Structures and Algorithms – Midterm Examination 16 March 2021
University of Science & Technology Level : 2nd Level IT
Ibb Branch Semester : 2nd 2020/2021
Faculty of Computing & IT Duration : 1 Hour
IT Programs Lecturer : Dr. Redhwan Q. Shaddad
Q2. 12 For a linked list head with 5 nodes with the following information:
a) Write a definition for nodeType record which is used to declare this linked list.
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
Page 2 of
SAMPLE0
Data Structures and Algorithms – Midterm Examination 16 March 2021
University of Science & Technology Level : 2nd Level IT
Ibb Branch Semester : 2nd 2020/2021
Faculty of Computing & IT Duration : 1 Hour
IT Programs Lecturer : Dr. Redhwan Q. Shaddad
d) Write a code to call the buildListBackward( ) function for the head list.
…………………………………………………………………………………………………………………
e) Write definition of Neg_to_Zero()function which resets the negative data of list nodes to zeros.
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
f) Run the following code for the given data above for head list:
head = Neg_to_Zero(head);
nodeType* current;
current=head;
current = current->link; }
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………
Good Luck
Page 3 of
SAMPLE0