📄 النص الكامل للصفحة
--- SECTION: خوارزمية البحث بأولوية العمق --- خوارزمية البحث بأولوية العمق
Depth-First Search (DFS) Algorithmفي البحث بأولوية العمق (DFS)، ستقوم باتباع الحواف، وتتعمق أكثر وأكثر في المخطط. يستخدم البحث بأولوية العمق إجراء استدعاء تكراري للتنقل عبر العقد. عند الوصول إلى عقدة لا تحتوي على حواف لأي عقدة جديدة، ستعود إلى العقدة السابقة وتستمر العملية. تستخدم خوارزمية البحث بأولوية العمق هيكل بيانات المكدس لتتبع مسار الاستكشاف. بمجرد استكشاف عقدة، ستضاف إلى المكدس. عندما ترغب في العودة، ستُحذف العقدة من المكدس كما هو موضح في الشكل 2.7.--- SECTION: شكل 2.7 --- شكل 2.7: خوارزمية البحث بأولوية العمق (DFS)المثال التالي يوضح طريقة عمل خوارزمية البحث بأولوية العمق (DFS)، باستخدام المخطط التالي، تتبع ترتيب استكشاف العقد (Traversal) بحسب خوارزمية البحث بأولوية العمق.
ملاحظة: استخدم هيكل البيانات المناسب.--- SECTION: 1 --- 1 عالج الجذر A ثم أضفه إلى المكدس.--- SECTION: 2 --- 2 عالج العقدة B ثم أضفها إلى المكدس.--- SECTION: 3 --- 3 عالج العقدة D ثم أضفها إلى المكدس. ستُحذف العقدة التي فُحصت وليس لها فروع من المكدس. (احذف العقدة D).--- SECTION: 4 --- 4 عالج العقدة E ثم أضفها إلى المكدس. ستُحذف العقدة التي فُحصت وليس لها فروع من المكدس. (احذف العقدة E).--- SECTION: لمحة تاريخية --- لمحة تاريخية طُوّرت النسخة الأولى من خوارزمية البحث بأولوية العمق (DFS) في القرن التاسع عشر بواسطة عالم رياضيات فرنسي كاستراتيجية لحل المتاهات.2025 - 1447--- VISUAL CONTEXT ---
**DIAGRAM**: شكل 2.7: خوارزمية البحث بأولوية العمق (DFS)
Description: A directed tree diagram illustrating the Depth-First Search algorithm. The tree has a root node 'A' at المستوى 0 (Level 0). 'A' has two children: 'B' and 'C' at المستوى 1 (Level 1). 'B' has two children: 'D' and 'E' at المستوى 2 (Level 2). 'C' has two children: 'F' and 'G' at المستوى 2 (Level 2). Dashed arrows with numbers (1-6) indicate a possible traversal order: 1 from A to B, 2 from B to D, 3 from D back to B, 4 from B to E, 5 from E back to B, 6 from B back to A. This visualizes the 'depth-first' exploration and backtracking.
Key Values: Nodes: A, B, C, D, E, F, G, Levels: المستوى 0, المستوى 1, المستوى 2, Traversal path indicated by numbered arrows 1-6
Context: This diagram is the primary visual representation of the graph structure (a tree) that the Depth-First Search algorithm explores. The numbered arrows illustrate the conceptual flow of the DFS traversal, emphasizing deep exploration before backtracking.**DIAGRAM**: المخطط والمكدس في الخطوة 1
Description: This visual element consists of two parts: a simplified tree diagram and a stack. The tree diagram shows nodes A, B, C, D, E, F. Node 'A' is highlighted in blue, indicating it is the current node being processed. The stack diagram shows a single block labeled 'A' at the bottom, representing that node A has been added to the stack.
Key Values: Tree nodes: A, B, C, D, E, F, Highlighted node: A, Stack content: A (bottom)
Context: This visual demonstrates the initial step of the DFS example, where the root node 'A' is processed and pushed onto the stack, which is a key data structure for DFS.**DIAGRAM**: المخطط والمكدس في الخطوة 2
Description: This visual element consists of two parts: a tree diagram and a stack. In the tree diagram, node 'A' is greyed out, and node 'B' is highlighted in blue. A dashed arrow labeled 'فُحصت' (examined) points from 'A' to 'B', indicating the traversal. The stack diagram shows two blocks: 'A' at the bottom and 'B' on top, representing that node B has been processed and pushed onto the stack, on top of A.
Key Values: Tree nodes: A, B, C, D, E, F, Greyed node: A, Highlighted node: B, Traversal arrow: A to B, labeled 'فُحصت', Stack content: A (bottom), B (top)
Context: This visual illustrates the second step of the DFS example, showing the algorithm moving from node 'A' to its child 'B', marking 'B' as examined, and pushing 'B' onto the stack.**DIAGRAM**: المخطط والمكدس في الخطوة 3
Description: This visual element consists of two parts: a tree diagram and two stack diagrams. In the tree diagram, nodes 'A' and 'B' are greyed out, and node 'D' is highlighted in blue. A dashed arrow points from 'B' to 'D'. The first stack diagram shows 'A' (bottom), 'B', and 'D' (top). The second stack diagram shows 'D' being popped off the stack (indicated by an upward arrow), leaving 'A' (bottom) and 'B' (top). This represents processing node D, finding no unvisited children, and then backtracking by popping D from the stack.
Key Values: Tree nodes: A, B, C, D, E, F, Greyed nodes: A, B, Highlighted node: D, Traversal arrow: B to D, Stack before pop: A, B, D, Stack after pop: A, B, Node D popped from stack Context: This visual demonstrates the third step of the DFS example, where a leaf node 'D' is processed. Since it has no further branches to explore, it is popped from the stack, illustrating the backtracking mechanism of DFS.**DIAGRAM**: المخطط والمكدس في الخطوة 4
Description: This visual element consists of two parts: a tree diagram and two stack diagrams. In the tree diagram, nodes 'A', 'B', and 'D' are greyed out, and node 'E' is highlighted in blue. A dashed arrow points from 'B' to 'E'. The first stack diagram shows 'A' (bottom), 'B', and 'E' (top). The second stack diagram shows 'E' being popped off the stack (indicated by an upward arrow), leaving 'A' (bottom) and 'B' (top). This represents processing node E, finding no unvisited children, and then backtracking by popping E from the stack.
Key Values: Tree nodes: A, B, C, D, E, F, Greyed nodes: A, B, D, Highlighted node: E, Traversal arrow: B to E, Stack before pop: A, B, E, Stack after pop: A, B, Node E popped from stack Context: This visual demonstrates the fourth step of the DFS example, similar to step 3. Node 'E' is processed, and since it has no further branches, it is popped from the stack, continuing the backtracking process to explore other branches from node 'B' (which has no more unvisited children, so B would be popped next, though not shown in this step).
🎴 بطاقات تعليمية للمراجعة
عدد البطاقات: 5 بطاقة لهذه الصفحة
ما هو التعريف الأساسي لخوارزمية البحث بأولوية العمق (DFS)؟
الإجابة: في البحث بأولوية العمق (DFS)، يتم اتباع الحواف والتعمق أكثر وأكثر في المخطط، مستخدمةً إجراء استدعاء تكراري للتنقل عبر العقد، وعند الوصول لعقدة لا تحتوي على حواف لعقد جديدة، يتم العودة للعقدة السابقة والاستمرار. تستخدم هيكل بيانات المكدس لتتبع مسار الاستكشاف.
الشرح: يصف هذا التعريف الآلية الأساسية لخوارزمية DFS التي تتعمق في مسار واحد قبل استكشاف المسارات الأخرى.
تلميح: فكر في طريقة استكشاف المسارات الطويلة أولاً قبل العودة.
ما هو هيكل البيانات الرئيسي الذي تستخدمه خوارزمية البحث بأولوية العمق (DFS) لتتبع مسار الاستكشاف؟
الإجابة: تستخدم خوارزمية البحث بأولوية العمق (DFS) هيكل بيانات المكدس (Stack) لتتبع مسار الاستكشاف.
الشرح: المكدس ضروري في DFS لأنه يسمح بالعودة (Backtracking) إلى العقدة السابقة عندما يصل البحث إلى طريق مسدود، مما يتيح استكشاف مسارات أخرى.
تلميح: تذكر ما هو الهيكل الذي يسمح بإضافة العناصر وإزالتها بترتيب عكسي (آخر عنصر يدخل هو أول عنصر يخرج).
كيف تتعامل خوارزمية البحث بأولوية العمق (DFS) عندما تصل إلى عقدة لا تحتوي على حواف لأي عقد جديدة؟
الإجابة: عند الوصول إلى عقدة لا تحتوي على حواف لأي عقد جديدة، تعود خوارزمية البحث بأولوية العمق (DFS) إلى العقدة السابقة وتستمر في عملية الاستكشاف من هناك.
الشرح: هذه الآلية تسمى 'الرجوع' (Backtracking) وهي جزء أساسي من عمل DFS، حيث تسمح بالانتقال من مسار تم استكشافه بالكامل إلى مسار آخر.
تلميح: فكر في عملية 'الرجوع' أو 'التراجع' عندما لا تجد الخوارزمية مساراً جديداً.
ما هو الأصل التاريخي لخوارزمية البحث بأولوية العمق (DFS)؟
الإجابة: طُورت النسخة الأولى من خوارزمية البحث بأولوية العمق (DFS) في القرن التاسع عشر بواسطة عالم رياضيات فرنسي كاستراتيجية لحل المتاهات.
الشرح: تاريخياً، استُخدمت DFS كأداة فعالة لحل الألغاز والمسارات المعقدة مثل المتاهات.
تلميح: ابحث عن الكلمة التي تشير إلى التطبيق الأولي للخوارزمية.
ما هي خوارزمية البحث بأولوية العمق (Depth-First Search (DFS) Algorithm)؟
الإجابة: في البحث بأولوية العمق (DFS)، ستقوم باتباع الحواف، وتتعمق أكثر وأكثر في المخطط. يستخدم البحث بأولوية العمق إجراء استدعاء تكراري للتنقل عبر العقد. عند الوصول إلى عقدة لا تحتوي على حواف لأي عقدة جديدة، ستعود إلى العقدة السابقة وتستمر العملية.
الشرح: خوارزمية DFS تستكشف كل فرع بأقصى عمق ممكن قبل الانتقال إلى الفرع التالي، مما يجعلها مناسبة للمشاكل التي تتطلب استكشاف جميع الاحتمالات.
تلميح: ركز على طريقة استكشاف العقد المتجاورة في المخطط.
التصنيف: تعريف | المستوى: متوسط