0% found this document useful (0 votes)
4 views

1_Introduction to Algorithms

The document provides an introduction to algorithms, defining them as sequences of instructions for problem-solving with characteristics such as input, output, finiteness, definiteness, and effectiveness. It discusses the analysis of algorithms based on time and space complexity, introducing asymptotic notations like Big Oh, Big Omega, and Big Theta for efficiency evaluation. Additionally, it outlines important problem types and fundamental data structures relevant to algorithm design.

Uploaded by

klavidaesbella56
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

1_Introduction to Algorithms

The document provides an introduction to algorithms, defining them as sequences of instructions for problem-solving with characteristics such as input, output, finiteness, definiteness, and effectiveness. It discusses the analysis of algorithms based on time and space complexity, introducing asymptotic notations like Big Oh, Big Omega, and Big Theta for efficiency evaluation. Additionally, it outlines important problem types and fundamental data structures relevant to algorithm design.

Uploaded by

klavidaesbella56
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Introduction to Algorithms

Overview
• What is an Algorithm?
• Fundamentals of Algorithmic ‘Problem solving’
• Important Problem Types
• Fundamental Data Structures
What is an
Algorithm?
An algorithm is a sequence of unambiguous instructions for
solving a problem, i.e., for obtaining a required output for any
legitimate input in a finite amount of time.

• Can be represented various forms


• Unambiguity/clearness
• Effectiveness
• Finiteness/termination
• Correctness
Characteristics of Algorithm
• Input
• Algorithm must contain zero or more input
• Output
• Algorithm must contain one or more output
• Finiteness
• Algorithm must complete after finite number of steps
• Definiteness
• The step of the algorithm must be defined precisely or clearly(unambiguous)
• Effectiveness
• The step of the algorithm must be effective (can be done successfully)
Analysis of Algorithms
• Analysis of algorithm depend upon the time and memory taken by
the algorithm.
• Time – Efficient algorithm if it takes very less time
• Memory (space) – how much memory an algorithm consumes to give
effective output

• Time Complexity – The amount of time required by the algorithm


• Space Complexity – The amount of space or memory required by the
algorithm
Growth functions
Asymptotic Notations
• There are 3 notations for analyzing the time complexity (majorly)
• These are the terminologies used for determining the efficiency of
algorithms

1. Big Oh (O) – indicates the worst-case scenario


2. Big Omega (Ω) – indicates the best-case scenario
3. Big Theta (ϴ) – indicates the average-case scenario

• Running time analysis – Determine how running time increases as the size
of the problem increases ie as per increase time we will determine the
growth in the ‘n’ value (size of the input).
• Euclid’s algorithm for finding the greatest common divisor
• If we subtract smaller number from larger (we reduce larger number),
GCD doesn’t change. So if we keep subtracting repeatedly the larger
of two, we end up with GCD.
• Now instead of subtraction, if we divide smaller number, the
algorithm stops when we find remainder 0.
Important Problem Types
• Sorting
• Searching
• Shortest paths in a graph
• Minimum spanning tree
• Traveling salesman problem
• Knapsack problem
• Chess
• Towers of Hanoi
• Program termination

Some of these problems don’t have efficient algorithms, or algorithms at all!


Fundamental Data Structures

• list • graph
• array • tree and binary tree
• linked list • set and dictionary
• string
• stack
• queue
• priority queue/heap
Doubly Linked List
• https://www.thecodingdelight.com/doubly-linked-list/

You might also like