Data Structures and Algorithms
Data Structures and Algorithms
General Instructions
Write your name Id, Department and section both on the cover page and on the answer
sheet.
Please make sure the exam has 4 parts and 8 pages including the cover page and the
answer sheet.
Provide your answer only on the separate answer sheet.
Any material shall not be taken to the exam room unless permitted by the course
instructor.
Cheating is strictly forbidden and it will lead you academic dismissal.
Please switch off your mobile until the end of the exam.
PLEASE DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO!!
Part I: True/False Items (8 points)
Instruction: Write TRUE if the statement is true and FALSE if the statement is
false. (1 point each)
1. Hash tables use the array data structure as a data storage medium.
2. Hashing cannot be used for applications where multiple records with the same key value
are permitted.
3. Data searching can be optimized to a very high level if the data is sorted.
4. Bubble sort is a better sorting algorithm than the selection sort algorithm because it
makes the minimum amount of swapping values.
5. A balanced binary tree is a binary tree in which each node has either 0 or 2 children.
6. The depth first traversal/search graph traversal algorithm uses the queue data structure to
maintain visited nodes and continue searching.
7. Big-O notation is used to measure the lower bound growth rate of an algorithm.
8. For binary search to work properly the dataset should be stored in a sorted format.
2. Create a binary search tree using the following values, [8, 3, 6, 5, 4, 13, 9, 10, 15, 1].
(4pts)
3. Traverse the following binary search tree using all the tree traversing algorithms. (4pts)
4. Determine the following terms for the following tree: (4pts)
Find the root node (vertex) of the tree:
Determine the descendants of D:
Determine the ancestors of J:
Determine the degree of the tree:
Determine the height of the tree:
Determine the path length of the tree:
5. Traverse the following graph using both Breadth first and Depth first search algorithms:
(4pts)
6. Draw the graph using the following adjacency list of a graph. (2pts)
7. What is the worst case running time complexity of the following code snippet? (2pts)
for(inti=1; i<=n; i++){
for(int j=1; j<=n; j*=2){
cout<<j<<endl;
}
}
8. Write an algorithm and its implementation to find the largest element in a given array.
(3pts)
Microlink Information Technology and Business Collage
Department of computer science
Mid exam for data structures and algorithms
2020/ Academic Year
Answer sheet
1. ______________ 1. ______________
2. ______________ 2. ______________
3. ______________ 3. ______________
4. ______________ 4. ______________
5. ______________ 5. ______________
6. ______________ 6. ______________
7. ______________ 7. ______________
8. ______________ 8. ______________
2.
3.
4.
5.