Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 01b896c

Browse files
committed
modified: DSA/Arrays.class
modified: DSA/Arrays.java
1 parent 38888c2 commit 01b896c

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

‎DSA/Arrays.class‎

-57 Bytes
Binary file not shown.

‎DSA/Arrays.java‎

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
ARRAY
33
Creating Array
4-
*/
4+
55
import java.util.*;
66
public class Arrays{
77
public static void main(String args[]){
@@ -24,4 +24,56 @@ public static void main(String args[]){
2424
2525
System.out.println(marks.length);
2626
}
27+
}
28+
29+
UPDATING ARRAY
30+
31+
32+
public class Arrays{
33+
public static void update(int marks [], int a){
34+
a =10;
35+
for (int i=0; i<marks.length; i++){
36+
marks[i] = marks[i] + 1;
37+
38+
}
39+
}
40+
public static void main(String args[]){
41+
int marks[] = {89, 98, 86};
42+
int a = 5;
43+
update(marks, a);
44+
System.out.println(a);
45+
46+
//print marks
47+
for(int i=0; i<marks.length; i++){
48+
System.out.print(marks[i]+ " ");
49+
}
50+
System.out.println();
51+
}
52+
}
53+
54+
LINEAR SEARCH
55+
*/
56+
57+
public class Arrays{
58+
public static int linearSearch(int number[], int key){
59+
for (int i=0; i<number.length; i++){
60+
if(number[i]==key){
61+
return i;
62+
}
63+
}
64+
return -1;
65+
}
66+
public static void main(String args[]){
67+
int number[] = {2,7,9,6,2,10,12,78,96};
68+
int key = 100;
69+
70+
int index = linearSearch(number,key);
71+
72+
if(index==-1){
73+
System.out.print("Not found");
74+
}
75+
else{
76+
System.out.println("The key exists at index: "+ index);
77+
}
78+
}
2779
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /