Computational thinking is a cognitive problem-solving methodology that empowers humans to formulate problems and design step-by-step algorithmic solutions that can be effectively automated by a digital computer. This chapter teaches the 4 core pillars, flowchart and pseudocode conventions, algorithmic efficiency analysis using Big-O notation, searching algorithms (Linear vs. Binary search), and sorting algorithms (Bubble sort).
کمپیوٹیشنل سوچ ایک ایسا فکری اور منطقی طریقہ کار ہے جس کی مدد سے پیچیدہ مسائل کو اس طرح سمجھا اور ترتیب دیا جاتا ہے کہ کمپیوٹر انہیں آسانی سے حل کر سکے۔ اس باب میں کمپیوٹیشنل سوچ کے چار ستون، فلو چارٹ اور سوڈو کوڈ کی ساخت، الگورتھم کی رفتار ماپنے کے پیمانے (Big-O)، تلاش کے طریقے (لینیئر اور بائنری سرچ) اور ترتیب دینے کے طریقے (ببل سورٹ) شامل ہیں۔
Visual Framework: The 4 Pillars of Computational Thinkingتصویری خاکہ
Comprehensive Textbook Learning Material (تفصیلی تعلیمی مواد)
Full Syllabus Coverage • BISE Punjab
11. Deep Dive into the 4 Pillars of Computational Thinking
۱. کمپیوٹیشنل سوچ کے چاروں ستونوں کا تفصیلی جائزہ
English Theoretical Concept & Technical Breakdown:
1. **Decomposition (مسئلے کی تقسیم):** The strategic breakdown of a complex, intractable problem into smaller, mutually distinct, manageable modules. When solving a problem, humans easily get overwhelmed by the big picture; breaking it down into sub-problems allows individual components to be analyzed, coded, and tested in parallel.
2. **Pattern Recognition (نمونوں کی پہچان):** Analyzing decomposed sub-problems to identify shared characteristics, recurring sequences, or common structures. If an algorithm was previously developed to calculate student exam ranks, that exact same pattern can be adapted to calculate customer loyalty scores.
3. **Abstraction (تجرید / غیر ضروری تفصیلات چھانٹنا):** The process of distilling essential features while ruthlessly filtering out and ignoring non-essential, irrelevant details. Abstraction creates conceptual models that reduce mental overhead.
4. **Algorithm Design (الگورتھم سازی):** The construction of a well-defined, ordered, finite sequence of unambiguous instructions that transforms valid inputs into expected outputs.
آسان اردو میں مکمل اور تفصیلی وضاحت:
۱. **مسئلے کی تقسیم (Decomposition):** کسی بہت بڑے اور مشکل کام کو چھوٹے چھوٹے آزاد حصوں میں بانٹنا۔ مثلاً پورے کالج کے سافٹ ویئر کو داخلہ فیس، حاضری اور نتائج کے الگ الگ حصوں میں تقسیم کرنا۔
۲. **نمونوں کی پہچان (Pattern Recognition):** مختلف مسائل میں مشترک باتوں کو پہچاننا تاکہ پرانے تجربات سے نیا مسئلہ جلد حل ہو۔
۳. **تجرید (Abstraction):** صرف ضروری معلومات پر توجہ رکھنا اور غیر ضروری تفصیلات کو مکمل طور پر نظر انداز کر دینا۔
۴. **الگورتھم سازی (Algorithm Design):** مرحلہ وار واضح ہدایات کا ایسا سلسلہ تیار کرنا جو بغیر کسی ابہام کے مطلوبہ نتیجہ دے سکے۔
Real-World Student Analogy (روزمرہ زندگی سے آسان فہم مثال):
In English: Google Maps uses Abstraction: It displays highway roads, street turns, and traffic congestion colors. It deliberately hides roadside trees, house wallpaper colors, and lamp post models because drivers do not need that information to navigate.
گوگل میپس (Google Maps) کی مثال: یہ سڑک کا راستہ اور ٹریفک کا رنگ تو دکھاتا ہے، لیکن سڑک کے کنارے کھڑے درخت اور گھروں کا رنگ چھپا دیتا ہے کیونکہ ڈرائیور کو راستہ تلاش کرنے کے لیے درختوں کے رنگ کی ضرورت نہیں ہوتی۔ یہ ابسٹریکشن ہے۔
BISE Punjab Board Examination Tip (اہم امتحانی نکات):
Define each pillar clearly in 2 to 3 lines for a guaranteed 4-mark short question.
22. Algorithm Complexity & Big-O Notation ($O$)
۲. الگورتھم کی کارکردگی اور بگ او نوٹیشن (Big-O)
English Theoretical Concept & Technical Breakdown:
Computer scientists do not measure an algorithm's speed in seconds because hardware clock speeds vary across machines. Instead, we use **Big-O Notation** to quantify the rate of growth of execution steps as input size $N$ increases towards infinity.
- **$O(1)$ - Constant Time:** Execution time stays identical regardless of dataset size (e.g., accessing an array element by its index `arr[0]`).
- **$O(\log N)$ - Logarithmic Time:** Search space is halved at each step. Extremely fast for huge datasets (e.g., Binary Search).
- **$O(N)$ - Linear Time:** Execution steps scale directly in proportion to $N$ (e.g., Linear Search through an unsorted list).
- **$O(N^2)$ - Quadratic Time:** Performance degrades rapidly; typical of nested loops (e.g., Bubble Sort, Selection Sort).
آسان اردو میں مکمل اور تفصیلی وضاحت:
کمپیوٹر سائنس دان الگورتھم کی رفتار کو سیکنڈوں میں نہیں ماپتے کیونکہ تیز کمپیوٹر پر کوڈ جلدی چلتا ہے اور سست پر دیر سے۔ اس کے بجائے **بگ او نوٹیشن (Big-O)** استعمال کی جاتی ہے جو یہ بتاتی ہے کہ جب ڈیٹا کی تعداد ($N$) بڑھے گی تو کمپیوٹر کو کتنے اضافی مراحل طے کرنا پڑیں گے:
- **$O(1)$ مستقل وقت (Constant Time):** چاہے ۱۰ چیزیں ہوں یا ۱۰ کروڑ، وقت بالکل ایک جیسا لگتا ہے (جیسے فہرست کا پہلا نمبر پڑھنا)۔
- **$O(\log N)$ لوگارتھمک وقت:** ڈیٹا جتنا بھی بڑا ہو، ہر مرحلے پر آدھا ہو جاتا ہے (جیسے بائنری سرچ)۔
- **$O(N)$ لینیئر وقت:** اگر ڈیٹا دوگنا ہوگا تو وقت بھی دوگنا لگے گا (جیسے لینیئر سرچ)۔
- **$O(N^2)$ کواڈریٹک وقت:** ڈیٹا بڑھنے سے وقت بہت تیزی سے اسکوائر کی طرح بڑھتا ہے (جیسے ببل سورٹ)۔
Real-World Student Analogy (روزمرہ زندگی سے آسان فہم مثال):
In English: Imagine finding a book in a library: If the books are dumped in random piles, you check one by one until you find it ($O(N)$). If the books are cataloged by Dewey Decimal Number, you jump directly to the exact shelf section in logarithmic time ($O(\log N)$).
اگر کمرے میں بکھرے ہوئے کاغذات میں سے اپنا شناختی کارڈ تلاش کرنا ہو تو ہر کاغذ الگ الگ چیک کرنا پڑے گا ($O(N)$)۔ لیکن اگر الف بائی ترتیب سے فائلیں رکھی ہوں تو چند سیکنڈ میں تلاش ہو جائے گا ($O(\log N)$)۔
BISE Punjab Board Examination Tip (اہم امتحانی نکات):
Compare the worst-case complexities of Linear Search ($O(N)$) and Binary Search ($O(\log N)$).
33. Searching & Sorting Algorithms Walkthrough
۳. تلاش اور ترتیب کے الگورتھمز کا عملی موازنہ
English Theoretical Concept & Technical Breakdown:
### A. Linear Search vs. Binary Search
- **Linear Search:** Works on both sorted and unsorted lists. Iterates from index 0 to $N-1$. Best case: $O(1)$ (target is at the first index). Worst case: $O(N)$ (target is at the very end or absent).
- **Binary Search:** **Mandatory Precondition: The array MUST be sorted.**
1. Initialize `low = 0`, `high = len - 1`.
2. Compute midpoint index `mid = (low + high) // 2`.
3. If `arr[mid] == target`, item is found!
4. If `arr[mid] < target`, discard left half: `low = mid + 1`.
5. If `arr[mid] > target`, discard right half: `high = mid - 1`.
### B. Bubble Sort Algorithm
Iterates through the list, comparing adjacent pairs of items. If `arr[j] > arr[j+1]`, they are swapped. With each complete outer pass, the largest remaining unsorted value "bubbles up" to its correct position at the end of the array. Best case (already sorted with swap flag): $O(N)$. Worst case: $O(N^2)$.
آسان اردو میں مکمل اور تفصیلی وضاحت:
### الف) لینیئر سرچ بمقابلہ بائنری سرچ
- **لینیئر سرچ:** ڈیٹا ترتیب شدہ ہو یا نہ ہو، دونوں پر کام کرتی ہے۔ پہلے عنصر سے لے کر آخری تک ایک ایک کر کے دیکھا جاتا ہے۔ بدترین صورت میں $O(N)$ وقت لگتا ہے۔
- **بائنری سرچ:** **لازمی شرط: ڈیٹا کا ترتیب شدہ (Sorted) ہونا ضروری ہے۔**
یہ الگورتھم ہر بار فہرست کے درمیان والے عنصر کو دیکھتا ہے۔ اگر مطلوبہ نمبر درمیان والے سے بڑا ہے تو بائیں طرف کا سارا حصہ چھوڑ کر دائیں طرف ڈھونڈتا ہے، اور اگر چھوٹا ہے تو بائیں طرف۔ ہر چکر میں آدھی فہرست خارج ہو جاتی ہے ($O(\log N)$)۔
### ب) ببل سورٹ (Bubble Sort)
یہ الگورتھم ساتھ ساتھ جڑے ہوئے دو دو نمبروں کا موازنہ کرتا ہے۔ اگر پہلا نمبر دوسرے سے بڑا ہو تو ان کی جگہیں بدل (Swap) دی جاتی ہیں۔ اس طرح ہر چکر کے بعد سب سے بڑا نمبر بلبلے کی طرح تیر کر فہرست کے آخر میں اپنی صحیح جگہ پر پہنچ جاتا ہے۔
Real-World Student Analogy (روزمرہ زندگی سے آسان فہم مثال):
In English: Bubble sort is like bubbles rising in a carbonated soda: The largest, lightest bubbles rise to the top of the glass first.
سوڈا یا کولڈ ڈرنک میں بلبلے جیسے اوپر آتے ہیں، اسی طرح سب سے بڑے نمبر ہر چکر کے بعد تیر کر فہرست کے آخر میں پہنچتے جاتے ہیں۔
BISE Punjab Board Examination Tip (اہم امتحانی نکات):
Be prepared to manually dry-run Bubble Sort on an array of 5 numbers for a long question.
Looking for the official textbook pages?
Jump directly to pages 20 - 38 in the embedded streaming viewer.