0% found this document useful (0 votes)
2 views7 pages

Algorithm

The document provides an overview of system software components such as compilers, interpreters, assemblers, linkers, and loaders. It also explains algorithms and their analysis, including time and space complexity, along with examples of algorithms for reversing a number, checking for palindromes, and finding the greatest of three numbers. Additionally, it distinguishes between algorithms and pseudocode, highlighting their purposes and characteristics.
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)
2 views7 pages

Algorithm

The document provides an overview of system software components such as compilers, interpreters, assemblers, linkers, and loaders. It also explains algorithms and their analysis, including time and space complexity, along with examples of algorithms for reversing a number, checking for palindromes, and finding the greatest of three numbers. Additionally, it distinguishes between algorithms and pseudocode, highlighting their purposes and characteristics.
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

SYSTEM SOFTWARE – NOTES

1. COMPILER
A compiler is system software that translates the entire high-level language program into machine code at once.

2. INTERPRETER
An interpreter translates and executes one statement at a time.

3. ASSEMBLER
An assembler converts assembly language program into machine language.

4. LINKER
A linker combines multiple object files and libraries into a single executable file.

5. LOADER
A loader loads the executable program into main memory for execution.

Algorithm and Analysis of Algorithm

1. What is an Algorithm?
An algorithm is a set of clear steps to solve a problem.
Simple meaning: A step-by-step method to do something.

Example:
Steps to make tea:
1. Boil water
2. Add tea leaves
3. Add sugar and milk
4. Boil
5. Serve

2. What is Analysis of Algorithm?


Analysis of algorithm means checking how good an algorithm is.
We check:

- How much time it takes


- How much memory (space) it uses

3. Why Do We Analyze Algorithms?


- To choose the fastest method
- To save time and memory
- To make programs efficient

4. Time Complexity (Easy)


Time complexity means how long an algorithm takes to run.

Examples:
- One step → O(1)
- Loop runs n times → O(n)

- Loop inside loop → O(n²)


5. Space Complexity (Easy)
Space complexity means how much memory is used by the program.
6. Example: Find biggest number between two numbers

Algorithm:
1. Read a and b

2. If a > b,
3. print a
4. Else print b

Time Complexity: O(1)


Space Complexity: O(1)

7. Simple Definition for Exam


Algorithm:
A step-by-step method to solve a problem.

Analysis of Algorithm:
The process of finding the time and memory used by an algorithm.

Algorithm to Reverse a Number


Step1:Start
Step2: Read the number n
Step3:Set rev = 0
Step4:Repeat while n > 0
 Find last digit: digit = n % 10
 Add digit to reverse: rev = (rev * 10) + digit
 Remove last digit: n = n / 10
Step5: Print rev
Step5:Stop
1) Algorithm to Check Palindrome Number

Definition:
A number is palindrome if it is same after reverse.
Example: 121, 343, 1221
Algorithm:
Step1: Start
Step 2: Read number n
Step 3. Set temp = n
Step 4. Set rev = 0
Step 5. While n > 0:
a. digit = n % 10
b. rev = (rev * 10) + digit
c. n = n / 10
Step 6. If temp == rev, print "Palindrome"
Step 7. Else print "Not Palindrome"
Step 8. Stop

2) Algorithm to Find Greatest of Three Numbers


Algorithm:
Step 1. Start
Step 2. Read three numbers a, b, c
Step 3. If a > b and a > c, print a as greatest
Step 4. Else if b > a and b > c, print b as greatest
Step 5. Else print c as greatest
Step 6 . Stop.
Pseudocode : A simple and informal way of writing an algorithm using English and programming-like statements.

1) Pseudocode of Reverse Number


Start
Read n
rev = 0
While n > 0 do
digit = n % 10

rev = rev * 10 + digit


n = n / 10
End while
Print rev
Stop.

2) Pseudocode of Palindrome Number


Start
Read n
temp = n
rev = 0
While n > 0 do
digit = n % 10

rev = rev * 10 + digit


n = n / 10
End while
If temp == rev then
Print "Palindrome"
Else
Print "Not Palindrome"

End if
Stop

3) Pseudocode of Greatest of Three Numbers


Start
Read a, b, c
If a > b and a > c then

Print a
Else if b > a and b > c then
Print b
Else
Print c
End if

Stop

4) Difference Between Algorithm and Pseudocode


Algorithm:
- Step-by-step method to solve a problem.
- Written in simple English.
- Easy to understand by humans.

- Used for planning solution.


Pseudocode:
- Writing of algorithm in programming style.
- Looks like programming language.
- Easy to convert into program.

- Used before writing actual code.

You might also like