blob: 709b10fa861f32456e61ecbbdfa8d96d842e2ad4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
#import "/template.typ": highlight-output
#highlight-output[```
$ java ArraySearch
Menu-driven program of array searching
Enter the array:
Enter the length: 5
Enter the array elements: 5 7 9 3 4
Menu:
1. Re-enter array
2. Display array elements
3. Perform linear search
4. Perform binary search
5. Exit
Enter your choice: 2
The array elements are: 5.0 7.0 9.0 3.0 4.0
Menu:
1. Re-enter array
2. Display array elements
3. Perform linear search
4. Perform binary search
5. Exit
Enter your choice: 3
The array elements are: 5.0 7.0 9.0 3.0 4.0
Enter the element to find: 7
The element 7.0 was found in the array at position 2.
Menu:
1. Re-enter array
2. Display array elements
3. Perform linear search
4. Perform binary search
5. Exit
Enter your choice: 3
The array elements are: 5.0 7.0 9.0 3.0 4.0
Enter the element to find: 8
The element 8.0 was not found in the array.
Menu:
1. Re-enter array
2. Display array elements
3. Perform linear search
4. Perform binary search
5. Exit
Enter your choice: 4
Array is sorted before binary search.
The array elements are: 3.0 4.0 5.0 7.0 9.0
Enter the element to find: 4
The element 4.0 was found in the array at position 2.
Menu:
1. Re-enter array
2. Display array elements
3. Perform linear search
4. Perform binary search
5. Exit
Enter your choice: 4
Array is sorted before binary search.
The array elements are: 3.0 4.0 5.0 7.0 9.0
Enter the element to find: 8
The element 8.0 was not found in the array.
Menu:
1. Re-enter array
2. Display array elements
3. Perform linear search
4. Perform binary search
5. Exit
Enter your choice: 1
Enter the length: 7
Enter the array elements: 9 -11 7 13 5 0 4
The array elements are: 9.0 -11.0 7.0 13.0 5.0 0.0 4.0
Menu:
1. Re-enter array
2. Display array elements
3. Perform linear search
4. Perform binary search
5. Exit
Enter your choice: 2
The array elements are: 9.0 -11.0 7.0 13.0 5.0 0.0 4.0
Menu:
1. Re-enter array
2. Display array elements
3. Perform linear search
4. Perform binary search
5. Exit
Enter your choice: 5
Bye.
```]
|