Академический Документы
Профессиональный Документы
Культура Документы
Algorithms
Course organization
We will use the Course Management System Piazza
(https://piazza.com) for managing course materials
and announcements. Please wait for invitation via
email to join Piazza.
Twice a week Tuesday ( 1 hour) and Friday (2
hours) Tutorial and Lecture
Text book
Data Structures using C and C++, Second
Edition. Langsam, Augenstein, Tenenbaum
Evaluation scheme
Semester evaluation 50%
End-Semester evaluation 50%
About the course
Course organization
Data Search
Processor Speed
Multiple Requests
Worst case
Maximum execution time or consumption of other resources.
Average case
Average execution time or consumption of other resources.
Best case
Least possible execution time or consumption of other
resources.
Basic Terminology
Search
Sort
Characteristics of an Algorithm
Example 1
result
step 1 START
step 2 declare three integers a, b & c
step 3 define values of a & b
step 4 add values of a & b
step 5 store output of step 4 to c
step 6 print c
step 7 STOP
Algorithms tell the programmer how to code the program.
Writing an algorithm
result
Analyzing algorithms
Suppose X is an algorithm and n is the size of input data, the time and
space used by Algorithm X are the two main factors which decide the
efficiency of X.
input data.
Space Complexity
Example
Algorithm: SUM(A, B)
Step 1 - START
Step 2 - C A + B + 10
Step 3 - Stop
(Omega) Notation
(Theta) Notation
Asymptotic Notations
(Big Oh) Notation
The O(n) is the formal way to express the upper bound of an
algorithms running time.
It measures the worst case time complexity or longest amount
of time an algorithm can possibly take to complete.
O(1)
logarithmic O(logn)
linear O(n)
n log n O( n log n)
quadratic O(n2)
cubic O(n3)
polynomial nO(1)
exponential 2O(n)
Data Structures Basic Concepts
Data Structure is a way to organize data in such a way that it can
be used efficiently.
Data Definition
A particular data can be defined with the following characteristics:
Atomic Definition defines a single concept.
Traceable Definition should be able to map to some data
element.
Accurate Definition should be ambiguous.
Clear and Concise Definition should be understandable.
Data Structures Basic Concepts
Data Object represents an object having a data.
Data Type
Data type is a way to classify various types of data such as
integer, string etc. which determines:
The values that can be used with the corresponding type of data
The type of operations that can be performed on the
corresponding type of data.
Data are of two types:
Built-in data type
Derived data type
Data Structures Basic Concepts
Built-in Data Type
Those data types for which a language has built-in support. For
example, most of the language provides the following built-in data
types:
Integers
Boolean(true, false)
Floating(Decimal numbers)
Characters and Strings
Data Structures Basic Concepts
Derived Data Type
These are implementation independent as they can be
implemented in one way or the other. These data types are
normally built by a combination of primary or built-in data types
and associated operations on them. For example,
List
Array
Stack
Queue
Data Structures Basic Concepts
Basic Operations
The data in the data structures are processed by certain
operations. The choice of a particular data structure largely
depends on the frequency of the operation that needs to be
performed on the data structure:
Traversing
Searching
Insertion
Deletion
Sorting
Merging
Next Lecture