Created
April 2, 2022 19:08
-
-
Save argestes/9761c79c083eeb167dffd342db5ab832 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.birohcek; | |
import java.util.*; | |
public class Main { | |
public static void main(String[] args) { | |
// write your code here | |
// 1, 2, 3, 4, 5 | |
List<Integer> integerList = Arrays.asList(10, 20, 30, 40, 50); | |
Scanner scanner = new Scanner(System.in); | |
int kullaniciIntegeri = scanner.nextInt(); | |
extracted(integerList, kullaniciIntegeri); | |
} | |
// returns index if found, -1 otherwise | |
// Best case 1, | |
// Worst case integerList.size | |
// n = eleman sayisi | |
// O(n) bu islemin suresi tahminen eleman sayina gore lineer artar | |
// eger 100 elemani varsa 500 islem yapiyorsa | |
// bu durumda 100.000 elemani varsa 500.000 | |
// Big O (ya da big oh) notation | |
// okunurken 'O n kompleksitesindedir' denir | |
private static int extracted(List<Integer> integerList, int kullaniciIntegeri) { | |
for (int i = 0; i < integerList.size(); i++) { | |
System.out.println("Islem yaptim"); | |
Integer integer = integerList.get(i); | |
for (int i1 = 0; i1 < integerList.size(); i1++) { | |
// boyle bi durumda O(n*n) O(n kare) | |
} | |
if (integer.equals(kullaniciIntegeri)) { | |
// buldum | |
return i; | |
} | |
} | |
for (int i1 = 0; i1 < integerList.size(); i1++) { | |
// boyle bi durumda O(2n) | |
} | |
return -1; | |
} | |
// Vararg | |
// variable arguments | |
// sevval(1, 2, 3, 4, 5, 6, 7, 8, 9); | |
public static void sevval(int... a) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment