Faculty of Artificial Intelligence

Artificial Intelligence

Level 1
Semester 2

Developed by Ahmed Gomaa & Mohamed Eldemery

Explore
AI · Lectures 1–7
● Live
🧠
Intro to AI
الذكاء الاصطناعي
7Lectures
7Quizzes
231Questions
Open Lectures
DB · Lectures 1–7
● Live
🗄️
Database Management
إدارة قواعد البيانات
7Lectures
7Quizzes
140Questions
Open Lectures
Java · Lectures 1–11
● Live
Structure Programming
البرمجة الهيكلية
11Lectures
11Quizzes
371Questions
Open Lectures
BAS 126 · Lectures 1–5
● Live
Discrete Mathematics
الرياضيات المتقطعة
5Lectures
5Quizzes
110Questions
Open Lectures
BAS 123 · Lectures 1–6
● Live
📊
Probability & Statistics
الاحتمالات والإحصاء
7Lectures
6Quizzes
120Questions
Open Lectures
IT · GEN001 · Lectures 1–8
● Live
🖥️
Information Technology
تقنية المعلومات
8Lectures
8Quizzes
160Questions
Open Lectures
ENG · Level 1
● Live
📖
English II
اللغة الإنجليزية ٢
3Units
1Bank
120Questions
Open Question Bank
Introduction to Artificial Intelligence
Lectures 1–7 · Dr. Reham Elsheikh
Spring 2026 • Dr. Reham Elsheikh

Introduction to Artificial Intelligence

Lectures 1–8  |  مقدمة في الذكاء الاصطناعي — محاضرات ١–٨

What is Intelligence? | ما هو الذكاء؟
🇬🇧 English

Intelligence is the capacity to adapt, solve problems, and learn. Alfred Binet described it as "good sense, practical sense, initiative, and the faculty of adapting to circumstances."

Three core abilities:

  • Solve novel problems
  • Act rationally
  • Act like humans
🇪🇬 العربية

الذكاء هو القدرة على التكيف وحل المشكلات والتعلم. وصفه ألفريد بينيه بأنه "الحكمة، والتكيف مع الظروف، ونقد الذات."

ثلاث قدرات جوهرية:

  • حل المشكلات الجديدة
  • التصرف بعقلانية
  • التصرف مثل البشر
"The capacity to learn and solve problems." — Webster's Dictionary
"القدرة على التعلم وحل المشكلات." — قاموس ويبستر
What is Artificial Intelligence? | ما هو الذكاء الاصطناعي؟
🇬🇧 English

AI was born at the Dartmouth Workshop (1956). Key definitions:

Alan Turing (1950)

"Can machines think?" — founding question.

John McCarthy (1956)

CS branch making computers behave like humans. Invented LISP.

Marvin Minsky

Making machines do things requiring intelligence if done by humans.

4 Main Approaches

Acting/Thinking Humanly or Rationally.

🇪🇬 العربية

وُلد الذكاء الاصطناعي في ورشة دارتموث 1956. أبرز التعريفات:

آلان تورينج (1950)

"هل تستطيع الآلات التفكير؟" — السؤال التأسيسي.

جون مكارثي (1956)

فرع علوم الحاسوب لجعل الحاسبات تتصرف كالبشر. اخترع LISP.

مارفن مينسكي

علم جعل الآلات تؤدي مهاماً تتطلب ذكاءً لو أدّاها الإنسان.

٤ مناهج رئيسية

التصرف/التفكير كالإنسان أو بعقلانية.

The Turing Test & Chinese Room | اختبار تورينج وحجة الغرفة الصينية
🇬🇧 English

A computer passes if a human interrogator can't distinguish it from a human after written questions. Requirements: NLP, Knowledge Representation, Automated Reasoning, Machine Learning.

Total Turing Test adds: Computer Vision + Robotics.

Chinese Room (Searle): a system can produce correct output without truly understanding → debate: Weak AI vs Strong AI.

🇪🇬 العربية

يجتاز الحاسوب الاختبار إذا لم يستطع المحقق البشري التمييز بين ردوده وردود الإنسان. المتطلبات: معالجة اللغة، تمثيل المعرفة، الاستدلال الآلي، التعلم الآلي.

الاختبار الكلي يضيف: رؤية الحاسوب + الروبوتيات.

الغرفة الصينية (سيرل): الآلة تُنتج ردوداً صحيحة دون فهم حقيقي ← جدل الذكاء الضعيف مقابل الذكاء القوي.

Three Stages of AI | المراحل الثلاثة للذكاء الاصطناعي
🇬🇧 English

ANI — Narrow AI

Current stage. Specialized in one task (chess, voice assistants).

AGI — General AI

Future. Performs any intellectual task a human can.

ASI — Super AI

Hypothetical. Surpasses humans in every domain.

Supporting fields

Philosophy, Maths, Neuroscience, Psychology, Economics, CS, Linguistics, Control Theory.

🇪🇬 العربية

ANI — الذكاء الضيق

المرحلة الحالية. متخصص في مهمة واحدة (شطرنج، مساعد صوتي).

AGI — الذكاء العام

مستقبلي. قادر على أداء أي مهمة فكرية بشرية.

ASI — الذكاء الخارق

افتراضي. يتفوق على الإنسان في كل المجالات.

المجالات الداعمة

الفلسفة، الرياضيات، علم الأعصاب، النفس، الاقتصاد، الحاسوب، اللغويات، التحكم.

ملخص المحاضرة الأولى — للمذاكرة الجادة

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🧠 ١. الذكاء: Alfred Binet = حكم عملي + تكيف + نقد ذات | Webster = التعلم وحل المشكلات

🏛️ ٢. ورشة دارتموث 1956: ميلاد مصطلح AI | Turing 1950: "هل تفكر الآلات؟" | McCarthy: اخترع AI + LISP

🔲 ٣. الأربع مناهج: Acting Humanly (تورينج) | Thinking Humanly (معرفي) | Thinking Rationally (منطق) | Acting Rationally (وكيل عقلاني)

🎮 ٤. اختبار تورينج: محقق لا يفرق بين الإنسان والآلة = نجاح | يحتاج: NLP + KR + AR + ML | الكلي يضيف: CV + Robotics

🚪 ٥. الغرفة الصينية (Searle): ردود صحيحة بدون فهم = نقد لتورينج | Weak AI = محاكاة | Strong AI = وعي حقيقي

📈 ٦. المراحل: ANI (الآن) ← متخصص | AGI (مستقبل) ← عام | ASI (افتراضي) ← خارق

Quiz — Lecture 1
35 سؤال — اختر الإجابة الصحيحة. الشرح بالعربي بعد كل إجابة.
0/35
Quiz Complete! 🎉
Intelligent Agents | الوكلاء الأذكياء
🇬🇧 English

An agent perceives its environment through sensors and acts through actuators. Agent function: f: P* → A

Human Agent

Sensors: eyes, ears, nose, skin
Actuators: hands, legs, mouth

Robotic Agent

Sensors: cameras, infrared
Actuators: motors, wheels

Software Agent

Sensors: keystrokes, files
Actuators: screen, file writes

Cycle

Sense → Reason → Act → Feedback → Learn

🇪🇬 العربية

الوكيل يُدرك بيئته عبر المستشعرات ويتصرف فيها عبر المشغّلات. دالة الوكيل: f: P* → A

الوكيل البشري

المستشعرات: عيون، آذان، أنف، جلد
المشغّلات: يدان، رجلان، فم

الوكيل الروبوتي

المستشعرات: كاميرات، أشعة تحت حمراء
المشغّلات: محركات، عجلات

الوكيل البرمجي

المستشعرات: ضغطات، ملفات
المشغّلات: عرض الشاشة، كتابة الملفات

دورة الوكيل

الإحساس ← الاستدلال ← التصرف ← التغذية الراجعة ← التعلم

PEAS Framework | إطار PEAS
🇬🇧 English

Performance · Environment · Actuators · Sensors

Autonomous Taxi example:

  • P: Safe, fast, legal, comfortable trip; maximize profits
  • E: Roads, traffic, pedestrians, customers
  • A: Steering wheel, accelerator, brake, horn
  • S: Cameras, LIDAR, GPS, speedometer
🇪🇬 العربية

P = الأداء · E = البيئة · A = المشغّلات · S = المستشعرات

مثال سيارة الأجرة الذاتية:

  • P: رحلة آمنة وسريعة وقانونية ومريحة، تعظيم الأرباح
  • E: الطرق، المركبات الأخرى، المشاة، الركاب
  • A: عجلة قيادة، مسرّع، فرامل، بوق
  • S: كاميرات، LiDAR، GPS، مقياس السرعة
Environment Properties (ODESDA) | خصائص البيئة (ODESDA)
🇬🇧 English

Observable ↔ Partial

Can the agent see the full state?

Deterministic ↔ Stochastic

Is next state fully determined by current state + action?

Episodic ↔ Sequential

Are decisions independent of each other?

Static ↔ Dynamic

Does the world change while agent thinks?

Discrete ↔ Continuous

Are percepts/actions countable?

Single ↔ Multi-Agent

Is the agent operating alone?

🇪🇬 العربية

مرئية ↔ جزئية

هل يرى الوكيل الحالة الكاملة دائماً؟

حتمية ↔ عشوائية

هل الحالة التالية تتحدد بالكامل؟

متقطعة ↔ متسلسلة

هل القرارات مستقلة عن بعضها؟

ثابتة ↔ ديناميكية

هل يتغير العالم بينما يفكر الوكيل؟

منفصلة ↔ مستمرة

هل الإدراكات قابلة للعدّ؟

وكيل ↔ متعدد

هل يعمل الوكيل بمفرده؟

The real world is: partially observable, stochastic, sequential, dynamic, continuous, multi-agent — the hardest!
العالم الحقيقي: مرئي جزئياً + عشوائي + متسلسل + ديناميكي + مستمر + متعدد الوكلاء — الأصعب!

ملخص المحاضرة الثانية

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🤖 الوكيل: يُدرك (sensors) → يستدل → يتصرف (actuators) | دالة الوكيل: f: P* → A

📋 PEAS: P=الأداء | E=البيئة | A=المشغّلات | S=المستشعرات | مثال: سيارة الأجرة الذاتية

🌍 خصائص البيئة ODESDA: Observable / Deterministic / Episodic / Static / Discrete / Single-agent

📊 أمثلة: Chess = Fully+Strategic+Sequential+Semi-dyn+Discrete+Multi | Driving = Partially+Stochastic+Sequential+Dynamic+Continuous+Multi

الخلاصة: نوع البيئة هو الذي يحدد تصميم الوكيل بشكل كبير

Quiz — Lecture 2
35 سؤال — اختر الإجابة الصحيحة. الشرح بالعربي بعد كل إجابة.
0/35
Quiz Complete! 🎉
The Four Basic Agent Types | الأنواع الأربعة الأساسية للوكلاء
🇬🇧 English

1. Simple Reflex

Current percept only. Condition-action rules. No memory. Fully observable. May loop.

2. Model-Based Reflex

Maintains internal world model. Handles partial observability. = Simple + Memory + Model.

3. Goal-Based

Has goal info. Plans actions. Considers future consequences. More flexible.

4. Utility-Based

Uses utility function. Maximizes expected happiness. Handles conflicting goals.

Learning Agent: improves over time via feedback. Components: Performance Element + Critic + Learning Element + Problem Generator.

🇪🇬 العربية

١. المنعكس البسيط

الإدراك الحالي فقط. قواعد شرط-فعل. لا ذاكرة. Fully Observable فقط. قد يقع في حلقات.

٢. القائم على النموذج

يحتفظ بنموذج داخلي للعالم. يتعامل مع Partially Observable. = منعكس + ذاكرة + نموذج.

٣. القائم على الهدف

لديه معلومات عن الهدف. يخطط. يأخذ عواقب الأفعال المستقبلية. أكثر مرونة.

٤. القائم على المنفعة

يستخدم دالة منفعة. يعظّم السعادة المتوقعة. يحل تعارض الأهداف.

الوكيل التعلمي: يحسّن أداءه بمرور الوقت. مكوناته: عنصر الأداء + الناقد + عنصر التعلم + مولد المشكلات.

Chess Example & Agent Hierarchy | مثال الشطرنج والتسلسل الهرمي
🇬🇧 English
  • Simple Reflex: Limited — some moves need memory (castling)
  • Model-Based: Better — but needs future reasoning
  • Goal-Based: Good — but conflicting goals (attack vs defense)?
  • Utility-Based: Best — balances all goals simultaneously

Hierarchy (least → most capable):
Simple Reflex → Model-Based → Goal-Based → Utility-Based → Learning Agent

🇪🇬 العربية
  • المنعكس البسيط: محدود — بعض الحركات تحتاج ذاكرة (القلعة)
  • القائم على النموذج: أفضل — لكنه يحتاج الاستدلال عن المستقبل
  • القائم على الهدف: جيد — لكن ماذا عن تعارض الهجوم والدفاع؟
  • القائم على المنفعة: الأفضل — يوازن بين كل الأهداف في آنٍ واحد

التسلسل من الأبسط للأذكى:
منعكس بسيط → نموذج → هدف → منفعة → تعلّمي

ملخص المحاضرة الثالثة

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🤖 Simple Reflex: لا ذاكرة | الحاضر فقط | Fully Observable | قد يدور في حلقات | الحل: Randomization

🧠 Model-Based: ذاكرة + نموذج داخلي | Partially Observable | لكن بدون هدف واضح

🎯 Goal-Based: يخطط + يبحث | يفكر في المستقبل | مرن | الأهداف المتضاربة مشكلة

⚖️ Utility-Based: يوازن الأهداف | يختار الأعلى قيمة | الأكثر قدرة | يحتاج دالة منفعة جيدة

📚 Learning Agent: Performance + Critic + Learning Element + Problem Generator

📈 التسلسل: Simple → Model → Goal → Utility → Learning (كل مرحلة تضيف قدرة جديدة)

Quiz — Lecture 3
35 سؤال — اختر الإجابة الصحيحة. الشرح بالعربي بعد كل إجابة.
0/35
Quiz Complete! 🎉
What is Search? — 5 Problem Components | ما هو البحث؟ — ٥ مكونات المشكلة
🇬🇧 English

We design goal-based agents in environments that are fully observable, deterministic, discrete, known.

A problem is defined by 5 items:

1. Initial State

The starting state of the agent.

2. Actions

Set of possible actions available.

3. Transition Model

What each action does (Successor function).

4. Goal Test

Is the current state the goal?

5. Path Cost

Numeric cost of each path (usually 1/step).

Examples

Vacuum: L/R/Suck | N-Puzzle: move blank | Hanoi: move disk

🇪🇬 العربية

نصمم وكلاء قائمة على الهدف في بيئات مرئية بالكامل + حتمية + منفصلة + معروفة.

المشكلة تُعرَّف بـ ٥ عناصر:

١. الحالة الابتدائية

نقطة البداية للوكيل.

٢. الأفعال

مجموعة الأفعال المتاحة.

٣. نموذج الانتقال

نتيجة كل فعل (دالة الخلف).

٤. اختبار الهدف

هل الحالة الحالية هي الهدف؟

٥. تكلفة المسار

تكلفة رقمية لكل مسار (عادةً ١/خطوة).

أمثلة

مكنسة: يسار/يمين/امتصاص | N-Puzzle: تحريك الفراغ | هانوي: نقل قرص

Search Strategy Evaluation | تقييم استراتيجيات البحث
🇬🇧 English

State = physical configuration of world | Node = data structure (state + parent + action + g(n) + depth)

Strategies evaluated by: Completeness, Time Complexity, Space Complexity, Optimality

Key parameters: b = branching factor · d = depth of shallowest solution · m = max depth

Uninformed (Blind): BFS, UCS, DFS, DLS, IDS, BS — no extra info.
Informed (Heuristic): A*, Greedy — uses domain knowledge.

🇪🇬 العربية

الحالة (State) = تكوين جسدي للعالم | العقدة (Node) = هيكل بيانات (حالة + أم + فعل + g(n) + عمق)

معايير التقييم: الاكتمال، التعقيد الزمني، التعقيد المكاني، الأمثلية

المعاملات: b = معامل التفرع · d = عمق أضحل حل · m = الحد الأقصى للعمق

أعمى (Uninformed): BFS, UCS, DFS, DLS, IDS, BS — بدون معلومات إضافية.
إرشادي (Informed): A*، Greedy — يستغل معرفة بالمجال.

ملخص المحاضرة الرابعة

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🔍 البحث = إيجاد تسلسل أفعال من الحالة الابتدائية للهدف في بيئة: Fully + Deterministic + Discrete + Known

📋 ٥ مكونات: Initial State | Actions | Transition Model | Goal Test | Path Cost

⚖️ ٤ معايير تقييم: Completeness | Time Complexity | Space Complexity | Optimality

📐 المعاملات: b = معامل التفرع | d = عمق أضحل حل | m = الحد الأقصى | g(n) = تكلفة المسار

🔀 نوعا البحث: Blind (بدون معرفة) ← BFS/UCS/DFS/DLS/IDS | Informed (بمعرفة) ← A*/Greedy

Quiz — Lecture 4
35 سؤال — اختر الإجابة الصحيحة. الشرح بالعربي بعد كل إجابة.
0/35
Quiz Complete! 🎉
Breadth-First Search (BFS) | البحث بالعرض أولاً (BFS)
🇬🇧 English

Strategy: Always expand the shallowest unexpanded node.
Data structure: FIFO Queue.

PropertyBFSNotes
Complete?YesIf b is finite
Time?O(bd)Exponential in d
Space?O(bd)Keeps ALL nodes in memory!
Optimal?YesOnly if all step costs = 1
🇪🇬 العربية

الاستراتيجية: دايماً يوسِّع أضحل عقدة غير موسَّعة.
هيكل البيانات: FIFO Queue.

الخاصيةBFSملاحظة
اكتمال؟نعملو b محدودة
الزمن؟O(bd)أسي في d
المساحة؟O(bd)بيحتفظ بكل العقد في الذاكرة!
أمثل؟نعمبس لو تكلفة كل خطوة = ١
Space is BFS's main problem. With b=10, d=12: ~111 terabytes needed!
المساحة هي المشكلة الرئيسية لـ BFS. مع b=10 و d=12: ~١١١ تيرابايت!
Uniform-Cost Search (UCS) | البحث بالتكلفة الموحدة (UCS)
🇬🇧 English

Strategy: Expand least-cost unexpanded node.
Data structure: Priority Queue ordered by g(n).
C* = optimal cost · ε = min step cost.

PropertyUCSNotes
Complete?YesIf g > ε
Time?O(bC*/ε)All nodes with cost ≤ C*
Space?O(bC*/ε)Same as time
Optimal?YesAlways finds cheapest path
🇪🇬 العربية

الاستراتيجية: يوسِّع أقل تكلفة عقدة غير موسَّعة.
هيكل البيانات: Priority Queue مرتَّب بـ g(n).
C* = تكلفة الحل الأمثل · ε = الحد الأدنى لتكلفة خطوة.

الخاصيةUCSملاحظة
اكتمال؟نعملو g > ε
الزمن؟O(bC*/ε)كل العقد بتكلفة ≤ C*
المساحة؟O(bC*/ε)نفس الزمن
أمثل؟نعمدايماً يلاقي أرخص مسار
UCS = BFS when all step costs are equal. UCS is always optimal; BFS is optimal only when costs = 1.
UCS يساوي BFS لو كل التكاليف متساوية. UCS أمثل دائماً؛ BFS أمثل بس لو التكاليف = ١.
🔍 In-Depth: BFS — Breadth-First Search | شرح تفصيلي — البحث بالاتساع
📌 Strategy

BFS searches level by level — visits all nodes at depth 0 first, then depth 1, then depth 2, etc. Uses a FIFO Queue: new nodes added at the back, processed from the front.


⚙ How it works:

  • Add root node to the Queue
  • Remove front node, check if it's the goal
  • If not — add all its children to the Queue
  • Repeat until goal found or Queue is empty

✅ Pros / ❌ Cons:

  • Complete: always finds solution if it exists
  • Optimal: finds shortest path (equal costs)
  • Huge memory: keeps all nodes of current level
  • Very slow in deep trees
📌 الاستراتيجية

تبحث BFS عن الحل مستوى بمستوى — تزور جميع عقد العمق 0 أولاً، ثم عمق 1، ثم عمق 2، وهكذا. تعتمد على Queue (طابور FIFO): تُضاف العقد الجديدة في النهاية وتُعالج من البداية.


⚙ آلية العمل:

  • ابدأ بإضافة العقدة الجذر للـ Queue
  • أخرج العقدة الأمامية (Front)، تحقق هل هي الهدف؟
  • إذا لا — أضف جميع أبنائها للـ Queue
  • كرر حتى تجد الهدف أو ينتهي الـ Queue

✅ المزايا / ❌ العيوب:

  • Complete: تجد الحل دائماً إذا وُجد
  • Optimal: تجد أقصر مسار (بالتكاليف المتساوية)
  • ذاكرة ضخمة: تحتفظ بجميع عقد المستوى الحالي
  • بطيئة جداً في الأشجار العميقة
🌳 Graph-Based Logic — ترتيب زيارة العقد (Level by Level)
L0 L1 L2 A B C D E F G

ترتيب الزيارة: A①→ B②→ C③→ D④→ E⑤→ F⑥→ G⑦  |  Queue (FIFO)

A
B
C
D
E
F
G
🔍 In-Depth: UCS — Uniform Cost Search | شرح تفصيلي — البحث بالتكلفة الموحدة
📌 Strategy

Modified BFS that considers edge weights (costs). Always processes the node with lowest cumulative cost g(n). Uses a Priority Queue (Min-Heap).


⚙ How it works:

  • Insert root with cost 0 in Priority Queue
  • Extract node with lowest g(n)
  • Check if goal — if yes, done
  • Add children with g(n) = g(parent) + cost(edge)
  • If a node has two paths, keep the cheaper one

✅ Pros / ❌ Cons:

  • Always Optimal: always finds cheapest path
  • Complete: as long as costs are positive
  • ❌ Large memory (like BFS)
  • ❌ Slow if step costs are very small
📌 الاستراتيجية

نسخة معدّلة من BFS تأخذ أوزان الحواف (Edge Costs) بعين الاعتبار. تعالج دائماً العقدة ذات أقل تكلفة تراكمية g(n). تستخدم Priority Queue (Min-Heap).


⚙ آلية العمل:

  • أدخل الجذر بتكلفة 0 في الـ Priority Queue
  • أخرج العقدة ذات أقل g(n)
  • تحقق هل هي الهدف؟ إذا نعم — انتهى
  • أضف أبناءها مع تحديث g(n) = g(parent) + cost(edge)
  • إذا وُجدت عقدة بمسارين، احتفظ بالأرخص

✅ المزايا / ❌ العيوب:

  • Optimal تماماً: تجد أقل تكلفة دائماً
  • Complete: طالما التكاليف موجبة
  • ❌ ذاكرة كبيرة (مثل BFS)
  • ❌ بطيئة إذا كانت التكاليف صغيرة جداً
🌳 Graph-Based Logic — أقل تكلفة تراكمية أولاً (Priority Queue)
2 5 1 3 ① g=0 ② g=2 ③ g=3 ④ g=5 ④ g=5 A (0) B (2) C (5) D (3) E (5)

ترتيب المعالجة: A(0) → B(2) → D(3) → C(5) ≡ E(5)  |  الأرقام = g(n) التكلفة التراكمية

ملخص المحاضرة ٥–٦ (BFS & UCS)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🌊 BFS: FIFO Queue | دايماً أضحل عقدة | Complete ✅ | Time O(b^d) | Space O(b^d) ❌ | Optimal ✅ (تكاليف متساوية)

💰 UCS: Priority Queue بـ g(n) | دايماً أرخص عقدة | Complete ✅ | Time O(b^(C*/ε)) | Optimal ✅ دائماً

📊 مقارنة: UCS = BFS لو تكاليف متساوية | BFS أبسط | UCS أدق مع تكاليف مختلفة

📱 تطبيقات BFS: GPS Navigation | شبكات P2P | الشبكات الاجتماعية | MIMO

⚠️ المشكلة الكبرى لـ BFS: المساحة! b=10, d=12 ← 111 تيرابايت

DFS & DLS | البحث بالعمق أولاً والمحدود
🇬🇧 English

DFS: Always expand deepest node. LIFO Stack.

DFSDLS (limit L)
Complete?NoNo (if d>L)
Time?O(bm)O(bL)
Space?O(b·m)O(b·L)
Optimal?NoNo

DLS = DFS with depth limit L. Solves infinite-depth problem of DFS but fails if d > L.

🇪🇬 العربية

DFS: دايماً يوسِّع أعمق عقدة. LIFO Stack.

DFSDLS (حد L)
اكتمال؟لالا (لو d>L)
الزمن؟O(bm)O(bL)
المساحة؟O(b·m)O(b·L)
أمثل؟لالا

DLS = DFS مع حد عمق L. يحل مشكلة العمق اللانهائي لكن يفشل لو d > L.

DFS's big advantage: Space O(b·m) vs BFS's O(b^d) — much more memory-efficient!
الميزة الكبرى لـ DFS: المساحة O(b·m) مقارنة بـ O(b^d) لـ BFS — أكثر كفاءة بكثير!
IDS & Bidirectional Search | البحث التكراري المتعمق والثنائي الاتجاه
🇬🇧 English

IDS: Repeatedly apply DLS with increasing L = 0, 1, 2, … until goal found. Combines BFS completeness + DFS space efficiency.

Bidirectional (BS): Run BFS forward from START and backward from GOAL simultaneously. Meet in the middle!

IDSBS
Complete?YesYes*
Time?O(bd)O(bd/2) ✅✅
Space?O(b·d)O(bd/2)
Optimal?Yes*Yes*
🇪🇬 العربية

IDS: يكرر DLS مع حد متزايد L = 0, 1, 2, … لحد ما يلاقي الهدف. يجمع اكتمال BFS + كفاءة مساحة DFS.

الثنائي (BS): يشغِّل BFS للأمام من البداية + BFS للخلف من الهدف في آنٍ واحد. الحل لما يلتقوا في المنتصف!

IDSBS
اكتمال؟نعمنعم*
الزمن؟O(bd)O(bd/2) ✅✅
المساحة؟O(b·d)O(bd/2)
أمثل؟نعم*نعم*
BS example: d=12, b=10 → BFS needs 10¹² = 1 trillion nodes. BS needs only 2×10⁶ = 2 million!
مثال BS: d=12, b=10 → BFS محتاج تريليون عقدة. BS محتاج بس مليونين!
Complete Comparison — All Algorithms | الجدول الشامل — كل الخوارزميات
🇬🇧 English
AlgorithmComplete?TimeSpaceOptimal?
BFSYes*O(b^d)O(b^d)Yes*
UCSYes*O(b^(C*/ε))O(b^(C*/ε))Yes
DFSNoO(b^m)O(b·m)No
DLSNoO(b^L)O(b·L)No
IDSYes*O(b^d)O(b·d)Yes*
BSYes*O(b^(d/2))O(b^(d/2))Yes*

* = if b finite and step costs equal

🇪🇬 العربية
الخوارزميةاكتمال؟الزمنالمساحةأمثل؟
BFSنعم*O(b^d)O(b^d)نعم*
UCSنعم*O(b^(C*/ε))O(b^(C*/ε))نعم
DFSلاO(b^m)O(b·m)لا
DLSلاO(b^L)O(b·L)لا
IDSنعم*O(b^d)O(b·d)نعم*
BSنعم*O(b^(d/2))O(b^(d/2))نعم*

* = لو b محدودة وتكاليف متساوية

🔍 In-Depth: DFS — Depth-First Search | شرح تفصيلي — البحث بالعمق الأول
📌 Strategy

DFS dives as deep as possible into one branch before backtracking. Uses a Stack (LIFO) or recursive calls.


⚙ How it works:

  • Insert root into the Stack
  • Pop node from top
  • Check if goal — if not, push children to Stack
  • Continue until goal found or Stack empty
  • If loop detected — may run forever (incomplete!)

✅ Pros / ❌ Cons:

  • Low memory: O(b·m) — much better than BFS
  • ✅ Fast if solution is deep/left in the tree
  • Incomplete: may loop forever
  • Not optimal: first solution found may not be best
📌 الاستراتيجية

تغوص DFS لأعمق نقطة ممكنة في فرع واحد قبل الرجوع (Backtracking). تعتمد على Stack (LIFO) أو الاستدعاء التكراري (Recursion).


⚙ آلية العمل:

  • أدخل العقدة الجذر في الـ Stack
  • أخرج العقدة من القمة (Top)
  • تحقق هل هي الهدف؟ إذا لا — أضف أبناءها للـ Stack
  • يستمر حتى يجد الهدف أو ينتهي الـ Stack
  • إذا وجد حلقة — قد يدور إلى الأبد (غير مكتملة)

✅ المزايا / ❌ العيوب:

  • ذاكرة قليلة: O(b·m) فقط — أفضل بكثير من BFS
  • ✅ سريعة إذا كان الحل في اليسار/الأعمق
  • غير مكتملة: قد تدور في حلقات
  • غير مثلى: أول حل تجده ليس بالضرورة الأفضل
🌳 Graph-Based Logic — الغوص لأسفل أولاً (Stack LIFO)
A B C D E F G H I

ترتيب DFS: A①→B②→D③→H④→I⑤→E⑥→C⑦→F⑧→G⑨  |  ينزل لأقصى عمق ثم يرجع (Backtrack)

A
B
D
H
I
E
C
F
G
🔍 In-Depth: DLS — Depth-Limited Search | شرح تفصيلي — البحث بالعمق المحدود
📌 Strategy

Modified DFS that adds a maximum depth limit L. Stops expanding at depth L even if goal not found. Solves DFS's infinite-loop problem.


⚙ How it works:

  • Works exactly like DFS
  • If node depth = L, don't expand it
  • Returns: solution or "Cutoff" (not found within L)
  • If goal is deeper than L → won't find it

✅ Pros / ❌ Cons:

  • ✅ Solves infinite-loop problem
  • ✅ Linear memory O(b·L)
  • Incomplete: if solution is deeper than L
  • Not optimal
  • ❌ Wrong choice of L loses the solution
📌 الاستراتيجية

نسخة معدّلة من DFS تضيف حداً أقصى للعمق L. عند الوصول للعمق L، تتوقف عن التوسع حتى لو لم تجد الهدف. تحل مشكلة الحلقات اللانهائية في DFS.


⚙ آلية العمل:

  • تعمل مثل DFS تماماً
  • إذا وصلت لعقدة عمقها = L، لا توسّعها
  • ترجع نتيجتين: الحل أو "Cutoff" (لم يوجد ضمن L)
  • إذا كان الهدف أعمق من L → لن تجده

✅ المزايا / ❌ العيوب:

  • ✅ تحل مشكلة الحلقات اللانهائية
  • ✅ ذاكرة خطية O(b·L)
  • غير مكتملة: إذا كان الحل أعمق من L
  • غير مثلى
  • ❌ اختيار L الخاطئ يُضيّع الحل
🌳 Graph-Based Logic — DFS مع حد عمق L=2
d=0 d=1 d=2=L LIMIT A B C D E F G STOP GOAL✓ STOP STOP

عند L=2: العقد D,F,G = STOP (Cutoff) — لا تُوسَّع  |  E = GOAL Found ✓

🔍 In-Depth: IDS — Iterative Deepening Search | شرح تفصيلي — البحث بالتعمق التدريجي
📌 Strategy

Combines best of BFS and DFS: repeatedly applies DLS with increasing limit L = 0, 1, 2, 3… until goal found. Guarantees BFS completeness + DFS memory efficiency.


⚙ How it works:

  • Start with L = 0: apply DLS(L=0)
  • If Cutoff → increment L by 1
  • Apply DLS(L=1) → if Cutoff → L=2
  • Repeat until solution is found
  • Yes, revisits previous nodes — but that's acceptable!

✅ Pros / ❌ Cons:

  • Complete like BFS
  • Low memory like DFS: O(b·d)
  • Optimal (equal costs)
  • ❌ Revisits upper-level nodes (acceptable overhead)
  • ❌ Slightly slower than BFS due to revisits
📌 الاستراتيجية

تجمع IDS أفضل ما في BFS وDFS: تُطبّق DLS بشكل متكرر مع زيادة الحد L = 0, 1, 2, 3, … حتى تجد الحل. تضمن اكتمال BFS وذاكرة DFS.


⚙ آلية العمل:

  • ابدأ بـ L = 0: طبّق DLS(L=0)
  • إذا Cutoff → زد L بمقدار 1
  • طبّق DLS(L=1) → إذا Cutoff → L=2
  • كرر حتى تجد الحل
  • نعم، تُعيد زيارة عقد سابقة — لكن هذا مقبول!

✅ المزايا / ❌ العيوب:

  • Complete مثل BFS
  • ذاكرة قليلة مثل DFS: O(b·d)
  • Optimal (تكاليف متساوية)
  • ❌ تُعيد زيارة عقد المستويات السابقة (overhead مقبول)
  • ❌ أبطأ قليلاً من BFS (بسبب الإعادة)
🌳 Graph-Based Logic — التعمق التدريجي (كل iteration تبدأ من الجذر بعمق أكبر)
L=0 L=1 L=2 A → Cutoff A B C → Cutoff A B C D E F G GOAL ✓ → Found! كل iteration تعيد البناء من A — لكن دائماً ستصل للحل في النهاية ✓
L=2:
A
B
D
E
✓ GOAL
🔍 In-Depth: BS — Bidirectional Search | شرح تفصيلي — البحث ثنائي الاتجاه
📌 Strategy

Runs two BFS searches simultaneously: one forward from Start, one backward from Goal. Ends when the two searches meet in the middle.


⚙ How it works:

  • Create forward Queue (from Start) + backward Queue (from Goal)
  • Each step: expand one forward + one backward
  • After each expansion: check if frontiers meet
  • When they meet: merge the two paths for complete solution

✅ Pros / ❌ Cons:

  • Very efficient: O(bd/2) instead of O(bd)
  • Massive savings: b=10, d=6 → BFS: 1M nodes, BS: 2000 only!
  • ❌ Requires knowing the goal in advance
  • ❌ Complex to implement (managing two searches)
  • ❌ Needs reverse operators
📌 الاستراتيجية

تُشغّل بحثين BFS في نفس الوقت: الأول من البداية (Start) للأمام، والثاني من الهدف (Goal) للخلف. تنتهي عندما يلتقي البحثان في منتصف الطريق.


⚙ آلية العمل:

  • أنشئ Queue أمامية (من Start) وQueue خلفية (من Goal)
  • في كل خطوة: وسّع بحثاً من الأمام + بحثاً من الخلف
  • بعد كل توسع: تحقق هل التقت الحدود؟
  • عند الالتقاء: ادمج المسارين للحصول على الحل الكامل

✅ المزايا / ❌ العيوب:

  • فعّال جداً: O(bd/2) بدلاً من O(bd)
  • توفير هائل: b=10, d=6 → BFS: مليون عقدة, BS: 2000 فقط!
  • ❌ يتطلب معرفة الهدف مسبقاً
  • ❌ معقد في التطبيق (إدارة بحثين)
  • ❌ يحتاج عمليات عكسية (Reverse Operators)
🌳 Graph-Based Logic — BFS من البداية والهدف في نفس الوقت
A B C D E F START → Z X Y V W U ← GOAL MEET HERE الحل = مسار A→..→MEET + MEET→..→Z ✓

Forward BFS (من A) + Backward BFS (من Z) يلتقيان في المنتصف  |  توفير: O(bd/2) بدلاً من O(bd)

ملخص المحاضرة ٧–٨ (DFS, DLS, IDS, BS)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⬇️ DFS: LIFO Stack | أعمق عقدة | Complete ❌ | Time O(b^m) | Space O(b·m) ✅ | Optimal ❌

🔢 DLS: DFS + حد L | Complete ❌ (لو d>L) | Time O(b^L) | Space O(b·L) ✅ | Optimal ❌

🔄 IDS: يكرر DLS مع L متزايد | Complete ✅ | Time O(b^d) | Space O(b·d) ✅ | Optimal ✅

↔️ BS: BFS من البداية + BFS من الهدف | Complete ✅ | Time O(b^(d/2)) ✅✅ | Optimal ✅

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🏆 IDS = الأفضل شاملاً (كامل + أمثل + مساحة جيدة) | BS = الأسرع زمنياً

📊 Master Reference Table — All 6 Algorithms | جدول المقارنة الشامل — الخوارزميات الست
دليل الاختيار السريع:
🔵 BFS: أقصر مسار + تكاليف متساوية + ذاكرة كافية
🟢 UCS: أرخص مسار + تكاليف مختلفة
🔴 DFS: ذاكرة محدودة جداً + لا يهمك الأمثلية
🟠 DLS: تعرف الحد الأقصى للعمق مسبقاً
🟣 IDS: أفضل خوارزمية عامة في معظم الحالات ✨
🟡 BS: تعرف الهدف + d كبير + تريد السرعة
Algorithm Strategy / الاستراتيجية Data Structure Complete? Time Space Optimal?
BFS
Breadth-First Search
مستوى بمستوى
Level by Level
Queue (FIFO) ✓ Complete O(bd) O(bd) ✓ Optimal*
UCS
Uniform Cost Search
أقل تكلفة تراكمية
Min Cumulative Cost
Priority Queue
(Min-Heap)
✓ Complete O(b1+⌊C*/ε⌋) O(b1+⌊C*/ε⌋) ✓ Optimal
DFS
Depth-First Search
أعمق أولاً
Deepest First
Stack (LIFO) ✗ Incomplete O(bm) O(b·m) ✅ ✗ Not Optimal
DLS
Depth-Limited Search
DFS مع حد عمق L
DFS with Depth Limit
Stack (LIFO) ~ Incomplete* O(bL) O(b·L) ✅ ✗ Not Optimal
IDS
Iterative Deepening Search
DLS متكررة بزيادة العمق
Repeated DLS L=0,1,2…
Stack (LIFO) ✓ Complete O(bd) O(b·d) ✅ ✓ Optimal* ✨
BS
Bidirectional Search
BFS من البداية والهدف
Simultaneous BFS
Queue × 2
(FIFO)
~ Conditional O(bd/2) ✅✅ O(bd/2) ~ Conditional
Legend / المصطلحات:   b = branching factor (عدد الفروع من كل عقدة)  |  d = depth of shallowest goal (عمق أقرب هدف)  |  m = max depth of tree  |  L = depth limit  |  C* = optimal cost · ε = min edge cost  |  * = if b finite & step costs equal
Quiz — Lectures 7–8 (DFS, DLS, IDS, BS)
35 سؤال — اختر الإجابة الصحيحة. الشرح بالعربي بعد كل إجابة.
0/35
Quiz Complete! 🎉
What is a Heuristic? — ما هي الـ Heuristic؟ | المعلومة الإرشادية
🇬🇧 English

A heuristic h(n) is extra information used by the search algorithm beside the problem definition. It estimates the cost from node n to the goal — it is not the actual cost, just an optimistic expectation.


Key idea: Uninformed search is blind — it expands nodes without knowing which direction the goal is. Informed search uses h(n) to guide the search toward the goal more efficiently.

h(n) = estimated cost from n to goal  (optimistic — never overestimates)
🇪🇬 العربية

الـ heuristic h(n) هي معلومة إضافية بيستخدمها خوارزمية البحث جنب تعريف المشكلة. بتقدّر التكلفة من العقدة n للهدف — مش التكلفة الحقيقية، بس توقع متفائل.


الفكرة الجوهرية: البحث الأعمى (uninformed) مش بيعرف الهدف فين. البحث الموجّه بيستخدم h(n) يوجّه البحث ناحية الهدف بكفاءة أعلى.

h(n) = التكلفة المقدَّرة من n للهدف  (متفائلة — لا تتجاوز الحقيقية أبداً)
Heuristic Examples — أمثلة على الـ Heuristics | مسافة الخط المستقيم · 8-puzzle · 8-queens
Example 1 — Route Finding · مثال ١: إيجاد الطريق

h(n) = Straight-Line Distance (SLD) from node n to goal.
Even if roads are winding, the straight-line distance is always ≤ actual road distance — so it never overestimates. ✅

h(n) = المسافة بالخط المستقيم (SLD) من العقدة n للهدف.
حتى لو الطرق ملتوية، المسافة المستقيمة دائماً ≤ المسافة الفعلية — فلا تتجاوز الحقيقية أبداً. ✅

🗺 Straight-Line Distance Heuristic — المسافة بالخط المستقيم
A B C G 140km 99km 211km h(A) = SLD ≈ 380km Start Goal Actual road: 140+99+211 = 450km > SLD 380km ✅
Example 2 — The 8-Puzzle · مثال ٢: لغز الـ 8

h₁ = Number of misplaced tiles — count tiles not in their goal position. Simple but less accurate.

h₂ = Manhattan Distance — sum of |row_diff| + |col_diff| for each tile. More informed than h₁.

h₁ = عدد القطع في غير مكانها — عد القطع اللي مش في مكانها الصحيح. بسيطة لكن أقل دقة.

h₂ = مسافة Manhattan — مجموع |فرق الصف| + |فرق العمود| لكل قطعة. أكثر معلومات من h₁.

🧩 8-Puzzle: h₁ vs h₂ Comparison
Current State 7 2 4 5 _ 6 8 3 1 Goal State 1 2 3 4 5 6 7 8 _ h₁ (misplaced) = 6 h₂ (manhattan) = 3+0+1+1+2+2+ 2+2 = 13 🟣 = misplaced tiles h₂ > h₁ → h₂ dominates
Both h₁ and h₂ are admissible — they never overestimate. But h₂ ≥ h₁ for all nodes, so h₂ dominates h₁ and leads to fewer node expansions.
كلا h₁ و h₂ مقبولتان — لا تتجاوزان التكلفة الحقيقية أبداً. لكن h₂ ≥ h₁ لكل العقد، إذن h₂ تسود على h₁ وتوسّع عقداً أقل.
Greedy Best-First Search — البحث الجشع | f(n) = h(n)
🇬🇧 English

Evaluation function: f(n) = h(n)
Greedy search expands the node that appears closest to goal. It chooses the minimum h(n) — ignoring how much it cost to reach that node (g(n) is ignored).


Think of it as: "Go to the city that looks closest to the destination, regardless of how far you've already traveled."

PropertyGreedyWhy?
Complete?❌ NoCan get stuck in loops (Iași → Neamț → Iași...)
Time?O(bm)Exponential; good heuristic helps a lot
Space?O(bm)Keeps all nodes in memory
Optimal?❌ NoFinds A solution, not the BEST one
🇪🇬 العربية

دالة التقييم: f(n) = h(n)
البحث الجشع يوسّع العقدة اللي تبدو أقرب للهدف. يختار أقل h(n) — بيتجاهل تكلفة الوصول لتلك العقدة (بيتجاهل g(n)).


تخيّل: "اذهب للمدينة اللي تبدو أقرب للوجهة، بصرف النظر عن المسافة اللي قطعتها فعلاً."

الخاصيةGreedyالسبب
اكتمال؟❌ لايمكن يعلق في حلقات (Iași ← Neamț ← Iași...)
الزمن؟O(bm)أسي؛ الـ heuristic الجيدة تحسّن كثيراً
المساحة؟O(bm)بيحتفظ بكل العقد في الذاكرة
أمثل؟❌ لايلاقي حل، مش الأفضل
🗺 Greedy Route: Arad → Bucharest (h = SLD to Bucharest)
Arad h=366 Sibiu h=253 Timisoara h=329 Fagaras h=176 Bucharest GOAL 🏁 140 99 211 Step 1 Step 2 Step 3 Found! Total = 140+99+211 = 450km ❌ NOT optimal! (optimal is 418km via A*)
A* Search — خوارزمية A* | f(n) = g(n) + h(n)
🇬🇧 English

Evaluation function: f(n) = g(n) + h(n)

  • g(n) = actual cost from start to n (how far we've come)
  • h(n) = estimated cost from n to goal (how far we expect to go)
  • f(n) = estimated total cost of cheapest path through n

A* avoids expanding paths that are already expensive. It balances "how much did we pay?" with "how much do we expect to pay?" — giving the optimal solution when h(n) is admissible.

🇪🇬 العربية

دالة التقييم: f(n) = g(n) + h(n)

  • g(n) = التكلفة الفعلية من البداية لـ n (كده قطعنا كام)
  • h(n) = التكلفة المقدَّرة من n للهدف (كام باقي متوقع)
  • f(n) = إجمالي التكلفة المقدَّرة للمسار عبر n

A* بتتجنب توسيع المسارات الغالية فعلاً. بتوازن "كده دفعنا كام؟" مع "متوقع ندفع كام؟" — وبتدي الحل الأمثل لو h(n) مقبولة.

🔬 A* vs Greedy: How f(n) is Calculated
⭐ A* Search f(n) = g(n) + h(n) g(n) = actual cost so far h(n) = estimated to goal ✅ Optimal if h admissible 🔴 Greedy Search f(n) = h(n) only g(n) = IGNORED ❌ h(n) = estimated to goal ❌ Not optimal, not complete
🧭 A* Step-by-Step: Arad → Bucharest
Step 1 — Expand Arad Sibiu: f = g(140)+h(253)=393 | Timisoara: f=140+329=469 | Zerind: f=75+374=449 → pick Sibiu (393) Step 2 — Expand Sibiu Fagaras: f=(140+99)+176=415 | Rimnicu: f=(140+80)+193=413 | Oradea: f=(140+151)+380=671 → pick Rimnicu (413) Step 3 — Expand Rimnicu Vilcea Pitesti: f=(140+80+97)+101=418 | Craiova: f=(140+80+146)+160=526 | Sibiu: closed → pick Fagaras(415) Step 4 — Expand Fagaras Bucharest: f=(140+99+211)+0=450 | Sibiu: closed | Pitesti still f=418 in queue → pick Pitesti(418) ✅ A* finds optimal: Arad→Sibiu→Rimnicu→Pitesti→Bucharest = 418km
PropertyA*Notes
Complete?✅ YesIf h is finite everywhere
Time?ExponentialDepends on heuristic quality
Space?O(bd)Keeps all nodes in memory
Optimal?✅ Yes**Only if h(n) is admissible
الخاصيةA*ملاحظة
اكتمال؟✅ نعملو h محدودة في كل مكان
الزمن؟أسييعتمد على جودة الـ heuristic
المساحة؟O(bd)بيحتفظ بكل العقد في الذاكرة
أمثل؟✅ نعم**بشرط أن h(n) تكون مقبولة
Admissibility & Dominance — القبول والسيطرة | شروط h(n) المثالية
🇬🇧 1 — Admissibility (القبول)

A heuristic h(n) is admissible if for every node n:

h(n) ≤ h*(n)

where h*(n) is the true actual cost to the goal. An admissible heuristic is always optimistic — it never overestimates. This guarantees A* finds the optimal solution.


🇬🇧 2 — Dominance (السيطرة)

If h₂(n) ≥ h₁(n) for all n (and both are admissible), then h₂ dominates h₁. A dominating heuristic always leads to fewer node expansions — it is strictly better.


Example: h₂ (manhattan distance = 18) dominates h₁ (misplaced tiles = 8) → prefer h₂.

🇪🇬 ١ — القبول (Admissibility)

الـ heuristic h(n) تكون مقبولة لو لكل عقدة n:

h(n) ≤ h*(n)

حيث h*(n) هي التكلفة الحقيقية الفعلية للهدف. الـ heuristic المقبولة دائماً متفائلة — لا تبالغ في التقدير أبداً. ده بيضمن إن A* تلاقي الحل الأمثل.


🇪🇬 ٢ — السيطرة (Dominance)

لو h₂(n) ≥ h₁(n) لكل n (والاتنين مقبولتين)، فـ h₂ تسود على h₁. الـ heuristic المسيطرة دايماً بتوسّع عقداً أقل — أفضل بكل المقاييس.


مثال: h₂ (مسافة Manhattan = 18) تسود h₁ (عدد القطع المشتتة = 8) ← يُفضَّل استخدام h₂.

📊 Dominance Relationship — علاقة السيطرة
0 h*(n) h₁ = 8 h₂ = 18 h*(n) h₂ ✅ h₁ ✅ h₂ > h₁ → h₂ dominates → fewer expansions Both ≤ h*(n) → both admissible → both guarantee optimal A*
Use the dominating heuristic when possible — same optimality guarantee, but significantly fewer nodes expanded and faster performance.
استخدم الـ heuristic المسيطرة كلما أمكن — نفس ضمان الأمثلية، لكن عقد أقل موسَّعة وأداء أسرع بكثير.
Full Comparison — مقارنة شاملة | Greedy vs A* vs Uninformed
Algorithmf(n)Complete?Optimal?TimeSpace
BFS depth(n) ✅ (equal costs) O(bd) O(bd)
UCS g(n) ✅ Always O(bC*/ε) O(bC*/ε)
Greedy h(n) ❌ No ❌ No O(bm) O(bm)
A* g(n)+h(n) ✅ Yes ✅ If h admissible Exponential O(bd)

ملخص المحاضرة السابعة — Lecture 7 Summary

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🧠 Heuristic h(n): معلومة إضافية تُقدِّر التكلفة لـ Goal — متفائلة دائماً (لا تتجاوز h*) | Extra info estimating cost to goal — always optimistic

📌 أمثلة: SLD للمسارات | h₁=misplaced tiles | h₂=Manhattan distance | h(queens)=attacking pairs

🔴 Greedy: f(n)=h(n) — سريع لكن ❌ غير مكتمل ❌ غير أمثل — قد يعلق في loops

A*: f(n)=g(n)+h(n) — ✅ مكتمل ✅ أمثل (بشرط h مقبولة) — يوازن التكلفة المقطوعة والمتوقعة

Admissibility: h(n) ≤ h*(n) — شرط لأمثلية A* | لا تبالغ في التقدير أبداً

🏆 Dominance: h₂ تسود h₁ لو h₂(n) ≥ h₁(n) لكل n — نفس الضمان لكن أداء أفضل

🗺 مثال Bucharest: Greedy = 450km ❌ | A* = 418km ✅ — فرق واضح في الجودة

Quiz — Lecture 7: Informed Search
20 سؤال — اختر الإجابة الصحيحة. الشرح بالعربي بعد كل إجابة.
0/20
Quiz Complete! 🎉