11import java .util .Scanner ;
22class Search {
3- public void linearsearch (n , arr )
3+ public void linearsearch (arr , key )
44 {
5- for
5+ for (int i =0 ;i <arr .length ;i ++)
6+ {
7+ if (arr [i ]==key )
8+ {
9+ System .out .println ("Element found at Index" +i );
10+ return ;
11+ }
12+ }
13+ System .out .println ("Element not found in the array" );
14+ }
15+
16+ public void Binarysearch (arr ,element )
17+ {
18+ while (l <=r )
19+ {
20+
21+ }
622 }
723}
824class Main {
925public static void main (String []args ) {
1026Scanner sc =new Scanner (System .in );
11- do {
12- System .out .println ("Enter the size of the array:" );
13- n =sc .nextInt ();
14- int arr [n ];
15- for (int i =1 ;i ,n ;i ++)
16- {
17- arr [i ]=sc .nextInt ();
18- }
27+ int n ;
28+ int []arr ;
1929System .out .println ("MENU DRIVEN ARRAY SORT- SEARCH PROGRAM" );
2030System .out .println ("ALGORITHM - Time Complexity" );
2131System .out .println ("1.) Linear Search - O(n)" );
@@ -25,15 +35,28 @@ public static void main(String[] args) {
2535System .out .println ("5.) Insertion Sort - O(n^2)" );
2636System .out .println ("6.) Merge Sort - O(n logn)" );
2737System .out .println ("7.) Radix sort - O(nk)" );
28-
29- int choice ;
30-
31- choice =sc .nextInt ();
38+ do {
39+ System .out .println ("Enter the size of the array:" );
40+ n =sc .nextInt ();
41+ arr =new int [n ];
42+ System .out .println ("Enter" +n +"elements in an array:" );
43+ for (int i =1 ;i ,n ;i ++)
44+ {
45+ arr [i ]=sc .nextInt ();
46+ }
47+ int choice =sc .nextInt ();
48+ Search se =new Search ();
3249switch (choice )
3350 {
3451case 1 :
3552System .out .println ("Searching Algorithm : Linear Search" )
36-
53+ System .out .println ("Enter the Key to search:" );
54+ int key =sc .nextInt ();
55+ se .linearSearch (arr ,key );
56+
57+ case 2 :
58+ System .out .println ("Searching Algorithm : Binary Search" )
59+
3760
3861 }
3962