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
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