Algorithms_Lab2_15M-2
Algorithms_Lab2_15M-2
Total Marks: 15
import java.util.*;
1. What does the program print when checking if the queue is empty before any
elements are added?
2. After adding the elements 1, 4, and 6, what are the printed outputs for the queue’s
size, its elements, and the first element (using peek())?
3. What will be the output after polling (removing) all elements from the queue, and
why?
4. Briefly explain the purpose of the peek() and poll() methods in the context of this
program.
1. Prompt the user to enter 5 integers (ensure the numbers are in ascending
order for binary search to work correctly).
3. Implement a binary search method to search for the entered number in the
array.
4. If the number is found, print the index where it is located; otherwise, print
"Not Found".
Submission Guidelines:
- Ensure the code is compilable and executable.
- The assessment should be submitted clearly to show the code and output screenshot.