6. Theory of Computation and Computer Graphics (ACtE06)

Computer Engineering (Nepal Engineering Council) – Engineering Licence Exam

This note delves into theory of computation and computer graphics, offering clear explanations and practical insights. It is designed to help students grasp core ideas through structured content. Whether preparing for exams or seeking conceptual clarity, this resource provides valuable support. Enhance your understanding with simplified notes and organized materials tailored to learners.

Comprehensive Study Guide for NEC License Exam - Computer Engineering

6. Theory of Computation and Computer Graphics (ACtE06)

Introduction

The Nepal Engineering Council (NEC) License Exam is a mandatory requirement for Computer Engineering graduates in Nepal to register as professional engineers. The section 6. Theory of Computation and Computer Graphics (ACtE06) tests knowledge of formal languages, automata theory, computational complexity, and computer graphics principles. These topics are fundamental for understanding computation models and visualizing data in computing systems. This comprehensive note covers all subtopics (6.1 to 6.6) with detailed explanations, code examples (where applicable), diagram names, and exam-focused strategies to ensure students can rely on it for thorough preparation. The exam consists of 100 multiple-choice questions (MCQs), with 10 marks allocated to this section, requiring a 50% passing threshold and no negative marking.

The syllabus includes:

  • 6.1 Introduction to finite automata (ACtE0601)
  • 6.2 Introduction to context-free language (ACtE0602)
  • 6.3 Turing machine (ACtE0603)
  • 6.4 Introduction of computer graphics (ACtE0604)
  • 6.5 Two-dimensional transformation (ACtE0605)
  • 6.6 Three-dimensional transformation (ACtE0606)

6.1 Introduction to Finite Automata (ACtE0601)

Key Concepts

Finite Automata (FA): Models computation with finite states, defined as (Q, Σ, δ, q0, F) where Q is states, Σ is input alphabet, δ is transition function, q0 is initial state, F is accepting states.

Finite State Machine (FSM): DFA (Deterministic) and NFA (Non-deterministic); DFA has one transition per input, NFA allows multiple or ε-transitions.

Equivalence of DFA and NDFA: Every NFA can be converted to an equivalent DFA using subset construction.

Minimization of FSM: Reduces states while preserving language (e.g., partition refinement algorithm).

Regular Expressions (RE): Patterns for regular languages (e.g., (a|b)*).

Equivalence of RE and FA: RE can be converted to NFA, and FA to RE using state elimination.

Pumping Lemma for Regular Languages: Proves non-regularity; for language L, if |w| ≥ p (pumping length), w = xyz, |xy| ≤ p, |y| > 0, xyiz ∈ L for all i ≥ 0.

Diagram Names

  • DFA State Transition Diagram
  • NFA to DFA Conversion Diagram
  • FSM Minimization Diagram

Common MCQ Areas

  • Constructing DFA/NFA for given languages.
  • Converting NFA to DFA or RE to FA.
  • Applying Pumping Lemma to prove non-regularity.

Practice Tips

  • Study “Introduction to the Theory of Computation” by Michael Sipser for automata concepts.
  • Design DFA/NFA for languages like {w | w ends with ab}.
  • Practice NFA to DFA conversion and state minimization.
  • Use Pumping Lemma to test languages (e.g., {a^n b^n | n ≥ 0}).

Sample MCQs

  1. Which is true for DFA but not NFA?

    • a) Multiple transitions per input
    • b) ε-transitions
    • c) Single transition per input
    • d) No final state
    • Answer: c) Single transition per input.
  2. The language {a^n b^n | n ≥ 0} is:

    • a) Regular
    • b) Non-regular
    • c) Context-free
    • d) Both b and c
    • Answer: d) Both b and c (non-regular, context-free).

6.2 Introduction to Context-Free Language (ACtE0602)

Key Concepts

Context-Free Grammar (CFG): Defined as (V, Σ, R, S) where V is variables, Σ is terminals, R is rules, S is start symbol (e.g., S → aSb | ε).

Derivation Trees: Represent CFG derivations:

  • Bottom-Up: Constructs tree from terminals to start symbol.
  • Top-Down: Starts from S, applies rules to terminals.
  • Leftmost/Rightmost: Applies rules to leftmost/rightmost variable first.

Parse Tree: Graphical representation of derivation for a string.

Ambiguous Grammar: Multiple parse trees for a string (e.g., E → E + E | a).

Chomsky Normal Form (CNF): Rules of form A → BC or A → a.

Greibach Normal Form (GNF): Rules of form A → aα where α is variables.

Backus-Naur Form (BNF): Syntax for programming languages (e.g., ::= if then ).

Pushdown Automata (PDA): FA with stack, accepts context-free languages.

Equivalence of CFL and PDA: Every CFL has a PDA, and vice versa.

Pumping Lemma for CFL: For language L, if |w| ≥ p, w = uvxyz, |vxy| ≤ p, |vy| > 0, uvixyiz ∈ L for all i ≥ 0.

Properties of CFL: Closure under union, concatenation, Kleene star; not closed under intersection, complement.

Diagram Names

  • Parse Tree Construction Diagram
  • PDA State Transition Diagram
  • CFG Derivation Tree Diagram

Common MCQ Areas

  • Constructing CFG and parse trees for given languages.
  • Converting grammars to CNF or GNF.
  • Applying Pumping Lemma to prove non-context-free languages.

Practice Tips

  • Study “Introduction to the Theory of Computation” by Michael Sipser for CFL concepts.
  • Design CFG for languages like {a^n b^n | n ≥ 0}.
  • Construct parse trees and convert grammars to CNF.
  • Use Pumping Lemma to test languages (e.g., {a^n b^n c^n | n ≥ 0}).

Sample MCQs

  1. A grammar is in CNF if rules are of form:

    • a) A → aα
    • b) A → BC or A → a
    • c) A → ε
    • d) A → aA
    • Answer: b) A → BC or A → a.
  2. The language {a^n b^n c^n | n ≥ 0} is:

    • a) Regular
    • b) Context-free
    • c) Context-sensitive
    • d) Unrestricted
    • Answer: c) Context-sensitive (not context-free).

6.3 Turing Machine (ACtE0603)

Key Concepts

Turing Machine (TM): Defined as (Q, Σ, Γ, δ, q0, q_accept, q_reject), with infinite tape, read/write head, and state transitions.

Notations: δ(q, a) = (p, b, D) where q is current state, a is input, p is next state, b is write symbol, D is direction (L/R).

Acceptance: String accepted if TM halts in q_accept.

TM as Language Recognizer: Accepts recursively enumerable languages.

TM as Computing Function: Computes functions (e.g., addition of two numbers).

TM as Enumerator: Generates strings of a language.

TM Variants: Multiple tracks, multiple tapes, non-deterministic TM (equivalent to deterministic TM).

Church-Turing Thesis: Any computable function can be computed by a TM.

Universal TM: Simulates any TM given its encoding.

Computational Complexity: Time (steps) and space (tape cells) used by TM.

Intractability: Problems with high complexity (e.g., NP-hard).

Reducibility: Reducing one problem to another (e.g., SAT to 3-SAT).

Diagram Names

  • Turing Machine Tape Diagram
  • Universal Turing Machine Diagram
  • TM State Transition Diagram

Common MCQ Areas

  • Designing TM for simple languages or functions.
  • Understanding TM variants and Church-Turing Thesis.
  • Time and space complexity analysis.

Practice Tips

  • Study “Introduction to the Theory of Computation” by Michael Sipser for TM concepts.
  • Design TM for languages like {a^n b^n c^n | n ≥ 0}.
  • Trace TM execution for strings (e.g., binary addition).
  • Analyze complexity of problems like palindrome checking.

Sample MCQs

  1. A Turing Machine halts when it:

    • a) Reads blank tape
    • b) Enters accept/reject state
    • c) Has no transitions
    • d) Loops infinitely
    • Answer: b) Enters accept/reject state.
  2. The Church-Turing Thesis states:

    • a) All languages are decidable
    • b) TMs compute all computable functions
    • c) DFAs are universal
    • d) Complexity is polynomial
    • Answer: b) TMs compute all computable functions.

6.4 Introduction of Computer Graphics (ACtE0604)

Key Concepts

Overview: Visual representation of data using computers (e.g., games, simulations).

Graphics Hardware:

  • Display Technology: CRT, LCD, LED, OLED.
  • Raster-Scan Displays: Pixel-based, scan lines.
  • Vector Displays: Line-drawing, used in early systems.
  • Display Processors: GPU for rendering.
  • Output Devices: Monitors, printers.
  • Input Devices: Mouse, keyboard, stylus, VR controllers.

Graphics Software: OpenGL, DirectX, Vulkan.

Software Standards: GKS, PHIGS, OpenGL API.

Diagram Names

  • Raster-Scan Display Architecture Diagram
  • Graphics Pipeline Diagram
  • Display Processor Block Diagram

Common MCQ Areas

  • Functions of display technologies (e.g., raster vs. vector).
  • Roles of GPU and graphics APIs.
  • Input/output devices in graphics systems.

Practice Tips

  • Study “Computer Graphics: Principles and Practice” by Foley et al. for graphics basics.
  • Compare raster-scan and vector display mechanisms.
  • Explore OpenGL tutorials to understand graphics APIs.
  • List common input/output devices and their applications.

Sample MCQs

  1. Raster-scan displays use:

    • a) Vector lines
    • b) Pixel grid
    • c) Analog signals
    • d) No memory
    • Answer: b) Pixel grid.
  2. OpenGL is an example of:

    • a) Hardware
    • b) Graphics API
    • c) Input device
    • d) Display technology
    • Answer: b) Graphics API.

6.5 Two-Dimensional Transformation (ACtE0605)

Key Concepts

2D Transformations: Manipulate objects in 2D space using matrices.

  • Translation: Moves object by (tx, ty); matrix: [1 0 tx; 0 1 ty; 0 0 1].
  • Rotation: Rotates by θ about origin; matrix: [cosθ -sinθ 0; sinθ cosθ 0; 0 0 1].
  • Scaling: Scales by (sx, sy); matrix: [sx 0 0; 0 sy 0; 0 0 1].
  • Reflection: Mirrors over axis (e.g., x-axis: [1 0 0; 0 -1 0; 0 0 1]).
  • Shear: Distorts along axis (e.g., x-shear: [1 shx 0; 0 1 0; 0 0 1]).

2D Composite Transformation: Combines transformations by matrix multiplication (e.g., translate then rotate).

2D Viewing Pipeline: World to screen via transformations and clipping.

World to Screen Transformation: Maps world coordinates to device coordinates.

Clipping: Removes objects outside view window:

  • Cohen-Sutherland: Uses region codes to clip lines.
  • Liang-Barsky: Parametric line clipping, more efficient.

Code Example

// 2D Translation in OpenGL (pseudocode)
void translate(float tx, float ty) {
    float T[3][3] = {{1, 0, tx}, {0, 1, ty}, {0, 0, 1}};
    glMultMatrixf(T); // Apply translation
}

  

Diagram Names

  • 2D Transformation Matrix Diagram
  • Cohen-Sutherland Clipping Diagram
  • 2D Viewing Pipeline Diagram

Common MCQ Areas

  • Matrix representations of 2D transformations.
  • Order of composite transformations.
  • Clipping algorithms (e.g., Cohen-Sutherland region codes).

Practice Tips

  • Study “Computer Graphics: Principles and Practice” by Foley et al. for 2D transformations.
  • Calculate transformation matrices for translation, rotation, scaling.
  • Apply Cohen-Sutherland clipping to example lines.
  • Write OpenGL code for basic 2D transformations.

Sample MCQs

  1. The 2D rotation matrix for angle θ is:

    • a) [cosθ sinθ; -sinθ cosθ]
    • b) [cosθ -sinθ; sinθ cosθ]
    • c) [sinθ cosθ; cosθ sinθ]
    • d) [1 0; 0 1]
    • Answer: b) [cosθ -sinθ; sinθ cosθ].
  2. Cohen-Sutherland clipping uses:

    • a) Parametric equations
    • b) Region codes
    • c) Matrix transformations
    • d) Pixel shading
    • Answer: b) Region codes.

6.6 Three-Dimensional Transformation (ACtE0606)

Key Concepts

3D Transformations: Manipulate objects in 3D space using 4x4 matrices.

  • Translation: Moves by (tx, ty, tz); matrix: [1 0 0 tx; 0 1 0 ty; 0 0 1 tz; 0 0 0 1].
  • Rotation: Rotates about x, y, z axes (e.g., z-axis: [cosθ -sinθ 0 0; sinθ cosθ 0 0; 0 0 1 0; 0 0 0 1]).
  • Scaling: Scales by (sx, sy, sz); matrix: [sx 0 0 0; 0 sy 0 0; 0 0 sz 0; 0 0 0 1].
  • Reflection: Mirrors over plane (e.g., xy-plane: [1 0 0 0; 0 1 0 0; 0 0 -1 0; 0 0 0 1]).
  • Shear: Distorts along axis (e.g., xy-shear: [1 0 shx 0; 0 1 shy 0; 0 0 1 0; 0 0 0 1]).

3D Composite Transformation: Combines transformations via matrix multiplication.

3D Viewing Pipeline: World to screen via modeling, viewing, projection, and clipping.

Projection Concepts:

  • Orthographic: Parallel projection, preserves distances.
  • Parallel: Non-converging lines (e.g., isometric).
  • Perspective: Converging lines, simulates human vision.

Code Example

// 3D Rotation about Z-axis in OpenGL (pseudocode)
void rotateZ(float theta) {
    float R[4][4] = {{cos(theta), -sin(theta), 0, 0},
                     {sin(theta), cos(theta), 0, 0},
                     {0, 0, 1, 0},
                     {0, 0, 0, 1}};
    glMultMatrixf(R); // Apply rotation
}

  

Diagram Names

  • 3D Transformation Matrix Diagram
  • Perspective Projection Diagram
  • 3D Viewing Pipeline Diagram

Common MCQ Areas

  • Matrix representations of 3D transformations.
  • Differences between orthographic and perspective projections.
  • Steps in the 3D viewing pipeline.

Practice Tips

  • Study “Computer Graphics: Principles and Practice” by Foley et al. for 3D transformations.
  • Calculate 3D rotation matrices for given angles.
  • Compare orthographic and perspective projection effects.
  • Write OpenGL code for 3D transformations and projections.

Sample MCQs

  1. Perspective projection simulates:

    • a) Parallel lines
    • b) Human vision
    • c) Fixed distances
    • d) 2D scaling
    • Answer: b) Human vision.
  2. The 3D translation matrix has dimension:

    • a) 2x2
    • b) 3x3
    • c) 4x4
    • d) 3x4
    • Answer: c) 4x4.

General Preparation Strategies

  • Syllabus Review: Study the official NEC syllabus to focus on key topics.
  • Textbooks: Use “Introduction to the Theory of Computation” by Michael Sipser for theory of computation, and “Computer Graphics: Principles and Practice” by Foley et al. for graphics.
  • Practice: Solve 20–30 MCQs per subtopic, focusing on automata design, grammar conversions, and transformation matrices.
  • Simulations: Use JFLAP for automata and TMs, OpenGL for graphics transformations.
  • Time Management: Practice 10–15 MCQs in 12–15 minutes to match exam pace.

Conclusion

This comprehensive study guide covers all subtopics under 6. Theory of Computation and Computer Graphics (ACtE06) for the NEC License Exam, providing detailed explanations, code examples, diagram names, and practice strategies. Designed as a reliable resource for students, it ensures thorough preparation for automata theory, Turing machines, and computer graphics. By mastering these topics and practicing MCQs, candidates can confidently excel in the exam.