|
| 1 | +# Bağlantılı Liste |
| 2 | + |
| 3 | +_Bunu diğer dillerde okuyun:_ |
| 4 | +[_简体中文_](README.zh-CN.md), |
| 5 | +[_Русский_](README.ru-RU.md), |
| 6 | +[_日本語_](README.ja-JP.md), |
| 7 | +[_Português_](README.pt-BR.md), |
| 8 | +[_한국어_](README.ko-KR.md), |
| 9 | +[_Español_](README.es-ES.md), |
| 10 | + |
| 11 | +Bilgisayar bilimlerinde, **Bağlantılı liste**, her biri hem gerçek verileri |
| 12 | +hem de listedeki bir sonraki düğümün bir bağlantısını içeren dinamik bir |
| 13 | +veri yapısıdır. Bu yapı, yineleme sırasında rastgele bir konumda |
| 14 | +öğeleri verimli bir şekilde eklemenize ve kaldırmanıza olanak tanır. |
| 15 | +Daha karmaşık seçenekler için, isteğe bağlı öğeleri verimli bir şekilde |
| 16 | +eklemek ve kaldırmak için ek bağlantılar içerir. |
| 17 | + |
| 18 | +Bağlantılı listelerin bir dezavantajı, erişim süresinin doğrusal olmasıdır |
| 19 | +(ve ardışık düzene geçirilmesi zordur). Rastgele erişim gibi daha hızlı erişim |
| 20 | +mümkün değildir. Diziler, bağlantılı listelere kıyasla daha iyi önbellek konumuna sahiptir. |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +## Temel İşlemler için Sözde Kod |
| 25 | + |
| 26 | +### Ekleme |
| 27 | + |
| 28 | +```text |
| 29 | +Add(value) |
| 30 | + Pre: value is the value to add to the list |
| 31 | + Post: value has been placed at the tail of the list |
| 32 | + n ← node(value) |
| 33 | + if head = ø |
| 34 | + head ← n |
| 35 | + tail ← n |
| 36 | + else |
| 37 | + tail.next ← n |
| 38 | + tail ← n |
| 39 | + end if |
| 40 | +end Add |
| 41 | +``` |
| 42 | + |
| 43 | +```text |
| 44 | +Prepend(value) |
| 45 | + Pre: value is the value to add to the list |
| 46 | + Post: value has been placed at the head of the list |
| 47 | + n ← node(value) |
| 48 | + n.next ← head |
| 49 | + head ← n |
| 50 | + if tail = ø |
| 51 | + tail ← n |
| 52 | + end |
| 53 | +end Prepend |
| 54 | +``` |
| 55 | + |
| 56 | +### Arama |
| 57 | + |
| 58 | +```text |
| 59 | +Contains(head, value) |
| 60 | + Pre: head is the head node in the list |
| 61 | + value is the value to search for |
| 62 | + Post: the item is either in the linked list, true; otherwise false |
| 63 | + n ← head |
| 64 | + while n != ø and n.value != value |
| 65 | + n ← n.next |
| 66 | + end while |
| 67 | + if n = ø |
| 68 | + return false |
| 69 | + end if |
| 70 | + return true |
| 71 | +end Contains |
| 72 | +``` |
| 73 | + |
| 74 | +### Silme |
| 75 | + |
| 76 | +```text |
| 77 | +Remove(head, value) |
| 78 | + Pre: head is the head node in the list |
| 79 | + value is the value to remove from the list |
| 80 | + Post: value is removed from the list, true, otherwise false |
| 81 | + if head = ø |
| 82 | + return false |
| 83 | + end if |
| 84 | + n ← head |
| 85 | + if n.value = value |
| 86 | + if head = tail |
| 87 | + head ← ø |
| 88 | + tail ← ø |
| 89 | + else |
| 90 | + head ← head.next |
| 91 | + end if |
| 92 | + return true |
| 93 | + end if |
| 94 | + while n.next != ø and n.next.value != value |
| 95 | + n ← n.next |
| 96 | + end while |
| 97 | + if n.next != ø |
| 98 | + if n.next = tail |
| 99 | + tail ← n |
| 100 | + tail.next = null |
| 101 | + end if |
| 102 | + n.next ← n.next.next |
| 103 | + return true |
| 104 | + end if |
| 105 | + return false |
| 106 | +end Remove |
| 107 | +``` |
| 108 | + |
| 109 | +### Geçiş |
| 110 | + |
| 111 | +```text |
| 112 | +Traverse(head) |
| 113 | + Pre: head is the head node in the list |
| 114 | + Post: the items in the list have been traversed |
| 115 | + n ← head |
| 116 | + while n != ø |
| 117 | + yield n.value |
| 118 | + n ← n.next |
| 119 | + end while |
| 120 | +end Traverse |
| 121 | +``` |
| 122 | + |
| 123 | +### Ters Geçiş |
| 124 | + |
| 125 | +```text |
| 126 | +ReverseTraversal(head, tail) |
| 127 | + Pre: head and tail belong to the same list |
| 128 | + Post: the items in the list have been traversed in reverse order |
| 129 | + if tail != ø |
| 130 | + curr ← tail |
| 131 | + while curr != head |
| 132 | + prev ← head |
| 133 | + while prev.next != curr |
| 134 | + prev ← prev.next |
| 135 | + end while |
| 136 | + yield curr.value |
| 137 | + curr ← prev |
| 138 | + end while |
| 139 | + yield curr.value |
| 140 | + end if |
| 141 | +end ReverseTraversal |
| 142 | +``` |
| 143 | + |
| 144 | +## Karmaşıklıklar |
| 145 | + |
| 146 | +### Zaman Karmaşıklığı |
| 147 | + |
| 148 | +| Erişim | Arama | Ekleme | Silme | |
| 149 | +| :-------: | :-------: | :-------: | :-------: | |
| 150 | +| O(n) | O(n) | O(1) | O(n) | |
| 151 | + |
| 152 | +### Uzay Karmaşıklığı |
| 153 | + |
| 154 | +O(n) |
| 155 | + |
| 156 | +## Referanslar |
| 157 | + |
| 158 | +- [Wikipedia](https://en.wikipedia.org/wiki/Linked_list) |
| 159 | +- [YouTube](https://www.youtube.com/watch?v=njTh_OwMljA&index=2&t=1s&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8) |
0 commit comments