Professional Documents
Culture Documents
Chapter Three
َُخح عٍ هزا.هياكل البيانات الثابتة هٍ حُظُى نًدًىعه انبُاَاث فٍ انزاكشة انخٍ حى حكىٌ ثابخه فٍ انحدى
... حُث ال ًَكٍ إعادة حخصُص انزاكشة فٍ ولج الحك، انحذ األلصً نهحدى انزٌ َدب يعشفخه يسبمًا
Arrays are example of static data structure المصفوفات هً مثال على هُاكم البٌانات الثابته
A dynamic data structures , where in with the latter the size of the
structure can dynamically grow or shrink in size as needed.
حُث فٍ انحدى األخُش ًَكٍ أٌ ًَُى حدى انهُكم أو َخمهص بشكم حُىٌ حسب، هياكل البيانات الديناميكية
.انحاخت
1
BY NsM ][DATA STRUCTURES IN ARABIC
ال حدى ثابج ؛ ًَُى عُصش واحذ فٍ ولج واحذ نذَها حدى ثابج يحذد يسبما
ال ًَكٍ انىصىل بسهىنت إنً انعُصش األولَ .هضو انمفض يٍ خالل خًُع سهىنت انىصىل إنً أٌ عُصش فٍ
(Size=n×sizeof(element Size=n×sizeof(element(+
)n×sizeof(regerence
َدب عهً كم عُصش حخضٍَ انعُصش وانًؤشش إنً انعُصش انخانٍ (راكشة فمط انعُاصش حخضٌ
إضافُت نًؤشش انخخضٍَ)
2
BY NsM [DATA STRUCTURES IN ARABIC]
The linked list is sequence of nodes arranged one after another, with each node
connected to the next by a "link" (like a chain) each node contain:
" يع حىصُم كم عمذة باِخشة بىاسطت "سابط، انمائًت انًشحبطت هٍ حسهسم انعمذ يشحبت واحذة حهى األخشي
:ً(يثم سهسهت) ححخىٌ كم عمذة عه
ححخىٌ انمىائى انًشحبطت األحادٌه عهً انعمذ انخٍ ححخىٌ عهً خضء يٍ انبُاَاث:قائمة المرتبطه األحادية
.باإلضافت إنً خضء انعُىاٌ (انخانٍ) انزٌ َشُش إنً انعمذة انخانُت فٍ حسهسم انعمذ
3
BY NsM [DATA STRUCTURES IN ARABIC]
•Doubly Linked List : In a doubly linked list, each node (except he first and last
node) contains two links the first link points to the previous node and the next
link points to the next node in the sequence.
ً ححخىٌ كم عمذة (باسخثُاء انعمذة األونً واألخُشة) عه، فٍ لائًت يشحبطت انثُائُت: قائمة المرتبطة الثنائية
.سابطٍُ َشُش انشابط األول إنً انعمذة انسابمت وانشابط انخانٍ َشُش إنً انعمذة انخانُت فٍ انخسهسم
فٍ انمائًت انًشحبطت انذائشَت ححخىٌ انعمذة األخُشة يٍ انمائًت عهً عُىاٌ انعمذة: قائمة المرتبطة الدائرية
..ًاألون
4
BY NsM [DATA STRUCTURES IN ARABIC]
5.Delete first element: delete the element at the beginning of the list.
6.Delete last element: delete the element from the end of the list.
حزف انعُصش يٍ َهاَت انمائًت:حزف انعُصش األخُش
class Node {
int data;
node next;
node(int data) {
this.data = data; } }
5
BY NsM [DATA STRUCTURES IN ARABIC]
class SLL {
node head;
public SLL() {
this.head = null;
}
// methods
...
}
}
In the following steps for create linked list with data(22, 33, 44, 55,66)
66،55 ، 44 ، 33 ، 22( فً الخطوات التالٌة إلنشاء قائمة مرتبطة بالبٌانات
فً الشكل التالً ٌظهر بعض العملٌات على قائمة مرتبطة احادٌه
6
BY NsM [DATA STRUCTURES IN ARABIC]
7
BY NsM [DATA STRUCTURES IN ARABIC]
// method to print elements of singly linked list طريقة لطباعة عناصر قائمة مرتبطة احادٌة
else {
while (p.next != null)
p = p.next;
p.next = newNode;
}
}
8
BY NsM [DATA STRUCTURES IN ARABIC]
9
BY NsM [DATA STRUCTURES IN ARABIC]
ٌشٌر مرجع واحد إلى العقدة. تحتوي كل عقدة على زوج من المراجع، فً هذا النوع من القائمة المرتبطة
)ًالتً تسبق العقدة (السابقة) والنقاط األخرى إلى العقدة التً تتبع العقدة (التال
Advantages: مزاٌا
10
BY NsM [DATA STRUCTURES IN ARABIC]
Disadvantages: السلبٌات
11
BY NsM [DATA STRUCTURES IN ARABIC]
1.Add an element at the beginning of the list. إضافة عنصر فً بداٌة القائمة
2.Add an element in the end of the list. إضافة عنصر فً نهاٌة القائمة
3.Add an element after an item of the list. إضافة عنصر بعد عنصر من القائمة
4.Add an element before an item of the list.إضافة عنصر قبل عنصرمن القائمة
5.Delete the element at the beginning of the list.حذف العنصر فً بداٌة القائمة
6.Delete the element from the end of the list.حذف العنصر من نهاٌة القائمة
Last node references the first node تشٌر العقدة األخٌرة إلى العقدة األولى
12
BY NsM [DATA STRUCTURES IN ARABIC]
Both singly linked list and doubly linked list can be made into as circular linked list:
:ٌمكن إدراج كل من القائمة المرتبطة احادٌة والقائمة الثنائٌة كقائمة مرتبطة دائرٌه
Singly linked list as circular, the next pointer of the last node points to the first
node.
. ٌشٌر المؤشر التالً للعقدة األخٌرة إلى العقدة األولى، القائمة األحادٌه المرتبطة كما دائرٌة
Doubly linked list as circular, the next pointer of the last node points to the first
node and the previous pointer of the first node points to the last node making the
circular in both directions.
ٌشٌر المؤشر التالً للعقدة األخٌرة إلى العقدة األولى وٌشٌر المؤشر السابق، قائمة مرتبطة ثنائٌه كما دائرٌة
.للعقدة األولى إلى العقدة األخٌرة مما ٌجعلها دائرٌة فً كال االتجاهٌن
13
BY NsM [DATA STRUCTURES IN ARABIC]
•Add an element at the beginning of the list. إضافت عُصش فٍ بذاَت انمائًت
•Add an element in the end of the list. إضافت عُصش فٍ َهاَت انمائًت
•Add an element after an item of the list. إضافت عُصش بعذ عُصش يٍ انمائًت
•Add an element before an item of the list. إضافت عُصش لبم عُصش انمائًت
•Delete the element at the beginning of the list. احزف انعُصش فٍ بذاَت انمائًت
•Delete the element from the end of the list. احزف انعُصش يٍ َهاَت انمائًت
14
BY NsM [DATA STRUCTURES IN ARABIC]
15
BY NsM [DATA STRUCTURES IN ARABIC]
16
BY NsM [DATA STRUCTURES IN ARABIC]
17
BY NsM [DATA STRUCTURES IN ARABIC]
18
BY NsM [DATA STRUCTURES IN ARABIC]
19
BY NsM [DATA STRUCTURES IN ARABIC]
بالتوفٌق
20