Lower Bound for Comparison Sort
ESO207
Indian Institute of Technology, Kanpur
Overview
We have seen several sorting algorithms so far,
Heapsort, Mergesort and Quicksort.
Heapsort and Mergesort can sort n numbers in time
O(n log n) time. Quicksort achiev
Lecture # 1-2
Dr. Qamar Abbas
Books
C+ Plus Data Structure by Nell Dale, 3 rd
Edition
Data Structures & Algorithms in Java by M. T.
Goodrich 6th Edition
A Practical Introduction to Data Structures and
Algorithm Analysis C. A. Shaffer 3rd Edition
Data Stru
International Islamic University, Islamabad
Faculty of Basic & Applied Sciences
Department of Computer Science & Software Engineering
Data Structure and Algorithms
Program:BSSE/BSCS Fall-2015
Course Code:CS 212(DSA)
Assignment No. I
(For BSSE-F15-A)
_
Ins
Lecture # 3-4
Dr. Qamar Abbas
Algorithm
An algorithm is a finite set of steps
defining the solution of a particular
problem.
Need not to belong one particular
language
Sequence of English statements can also
be algorithm
It is not a computer program
An al
DataStructuresandAlgorithms
(ESO207/ESO211)
Lecture2
Time complexity
Big O notation
Solving a problem: Maximum sum subarray
1
Time complexity of an algorithm
2
Example:
Time complexity of matrix multiplication
Matrix-mult(C[n,n],D[n,n])
cfw_
for i = 0 to
DataStructuresandAlgorithms
(ESO207A/ESO211)
Lecture4-5
Heaps
1
Binary tree
The simplest among the tree data
structures (but useful).
Tree has a root node.
10
rootnode
Each node has at most two children, left
Example
internalnode
height=2 9 node. 7
node a
Hash Tables
ESO207
Indian Institute of Technology, Kanpur
Introduction
Consider a dynamic set that supports dictionary
operations, I NSERT, S EARCH and D ELETE.
Previously, the L IST (and even S TACK and Q UEUE) data
structures can support the above ope
DataStructuresandAlgorithms
(ESO207A/ESO211)
Lecture7
Linked Lists
1
Singly Linked Lists
L
Linkedlistsareelementsarrangedinalinearorder.
5
next
9
next
3
next
15
next
3
NIL
Examplelistwith5elements:(5,9,3,15,3)
Eachlistnodecontainsakeyfieldandanextfield,wh
DataStructuresandAlgorithms
(ESO207A/ESO211)
Lecture6
Stacks, Queues
1
Stacks and Queues
We will look at two classical data
structures, Stacks and Queues.
Both model dynamic set of elements, that
is, set of elements where elements are
inserted and/or dele
Binary Search Trees-I
ESO207
Indian Institute of Technology, Kanpur
Introduction
We will now begin our study of the Search trees data
structure that supports dynamic set operations such as
S EARCH, I NSERT, D ELETE, M INIMUM, M AXIMUM,
P REDECESSOR and S
ESO 207
Hints and Solutions: Practice Problems - 2
Devendra Agrawal and Rachit Nimavat
TA, ESO207
September 6, 2014
1. For each half you need to store 4 things, Best Sum of the Half , Best Prex Sum
and Best Sux Sum of the Half and the overall sum of the H
ESO 207
Hints and Solutions: Practice Problems - 1
Devendra Agrawal and Rachit Nimavat
TA, ESO207
September 6, 2014
1.
Find the sum of all numbers in the array , let's call it as Sum_from_Array.
Find the sum of all numbers from 1 to N , let's call it as T
ESO207: Data Structures and Algorithms
Practice Problems 3
Solutions
Practice Problems: Hashing (Sample Solution)
Topics: Hash Tables.
Problem 3-1. [CLRS 11.4-4] Suppose that we use double hashing to resolve collisionsthat is, the
hash function is dened a
ESO 207
Practice Problems - 2
Devendra Agrawal
Rachit Nimavat
September 2, 2014
1. The maximum subarray problem is to nd the contiguous subarray within a onedimensional array of numbers (containing at least one positive number) which has
the largest sum.
ESO207: Data Structures and Algorithms
Practice Problems 3
Hash tables
Practice Problems: Hashing
Problem 3-1. [CLRS 11.4-4] Suppose that we use double hashing to resolve collisionsthat is, the
hash function is dened as h(k, i) = (h1 (k) + i h2 (k) mod m.
ESO 207
Practice Problems - 1
Devendra Agrawal and Rachit Nimavat
TA, ESO207
August 9, 2014
These are practice problems. They may be discussed in classes and/or solutions to the problems
will be posted. These problems are not for submission.
1. General. G
Lecture # 5-6
Dr. Qamar Abbas
Array Operations
Although we can apply conventional operations
defined for each element of an array , there are some
operations that we can define on an array as a data
structure. The common operations on arrays as
structures