F4104 : ALGORITHM & DATA STRUCTURE

advertisement
F4104 : ALGORITHM & DATA STRUCTURE
LAB 10: Binary Search
Laboratory
Exercises
Duration: 2 Hours
Learning Outcomes
This Labsheet encompasses activities 10A.
By the end of this laboratory session, you should be able to:
1. Define searching.
2. Explain binary searching algorithm.
3. Apply binary searching method to solve a given problem.
Exercise 10A
Outcome: Use binary searching to solve problems
The binary search algorithm searches the list by first comparing the key sought with the
middle element in the list. Binary search requires the sorted list.
The following is sorted list. By using binary searching, find how many steps needed to
find the desired value. Illustrate the process.
i.
ii.
Find 89 in : {12 23 14 32 39 40 59 61 69 77 89 93}
Find S in : {A D G H J L R T}
(8 marks)
(PLO2, CLO4, LD2)
Conclusion
(2 marks)
(PLO2, CLO4, LD2)
Page 1 of 1
Download