Posts

Optimization Techniques (MCA555) – Unit 2: Linear Programming (LP)

  Based on MCA Semester III Syllabus  --- Introduction to Linear Programming (LP) Linear Programming (LP) is a mathematical technique used to obtain the best possible solution (maximum profit or minimum cost) under given constraints. LP is one of the most widely used optimization techniques in business, engineering, transportation, and manufacturing. --- Definition of Linear Programming Linear Programming is a method of optimizing a linear objective function subject to a set of linear constraints. General Form: Maximize or Minimize Z = c₁x₁ + c₂x₂ + ... + cₙxₙ Subject to: a₁₁x₁ + a₁₂x₂ ≤ b₁ a₂₁x₁ + a₂₂x₂ ≤ b₂ x₁, x₂ ≥ 0 --- Components of Linear Programming Every LP problem consists of: 1. Decision Variables Unknown quantities to determine. Example: x = Number of Chairs y = Number of Tables --- 2. Objective Function Represents the goal. Example: Maximize Z = 50x + 40y --- 3. Constraints Restrictions on resources. Example: 2x + y ≤ 100 x + 3y ≤ 120 --- 4. Non-Negativity Constrai...

Optimization Techniques (MCA555) – Unit 1: Introduction to Optimization and Operations Research

  Based on MCA Semester III Syllabus  --- Introduction to Optimization Optimization is the process of finding the best possible solution from all feasible solutions while satisfying given constraints. The main objective of optimization is to: Maximize profit Minimize cost Minimize time Maximize efficiency Minimize resource usage --- Definition of Optimization Optimization is a mathematical technique used to obtain the best value of an objective function under specified constraints. Examples Finding the shortest route for delivery. Maximizing company profit. Minimizing production cost. Scheduling employees efficiently. --- Real-Life Applications of Optimization Optimization is used in almost every field. Engineering Machine design Structural design Electrical circuits Business Profit maximization Inventory management Production planning Transportation Route optimization Vehicle scheduling Healthcare Hospital scheduling Medicine dosage optimization Artificial Intelligence Machin...

Compiler Design (MCA554) – Unit 5: Code Generation and Code Optimization

  Based on MCA Semester III Syllabus  --- Introduction to Code Generation Code Generation is the final phase of a compiler. Its purpose is to convert intermediate code into target machine code. Compiler Flow: Source Program       ↓ Lexical Analysis       ↓ Syntax Analysis       ↓ Semantic Analysis       ↓ Intermediate Code       ↓ Code Generation       ↓ Machine Code --- Objectives of Code Generation A good code generator should: Produce correct code Produce efficient code Use memory efficiently Reduce execution time --- Inputs to Code Generator The code generator receives: Intermediate Code Symbol Table Runtime Information Example: t1 = a + b t2 = t1 * c --- Outputs of Code Generator The output is machine code or assembly code. Example: MOV R1, a ADD R1, b MUL R1, c --- Machine Dependent Code Generation Machine-dependent code generation considers: CPU architecture Number of registers Mem...

Compiler Design (MCA554) – Unit 4: Type Checking and Run Time Environments

 Compiler Design (MCA554) – Unit 4: Type Checking and Run Time Environments Based on MCA Semester III Syllabus  --- Introduction to Type Checking Type Checking is the process of verifying that operands and expressions are used with compatible data types. Its purpose is to detect type errors before program execution. Example: int x; x = 10; Valid Assignment. Example: int x; x = "Hello"; Type Error. --- Need for Type Checking Type checking helps: Detect programming errors Improve reliability Ensure correct operations Prevent invalid assignments --- Type Expressions A Type Expression represents the type of a variable, function, or expression. Examples: int a; float b; char c; Type Expressions: a → int b → float c → char --- Primitive Data Types Basic data types available in programming languages. Examples: int float char double boolean --- Constructed Data Types Created using primitive types. Examples: Array Pointer Structure Function --- Type Equivalence Determines whether two ...

Compiler Design (MCA554) – Unit 3: Syntax Directed Translation and Intermediate Code Generation

Compiler Design (MCA554) – Unit 3: Syntax Directed Translation and Intermediate Code Generation Based on MCA Semester III Syllabus  --- Introduction to Syntax Directed Translation Syntax Directed Translation (SDT) is a method in which semantic actions are associated with grammar rules. It helps the compiler: Generate intermediate code Perform type checking Build syntax trees Translate source code into machine-independent representation --- Need for Syntax Directed Translation A parser only checks syntax. The compiler must also: Understand meaning Generate code Perform semantic analysis Syntax Directed Translation helps achieve these tasks. --- Syntax Directed Definition (SDD) A Syntax Directed Definition is a Context Free Grammar (CFG) with attributes and semantic rules attached to productions. General Form: A → B C Semantic Rule: A.val = B.val + C.val --- Attributes Attributes store information about grammar symbols. Types: 1. Synthesized Attributes Information flows upward in the...

Compiler Design (MCA554) – Unit 2: Parsing and Syntax Analysis

 Compiler Design (MCA554) – Unit 2: Parsing and Syntax Analysis Based on MCA Semester III Syllabus  --- Introduction to Parsing Parsing is the second phase of a compiler. After Lexical Analysis generates tokens, the Parser checks whether the sequence of tokens follows the grammar rules of the programming language. Example Source Code: a = b + c; Tokens: id = id + id ; Parser verifies whether the token sequence is grammatically correct. --- Role of Parser The parser performs the following tasks: Checks syntax errors Builds parse trees Verifies grammar rules Reports syntax violations Position in Compiler Source Program       ↓ Lexical Analyzer       ↓ Parser       ↓ Semantic Analyzer --- Context Free Grammar (CFG) A Context Free Grammar is used to describe the syntax of programming languages. A CFG consists of: Terminals Non-terminals Productions Start Symbol Example Grammar E → E + T E → T T → id Where: E = Expression T = Term id = I...

Compiler Design (MCA554) Unit 1: Introduction to Compilers & Lexical Analysis

Unit 1: Introduction to Compilers & Lexical Analysis From your MCA Semester III syllabus.  --- What is a Compiler? A Compiler is a software that translates a program written in a high-level language into machine language. Example: printf("Hello"); Compiler converts it into machine code that the computer understands. --- Language Translators 1. Compiler Converts the entire program at once. Source Program       ↓    Compiler       ↓ Object Code Advantages: Faster execution Errors shown after compilation Examples: C C++ Go --- 2. Interpreter Translates line by line. Source Program       ↓  Interpreter       ↓  Execute Line by Line Advantages: Easy debugging Disadvantages: Slower execution Examples: Python JavaScript --- 3. Assembler Converts Assembly Language to Machine Language. Assembly Code       ↓    Assembler       ↓ Machine Code --- Difference Between Compi...