Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Data structure and algorithms

Rating
-
Sold
-
Pages
14
Uploaded on
25-05-2025
Written in
2024/2025

Algorithm-Definition-examples-Complexity-Divide and Conquer- Binary search -Maximum and Minimum-Merge sort. 1.Algorithm Definition: Algorithm is step-by-step process or sequence of steps for solving a problem. 2. Properties of an Algorithm The properties of an algorithm is given by Input: The algorithm must have input values from a specified set Output: The algorithm must produce the output values from a specified set of input values. The output values are the solution to a problem. Finiteness: For any input the algorithm must terminate after a finite number of steps. Definiteness: All the steps of the algorithm must be precisely defined. Effectiveness: It must be possible to perform each step of the algorithm correctly and in a finite amount of time 3.Types of Algorithms: 1.Sorting algorithms: Bubble Sort, insertion sort, and many more. These algorithms are used to sort the data in a particular format. 2.Searching algorithms: Linear search, binary search, etc. These algorithms are used in finding a value or record that the user demands. 3.Graph Algorithms: It is used to find solutions to problems like finding the shortest path between cities, and real-life problems like traveling salesman problems. Example 1: Write an algorithm to find the maximum of all the elements

Show more Read less
Institution
Course

Content preview

UNIT V ALGORITHM 12
Algorithm-Definition-examples-Complexity-Divide and Conquer- Binary search
-Maximum
and Minimum-Merge sort.




1.Algorithm Definition:
Algorithm is step-by-step process or sequence of steps for solving a
problem.

2. Properties of an Algorithm
The properties of an algorithm is given by
✓ Input: The algorithm must have input values from a specified set
✓ Output: The algorithm must produce the output values from a specified
set of input values. The output values are the solution to a problem.
✓ Finiteness: For any input the algorithm must terminate after a finite
number of steps.
✓ Definiteness: All the steps of the algorithm must be precisely defined.
✓ Effectiveness: It must be possible to perform each step of the algorithm
correctly and in a finite amount of time

3.Types of Algorithms:

1.Sorting algorithms: Bubble Sort, insertion sort, and many more. These
algorithms are used to sort the data in a particular format.

2.Searching algorithms: Linear search, binary search, etc. These algorithms are
used in finding a value or record that the user demands.

3.Graph Algorithms: It is used to find solutions to problems like finding the
shortest path between cities, and real-life problems like traveling salesman
problems.



Example 1: Write an algorithm to find the maximum of all the elements
present in the array.

, Step 1: Start the Program

Step 2: Declare a variable max with the value of the first element of the array.

Step 3: Compare max with other elements using loop.

Step 4: If max < array element value, change max to new max.

Step 5: If no element is left, return or print max otherwise goto step 3.

Step 6: End of Solution



Example 2: Write an algorithm to find the average of 3 subjects.

Step 1: Start the Program

Step 2: Declare and Read 3 Subject, let’s say S1, S2, S3

Step 3: Calculate the sum of all the 3 Subject values and store result in Sum
variable (Sum = S1+S2+S3)

Step 4: Divide Sum by 3 and assign it to Average variable. (Average = Sum/3)

Step 5: Print the value of Average of 3 Subjects

Step 6: End of Solution

4.Advantages of Algorithms

• Easy to understand: Since it is a stepwise representation of a solution to
a given problem, it is easy to understand.
• Language Independent: It is not dependent on any programming
language, so it can easily be understood by anyone.
• Debug / Error Finding: Every step is independent / in a flow so it will be
easy to spot and fix the error.
• Sub-Problems: It is written in a flow so now the programmer can divide
the tasks which makes them easier to code.

Written for

Institution
Course

Document information

Uploaded on
May 25, 2025
Number of pages
14
Written in
2024/2025
Type
Class notes
Professor(s)
Dr.praveen kumar
Contains
All classes

Subjects

$16.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
shankarshankar1

Get to know the seller

Seller avatar
shankarshankar1 S.m.d.p.v.c .hr.sec.school
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
11 months
Number of followers
0
Documents
5
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions