1.
Concept of Programming
Instruction:
Instructions are basic commands given to a computer to perform specific tasks. These can be defined and exemplified in various programming languages.
Program:
A program is a collection of instructions written to perform a specific task. It consists of definitions and examples that help users understand how to solve problems using code.
Programming Language:
High-level languages: These are languages closer to human languages, such as Python, C++, and Java, which are easier to write and understand.
Low-level languages: These include assembly language and machine code, closer to hardware and more difficult to understand but faster to execute.
Assembly Language: A low-level programming language that uses symbolic names to represent machine-level code instructions.
Procedural Programming:
A paradigm based on the concept of procedure calls, where the program is divided into procedures or functions.
Non-procedural Programming:
Also known as declarative programming, where the logic of computation is expressed without explicitly listing commands or steps.
Structured Programming:
A programming paradigm aimed at improving clarity, quality, and development time by using blocks, loops, and subroutines.
Object-Oriented Programming (OOP):
A paradigm based on the concept of objects which contain data and methods. It supports concepts like inheritance, encapsulation, abstraction, and polymorphism.
2. Algorithm Fundamentals
Definition:
An algorithm is a finite sequence of well-defined instructions to solve a specific problem.
Characteristics:
Must be clear and unambiguous
Should have a finite number of steps
Should provide a solution to the problem
Should be efficient and effective
Recursive Algorithm:
An algorithm that calls itself repeatedly to solve sub-parts of the problem.
Non-recursive Algorithm:
An algorithm that does not use recursion but uses loops and other control structures to solve problems.
Representation of Algorithm:
Flowchart: A graphical representation using symbols to illustrate the flow of the algorithm.
Pseudo Code: A structured but human-readable notation that outlines the steps in an algorithm.
Efficiency of Algorithm:
Refers to the resources used by the algorithm, mainly time and space.
Space Complexity:
The amount of memory an algorithm uses relative to the input size.
Time Complexity:
The amount of time an algorithm takes to complete in relation to the input size.
Asymptotic Notation:
Used to describe the efficiency of algorithms in terms of input size.
Big O Notation (O): Upper bound on time complexity (worst case).
Big Omega (Ω): Lower bound on time complexity (best case).
Big Theta (Θ): Tight bound, where upper and lower bounds are the same.
3. Introduction to Problem Solving
Steps for Problem Solving:
Analyzing the problem: Understand the problem requirements and constraints.
Developing an algorithm: Design a step-by-step solution for the problem.
Coding: Translating the algorithm into a programming language.
Testing: Running the code with various inputs to verify correctness.
Debugging: Identifying and fixing errors or bugs in the code to ensure functionality.