Introduction to Algorithm
Algorithm
Step by step method of solving problems
Procedure
Detailed series of instructions for carrying out an operation or solving a problem
We can also use algorithms in everyday tasks (ex. recipe)
Can be written in any matter unless they provide a solution of a problem
Data Structure
Specialized format for organizing and storing data
Used in computing to make it easy to locate and retrieve information
Can also be used to group and organize other data
Properties of Algorithms
Input
Input values from a specified set
Usually from us developer or user
Output
From the values the algorithms produces the output values from a specified set
Solution
Correctness
The algorithm should produce correct output values for each set of inputs
Finiteness
Introduction to Algorithm 1
The algorithm should produce the output after a finite number of stems for any
input
Effectiveness
MUST be possible to perform each step of the algorithm correctly and in a finite
amount of time
Generality
The algorithm should work for all problems of the desired form
Ways of Writing Algorithm
Flow chart
Pseudo-code
Different Ways on How to Search the Organized Data in
Database
Linear Search
Prose Description: Locate an item in a list by examining the sequence of list
elements one at a time, starting at the beginning
Iterate across the array from left to right, searching for specified element
One by one testing
Binary Search
The input is a list of items in increasing order
It begins by comparing the target with the middle element
If found the position is returned, otherwise 0 when not found
Greedy Search
Optimization problems minimize or maximize some parameter over all possible
inputs
Optimization problems can often be solved by this
Introduction to Algorithm 2
Examples
Finding a route between two cities with the smallest total mileage
Determining how to encode messages using the fewest possible bits
Finding fiber links between network nodes using the least amount of fiber
Bubble Sort
Introduction to Algorithm 3