0% found this document useful (0 votes)
3 views45 pages

Programmingforproblemsolvingunit1ppt 1pdf

This document serves as an introduction to computers, programming languages, and algorithms, outlining key components and characteristics of computer architecture. It covers the definitions of software and hardware, types of programming languages, and the roles of assemblers and compilers. The content is structured into units that detail the functionality and management of computer systems, as well as the principles of programming and algorithm design.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views45 pages

Programmingforproblemsolvingunit1ppt 1pdf

This document serves as an introduction to computers, programming languages, and algorithms, outlining key components and characteristics of computer architecture. It covers the definitions of software and hardware, types of programming languages, and the roles of assemblers and compilers. The content is structured into units that detail the functionality and management of computer systems, as well as the principles of programming and algorithm design.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

Introduction to Computers

Programming language
Algorithms

Unit 1: Introduction to Computer, Programming & Algorithms


Course: Programming for Problem Solving

Dr. Vishwa Pratap Singh

NextGen Academy

December 7, 2023

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 1 / 45
Introduction to Computers
Programming language
Algorithms

Contents

1 Introduction to Computers
Component of a Computer Architecture
Architecture
Definition of software and hardware
Definition of software and Hardware

2 Programming language
Programming Language
Types of Programming Langauges
Assemblers

3 Algorithms
Characteristics of Algorithms
Complexity of Algorithm
Flow Charts

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 2 / 45
Introduction to Computers
Programming language
Algorithms

Agenda

1 Introduction to Computer Programming & Algorithms


1 Component of a Computer
2 Architecture
3 Definition of Software and Hardware
4 Types of Programming Language
5 Assembler
6 Compiler
7 Interpreter
8 Linker
9 Loader
10 Algorithm
11 Characteristics of Algorithm
12 Complexity of an Algorithm
13 Flowcharts

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 3 / 45
Introduction to Computers
Programming language Component of a Computer Architecture
Algorithms

Contents

1 Introduction to Computers
Component of a Computer Architecture
Architecture
Definition of software and hardware
Definition of software and Hardware

2 Programming language
Programming Language
Types of Programming Langauges
Assemblers

3 Algorithms
Characteristics of Algorithms
Complexity of Algorithm
Flow Charts

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 4 / 45
Introduction to Computers
Programming language Component of a Computer Architecture
Algorithms

What is a Computer?

A computer is an electronic device that processes data to perform various tasks.


It can store, retrieve, and process data, making it a versatile tool for a wide
range of applications.
Computers can execute a set of instructions, known as a program, to perform
specific functions.
Key Components:
Input Unit: Accepts data and instructions.
Central Processing Unit (CPU): Processes data and performs calculations.
Output Unit: Presents results to the user.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 5 / 45
Introduction to Computers
Programming language Component of a Computer Architecture
Algorithms

Basic Characteristics of Computers

1 Speed: Computers can perform millions of calculations per second, making


them extremely fast.
2 Accuracy: Due to operating on pre-programmed software, computers are
highly accurate with no room for human error.
3 Diligence: Computers can perform complex and lengthy calculations
consistently and accurately.
4 Versatility: Designed to handle multiple operations simultaneously, making
them versatile.
5 Storage: Computers can store a large amount of data and instructions in
memory, retrievable as needed.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 6 / 45
Introduction to Computers
Programming language Component of a Computer Architecture
Algorithms

Components of a Computer

A computer processes data through a series of steps:


1 Input Devices: Capture user commands and data.
2 Central Processing Unit (CPU): Executes instructions and manipulates data.
3 Operating System: Manages hardware and software resources.
4 Output Devices: Display or present results to the user.
5 Storage Devices: Store data and programs for long-term use.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 7 / 45
Introduction to Computers
Programming language Component of a Computer Architecture
Algorithms

1. Input Unit

Input devices: keyboard, mouse, joystick, scanner, etc.


Converts data into binary language.
Provides data to the processor for further processing.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 8 / 45
Introduction to Computers
Programming language Component of a Computer Architecture
Algorithms

2. Central Processing Unit (CPU)

Once information is entered:


CPU processes data.
CPU components:
Arithmetic and Logic Unit (ALU)
Control Unit
Memory Registers

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 9 / 45
Introduction to Computers
Programming language Component of a Computer Architecture
Algorithms

2. Central Processing Unit (CPU) - Components

1 Arithmetic and Logic Unit (ALU):


Fundamental building block.
Performs arithmetic and logical operations.
2 Control Unit:
Coordinates data flow.
Controls operations of ALU, memory, and input/output units.
3 Memory Registers:
Temporary memory in the CPU.
Stores data directly used by the processor.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 10 / 45
Introduction to Computers
Programming language Component of a Computer Architecture
Algorithms

3. Output Unit

Output devices: monitor, printer, plotter, etc.


Converts binary data to human-readable form.
Displays or prints processed data in a user-friendly format.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 11 / 45
Introduction to Computers
Programming language Component of a Computer Architecture
Algorithms

Characteristics of a Computer

Speed: Millions of calculations per second.


Accuracy: Operates with pre-programmed software, minimizing human error.
Diligence: Performs complex calculations with the same accuracy.
Versatility: Designed to carry out multiple operations simultaneously.
Storage: Stores a large amount of data/instructions in memory.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 12 / 45
Introduction to Computers
Programming language Component of a Computer Architecture
Algorithms

1.2 Architecture

Defined as a set of rules and methods describing the functionality,


management, and implementation of computers.
Rules governing how a system performs and operates.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 13 / 45
Introduction to Computers
Programming language Component of a Computer Architecture
Algorithms

Computer Architecture Categories

1 Instruction Set Architecture (ISA):


Processor reads and acts on instructions.
Allocates memory and handles memory address modes.
2 Micro Architecture:
Describes how a processor implements instructions from ISA.
3 System Design:
Includes entire hardware components like virtualization and multiprocessing.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 14 / 45
Introduction to Computers
Programming language Component of a Computer Architecture
Algorithms

Role of Computer Architecture

Balancing act: Balances performance, efficiency, cost, and reliability of a


computer system.
ISA Bridge: Instruction Set Architecture acts as a bridge between software and
hardware.
Communication: Translates high-level language to binary language for
communication between users and computers.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 15 / 45
Introduction to Computers
Programming language Component of a Computer Architecture
Algorithms

Components of Computer Architecture

Generally consists of the following:


1 Processor
2 Memory
3 Peripherals
Connected via the system bus, including address bus, data bus, and control bus.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 16 / 45
Introduction to Computers
Programming language Component of a Computer Architecture
Algorithms

1.2 Architecture

Defined as a set of rules and methods describing the functionality,


management, and implementation of computers.
Rules governing how a system performs and operates.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 17 / 45
Introduction to Computers
Programming language Component of a Computer Architecture
Algorithms

Computer Architecture Categories

1 Instruction Set Architecture (ISA):


Processor reads and acts on instructions.
Allocates memory and handles memory address modes.
2 Micro Architecture:
Describes how a processor implements instructions from ISA.
3 System Design:
Includes entire hardware components like virtualization and multiprocessing.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 18 / 45
Introduction to Computers
Programming language Component of a Computer Architecture
Algorithms

Role of Computer Architecture

Balancing act: Balances performance, efficiency, cost, and reliability of a


computer system.
ISA Bridge: Instruction Set Architecture acts as a bridge between software and
hardware.
Communication: Translates high-level language to binary language for
communication between users and computers.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 19 / 45
Introduction to Computers
Programming language Component of a Computer Architecture
Algorithms

Components of Computer Architecture

Generally consists of the following:


1 Processor
2 Memory
3 Peripherals
Connected via the system bus, including address bus, data bus, and control bus.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 20 / 45
Introduction to Computers
Programming language Component of a Computer Architecture
Algorithms

Basic Definitions

Software
Software refers to a set of instructions that tell a computer how to perform specific
tasks. It encompasses both system software, responsible for managing computer
hardware, and application software, designed for end-users to accomplish various
tasks.
System Software: This type of software includes operating systems like
Windows, macOS, and Linux. It manages computer resources and provides a
foundation for other software applications to run.
Application Software: These are programs designed to perform specific tasks
for users. Examples include word processors (Microsoft Word), web browsers
(Google Chrome), and graphic design software (Adobe Photoshop).

Hardware
Hardware represents the physical components of a computer system. It includes
devices such as the central processing unit (CPU), memory (RAM), storage (hard
drives, SSDs), input devices (keyboard, mouse, webcam), and output devices
(monitor, printer, speakers).

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 21 / 45
Introduction to Computers
Types of Programming Langauges
Programming language
Assemblers
Algorithms

Contents

1 Introduction to Computers
Component of a Computer Architecture
Architecture
Definition of software and hardware
Definition of software and Hardware

2 Programming language
Programming Language
Types of Programming Langauges
Assemblers

3 Algorithms
Characteristics of Algorithms
Complexity of Algorithm
Flow Charts

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 22 / 45
Introduction to Computers
Types of Programming Langauges
Programming language
Assemblers
Algorithms

Programming Languages Basics

Definition: A programming language is a formal system designed to


communicate instructions to a computer. It is used to develop software and
create applications.
Purpose: Programming languages allow humans to write code that a computer
can understand and execute.
Key Elements:
Syntax: Rules governing the structure of code.
Semantics: Meaning assigned to various constructs in the language.
Variables: Containers for storing data.
Control Flow: Mechanisms to control the order of execution.
Functions/Methods: Modular units of code for reuse.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 23 / 45
Introduction to Computers
Types of Programming Langauges
Programming language
Assemblers
Algorithms

Types of Programming Languages

1 Low-level Language:
Machine Language: Binary instructions directly executed by the computer.
Assembly Language: Uses symbolic representations for machine instructions.
2 High-level Language:
Closer to human language, easier to read and write.
Examples: C, Java, Python, etc.
3 Medium Level Language:
Combines features of both low-level and high-level languages.
Examples: C, C++, Java.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 24 / 45
Introduction to Computers
Types of Programming Langauges
Programming language
Assemblers
Algorithms

How Programming Works

Writing Code: Developers write code using a text editor or integrated


development environment (IDE).
Compilation or Interpretation:
Compilation: Code is translated into machine code before execution. Results in an
executable file.
Interpretation: Code is translated line-by-line during execution. No separate
executable file is generated.
Execution: The compiled or interpreted code is executed by the computer’s
CPU.
Debugging: Identifying and fixing errors in the code using debugging tools.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 25 / 45
Introduction to Computers
Types of Programming Langauges
Programming language
Assemblers
Algorithms

Common Programming Paradigms

Imperative/Procedural: Focuses on describing how a program operates (C,


Fortran).
Object-Oriented: Organizes code around objects and classes (Java, Python).
Functional: Treats computation as mathematical functions (Haskell, Lisp).
Declarative: Describes the desired outcome without specifying the step-by-step
process (SQL).

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 26 / 45
Introduction to Computers
Types of Programming Langauges
Programming language
Assemblers
Algorithms

Types of Programming Language

1 Low-level Language:
Provides no abstraction from hardware, represented by machine instructions in 0
and 1 forms.
Machine Language:
Consists of binary instructions (0 and 1).
Difficult for programmers to write and comprehend.
Prone to errors, challenging to maintain.
Not portable between different processor architectures.
Assembly Language:
Human-readable commands (e.g., move, add).
Easier to write and understand than machine language.
Requires a translator (assembler) to convert to machine code.
Not fully portable due to processor-specific instructions.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 27 / 45
Introduction to Computers
Types of Programming Langauges
Programming language
Assemblers
Algorithms

Types of Programming Language (contd.)

2 High-Level Language:
Allows creation of machine-independent programs.
Resembles human languages, requires a compiler for translation.
Examples: COBOL, FORTRAN, PASCAL, C, C++, JAVA, .NET.
Advantages:
Readable, writable, and maintainable.
Overcomes drawbacks of low-level languages.
Machine-independent and portable.
3 Medium Level Language:
Features of both low-level and high-level languages.
Also known as intermediate-level programming languages.
Examples: C, C++, JAVA.
Combines the efficiency of low-level languages with readability of high-level
languages.
Portable, but may involve some hardware-specific features.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 28 / 45
Introduction to Computers
Types of Programming Langauges
Programming language
Assemblers
Algorithms

Assembler

Definition: Assembler is a program that translates assembly language code into


machine code.
Features:
Converts symbolic instructions to binary code.
Generates object files.
Handles labels, constants, and variables.
Advantages:
Faster program development.
Specific to a particular architecture.
Disadvantages:
Not portable across different architectures.
Limited functionality compared to high-level languages.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 29 / 45
Introduction to Computers
Types of Programming Langauges
Programming language
Assemblers
Algorithms

Compiler

Definition: Compiler is a program that translates high-level source code into


machine code.
Features:
Translates entire source code at once.
Generates object files or executables.
Optimizes code for performance.
Advantages:
Portable across different architectures.
Detects errors across the entire program.
Disadvantages:
Slower development compared to an assembler.
Requires more system resources.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 30 / 45
Introduction to Computers
Types of Programming Langauges
Programming language
Assemblers
Algorithms

Linker and Loader

Linker: Combines multiple object files into a single executable.


Loader: Loads executable into memory for execution.
Features:
Resolves addresses and references between different modules.
Allocates memory addresses for variables and constants.
Advantages:
Supports modular programming.
Enables dynamic linking.
Disadvantages:
Overhead in combining and loading modules.
Complex debugging process.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 31 / 45
Introduction to Computers Characteristics of Algorithms
Programming language Complexity of Algorithm
Algorithms Flow Charts

Contents

1 Introduction to Computers
Component of a Computer Architecture
Architecture
Definition of software and hardware
Definition of software and Hardware

2 Programming language
Programming Language
Types of Programming Langauges
Assemblers

3 Algorithms
Characteristics of Algorithms
Complexity of Algorithm
Flow Charts

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 32 / 45
Introduction to Computers Characteristics of Algorithms
Programming language Complexity of Algorithm
Algorithms Flow Charts

What is an Algorithm?

Definition
An algorithm is a finite set of instructions carried out in a specific order to perform a
particular task. It is a step-by-step process representing simple logic to solve
problems, often described informally through flowcharts or pseudocode.

Problem: A real-world problem for which a program or set of instructions is


needed.
Algorithm: A step-by-step process designed to solve a problem.
Input: Necessary inputs given to the algorithm.
Processing Unit: Processes input to produce the desired output.
Output: The outcome or result of the program.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 33 / 45
Introduction to Computers Characteristics of Algorithms
Programming language Complexity of Algorithm
Algorithms Flow Charts

How do Algorithms Work?

1 Input: Algorithms take input data (numbers, text, images).


2 Processing: Logical and mathematical operations manipulate and transform
input data.
3 Output: The algorithm produces meaningful information as output.
4 Efficiency: Algorithms aim for efficiency, accomplishing tasks quickly with
minimal resources.
5 Optimization: Constant efforts to optimize algorithms for speed and reliability.
6 Implementation: Executed in various programming languages.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 34 / 45
Introduction to Computers Characteristics of Algorithms
Programming language Complexity of Algorithm
Algorithms Flow Charts

Example: Multiplying Two Numbers

Algorithm Steps:
1 Start
2 Declare three integers x, y, and z
3 Define values of x and y
4 Multiply values of x and y
5 Store result to z
6 Print z
7 Stop
Algorithm:
1 Start mul
2 Get values of x and y
3 z ← x×y
4 Display z
5 Stop

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 35 / 45
Introduction to Computers Characteristics of Algorithms
Programming language Complexity of Algorithm
Algorithms Flow Charts

Algorithm Design

Algorithms instruct programmers on how to


write code.
They can be written as a series of steps or
using a more concise notation like
pseudocode.
Figure 1: Algorithm Design
To solve a given problem, multiple solution
algorithms can be derived.
The next step is to evaluate and implement
the most appropriate solution.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 36 / 45
Introduction to Computers Characteristics of Algorithms
Programming language Complexity of Algorithm
Algorithms Flow Charts

Characteristics of Algorithm

1 Efficiency
2 Correctness
3 Clarity
4 Scalability
5 Reliability
6 Optimality
7 Robustness
8 Adaptability
9 Simplicity

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 37 / 45
Introduction to Computers Characteristics of Algorithms
Programming language Complexity of Algorithm
Algorithms Flow Charts

Complexity of an Algorithm

Time Complexity
The amount of time required to complete an algorithm’s execution is called time
complexity. The big O notation is used to represent an algorithm’s time complexity.

Example: Multiplication of n Numbers


mul = 1;
for i=1 to n
mul = mul * i;
return mul;

The time complexity of the loop statement is at least n, and as n escalates, so


does the time complexity.
The code’s complexity, i.e., return mul, will be constant because its value is
not dependent on the importance of n and will provide the result in a single
step.
The worst-time complexity is generally considered because it is the maximum
time required for any given input size.
Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 38 / 45
Introduction to Computers Characteristics of Algorithms
Programming language Complexity of Algorithm
Algorithms Flow Charts

Complexity of an Algorithm (contd.)

Space Complexity
The amount of space an algorithm requires to solve a problem and produce an
output is called its space complexity. Space complexity is expressed in big O
notation.

Space is required for various purposes, including storing program instructions,


constant values, variable values, function calls, jumping statements, etc.
Space Complexity = Auxiliary Space + Input Size

Note
After understanding what an algorithm is, its analysis and approaches, we will look
at different types of algorithms.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 39 / 45
Introduction to Computers Characteristics of Algorithms
Programming language Complexity of Algorithm
Algorithms Flow Charts

Flowcharts
Definition
A flowchart is a visual representation of a process, showing the steps involved and
their order. It uses different shapes to represent different types of steps and arrows
to indicate the flow of the process.

Figure 2: Example of a simple flowchart


Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 40 / 45
Introduction to Computers Characteristics of Algorithms
Programming language Complexity of Algorithm
Algorithms Flow Charts

Key Components of a Flowchart

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 41 / 45
Introduction to Computers Characteristics of Algorithms
Programming language Complexity of Algorithm
Algorithms Flow Charts

Creating a Flowchart

1 Identify the process or system to be represented.


2 Define the start and end points.
3 Identify key steps or tasks in the process.
4 Use appropriate symbols for each step (process, decision, etc.).
5 Connect the symbols with arrows to represent the flow.
6 Review and refine the flowchart for clarity and accuracy.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 42 / 45
Introduction to Computers Characteristics of Algorithms
Programming language Complexity of Algorithm
Algorithms Flow Charts

Benefits of Flowcharts

Visual representation aids in understanding complex processes.


Helps in identifying bottlenecks or inefficiencies.
Useful for documentation and communication.
Facilitates process improvement and optimization.
Can be a valuable tool in problem-solving.

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 43 / 45
Introduction to Computers Characteristics of Algorithms
Programming language Complexity of Algorithm
Algorithms Flow Charts

Flowchart: Add Two Numbers

Figure 3: Sum of two members

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 44 / 45
Introduction to Computers Characteristics of Algorithms
Programming language Complexity of Algorithm
Algorithms Flow Charts

Flowchart: Add Two Numbers

Figure 4: Sum of two members

Dr. Vishwa Pratap Singh Unit 1: Introduction to Computer, Programming & Algorithms 45 / 45

You might also like