3. Course Objectives:
The course intends to provide concrete implementations and
manipulation of discrete structures and their use in design and
analysis of non-trivial algorithms for a given computational task by
teaching the students fundamentals of Algorithms and Data
Structures.
5. MODES OF CONTINUOS ASSESSMENT /
EVALUATION
ISE: In-Semester Examination
IE: Innovative Examination
ESE: End Semester Examination
6.
7.
8.
9.
10. INNOVATIVE EXAMINATION
This examination included in the Syllabus for 20 Marks
Purpose is to evaluate student w.r.t understanding the
Subject concepts and its use to designs small applications.
In Innovative Practice Students in a group or individually can
identify and implement given/self identified problem
definition.
During the Semester Submission Small Report and
Presentation of IE needs to be Submitted and presented the
same during Oral Examination
11. RESEARCH OPPORTUNITIES
1. Search engine for data structures
2. Phone directory application using doubly-linked
lists
3. Spatial indexing with quadtrees
4. Graph-based projects on data structures
5. Stack-based text editor
12. MODULE -1
COMPLEXITY ANALYSIS
• Time & Space Complexity of Algorithms
• Importance of Efficient Algorithms
• Calculating time complexity of operations on data
structures (insert, delete, search, display)
• Total= 4 hrs
13. Time & Space Complexity
Time complexity of an algorithm signifies the total time required by the program to
run till its completion.
The time complexity of algorithms is most commonly expressed using the big O
notation. It's an asymptotic notation to represent the time complexity.
Time Complexity is most commonly estimated by counting the number of elementary
steps performed by any algorithm to finish execution. Like in the example above, for
the first code the loop will run n number of times, so the time complexity will
be n atleast and as the value of n will increase the time taken will also increase.
While for the second code, time complexity is constant, because it will never be
dependent on the value of n, it will always give the result in 1 step.
14. Algorithm Analysis
The algorithm can be analyzed in two levels, i.e., first is before creating the
algorithm, and second is after creating the algorithm. The following are the two
analysis of an algorithm:
Priori Analysis: Here, priori analysis is the theoretical analysis of an algorithm
which is done before implementing the algorithm. Various factors can be
considered before implementing the algorithm like processor speed, which has
no effect on the implementation part.
Posterior Analysis: Here, posterior analysis is a practical analysis of an
algorithm. The practical analysis is achieved by implementing the algorithm
using any programming language. This analysis basically evaluate that how
much running time and space taken by the algorithm.
15. Performance Analysis of an algorithm
Performance analysis of an algorithm is the process of calculating space and time
required by that algorithm.
Performance analysis of an algorithm is performed by using the following measures...
1. Space required to complete the task of that algorithm (Space Complexity). It includes
program space and data space.
2. Time required to complete the task of that algorithm (Time Complexity)
What is Time complexity?
The time complexity of an algorithm is the total amount of time required by an algorithm to
complete its execution. The running time of an algorithm depends upon the following...
1. Whether it is running on Single processor machine or Multi processor machine.
2. Whether it is a 32 bit machine or 64 bit machine.
3. Read and Write speed of the machine.
4. The amount of time required by an algorithm to perform Arithmetic operations, logical
operations, return value and assignment operations etc.,
5. Input data
16. Example
Consider the following piece of code..
int sum(int A[], int n)
{ int sum = 0, i; for(i = 0; i < n; i++)
sum = sum + A[i];
return sum;
}
For the above code, time complexity can be calculated as follows
18. Linear Search
It is one of the most simple and straightforward search
algorithms. In this, you need to traverse the entire list and keep
comparing the current element with the target element. If a
match is found, you can stop the search else continue.
Complexity Analysis
Time Complexity
•Best case - O(1)
The best occurs when the target element is found at the
beginning of the list/array. Since only one comparison is made,
the time complexity is O(1).
Example -
Array A[] = {3,4,0,9,8}
Target element = 3
Here, the target is found at A[0].
19. •Worst-case - O(n), where n is the size of the list/array.
The worst-case occurs when the target element is found at the end of the list or is
not present in the list/array. Since you need to traverse the entire list, the time
complexity is O(n), as n comparisons are needed.
•Average case - O(n)
The average case complexity of the linear search is also O(n).
Space Complexity
The space complexity of the linear search is O(1), as we don't need any auxiliary
space for the algorithm.
20. Binary Search
It is a divide and conquers algorithm in which we compare the target element with the
middle element of the list. If they are equal, then it implies that the target is found at the
middle position; else, we reduce the search space by half, i.e. apply binary search on
either of the left and right halves of the list depending upon whether target<middle
element or target>middle element. We continue this until a match is found or the size of
the array reaches 1.
Time Complexity
•Best case - O(1)
The best-case occurs when the target element is found in the middle of the
original list/array. Since only one comparison is needed, the time complexity is
O(1).
•Worst-case - O(logn)
The worst occurs when the algorithm keeps on searching for the target element
until the size of the array reduces to 1. Since the number of comparisons
required is logn, the time complexity is O(logn).
21. Binary Search
•Average case - O(logn)
Binary search has an average-case complexity of O(long).
Space Complexity
Since no extra space is needed, the space complexity of the binary search is
O(1).