Programlama dilleri ve algoritamaların karşılaştırıldığı tartışmalar hep olagelmiştir. Bir taraf algoritmaya hakim olunduğunda tüm dillerde yazılım yapılabileceğini savunurken diğer taraf programlama dilinin özelliklerine hakim olunduğunda algoritmanın önemsizliğini hep savunmuştur.
Aşağıda videoda bu konuyu birde biz inceleyelim istedik. Bana göre programlama dili ve algoritmalar birbiri ile kıyaslanamaz birbirinin yerine geçemez. Ancak ve ancak birbirlerini tamamlayarak daha ileriye götürürler.
Programlama Dilleri vs Algoritmalar karşılaştırmasını 2 video olarak ele alacağız. Sonunda bu yapıları karşılaştırma yerine birleştirmenin daha doğrı bir seçim olacağını göstermeye çalışacağız.
Gelin, birlikte 2 Milyar işlemden kurtulduğumuz ve 136 bin kat hızlı olabileceğimiz bir serüvene çıkalım. Videodaki örneğin sonunda 2 Milyar işlem yaparken 1 işleme düşmek bunu da 136 Bin kat daha hızlı yapmak oldukça heyecan verici olacaktır.
Örnek Kodlar
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 |
package io.bilisim.java.loop.algorithm; /** * @author Alper Akalin * @project com.kimkorkarjavadan.java.algorithms * @package com.kimkorkarjavadan.java.loop.algorithm * @date 2017-02-06 */ public class LoopAlgorithm { public static void main(String[] args) { double t1 = System.nanoTime(); System.err.println("Integer.MAX_VALUE: " + Integer.MAX_VALUE); for (int i = 0; i < 10; i++) { System.out.print(i + " - "); maxIntegerToplam1(); } double t2 = System.nanoTime(); System.out.println(); System.out.println("hesaplama süresi: " + (t2 - t1) + " nano saniye"); System.out.println("hesaplama süresi: " + ((t2 - t1) / 1000000000) + " saniye"); } public static void maxIntegerToplam1() { Long toplam = 0L; long j= Integer.MAX_VALUE; for (long i = 0; i <= j; i++) { toplam = toplam + i; } System.out.println("toplam1 = " + toplam); } public static void maxIntegerToplam2() { long toplam = 0L; for (long i = 0; i <= Integer.MAX_VALUE; i++) { toplam = toplam + i; } System.out.println("toplam2 = " + toplam); } public static void maxIntegerToplam3() { long n = Integer.MAX_VALUE; Long toplam = n * (n + 1) / 2; System.out.println("toplam3 = " + toplam); } public static void maxIntegerToplam4() { long n = Integer.MAX_VALUE; long toplam = n * (n + 1) / 2; System.out.println("toplam4 = " + toplam); } } |
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 |
package io.bilisim.java.loop.algorithm; /** * @author Alper Akalin * @project com.kimkorkarjavadan.java.algorithms * @package com.kimkorkarjavadan.java.loop.algorithm * @date 2017-02-06 */ public class LoopVsAlgorithm { public static void main(String[] args) { double maxIntegerToplam1 = 6.6761024805E10d; double maxIntegerToplam4 = 488960.0d; System.out.println(maxIntegerToplam1 / maxIntegerToplam4); } public static void maxIntegerToplam1() { Long toplam = 0L; for (long i = 0; i <= Integer.MAX_VALUE; i++) { toplam = toplam + i; } System.out.println("toplam1 = " + toplam); } public static void maxIntegerToplam4() { long n = Integer.MAX_VALUE; long toplam = n * (n + 1) / 2; System.out.println("toplam4 = " + toplam); } } |