Sie sind auf Seite 1von 23

Data Structures EC 251

Number of credits: 5 Lectures: M and W 10-11 F 9-10 Tutorials: one hour per week there are 4 batches for Tutorials Practical: two hours per week there are 3 batches room no W204

EC251 Fall 2008 Rajdeep Niyogi IITR

Lab Batches Tuesday 2-4pm CSE 070801 to 070831 Wed 3-5pm ECE 070501 to 070535 Ths 2-4pm remaining students Fix your machine and work all throughout the semester. If it has to be changed, inform me and the lab assistants.
EC251 Fall 2008 Rajdeep Niyogi IITR 2

Tutorial batches W: 2-3pm ECE 070501 to 070524 (24) 3-4pm CSE 070801 to 070824 (24) 4-5pm CSE remaining and IDD CSE 12-1pm remaining of ECE + IDD ECE and back

F:

EC251 Fall 2008 Rajdeep Niyogi IITR

Instructors
Course and Tutorial instructor: R Niyogi
rajdpfec@iitr.ernet.in

office: S211 Preference: meeting with students by appointment Lab instructors: R Niyogi for two batches A Mittal for the other batch

EC251 Fall 2008 Rajdeep Niyogi IITR

Components

Relative weightage: ETE 40 MTE 30 PRS 15 CWS 15 CWS: constitutes tutorial, quiz
PRS: laboratory exercises

All announcements regarding the course Will be made in the classroom.

EC251 Fall 2008 Rajdeep Niyogi IITR

Suggested Books
Data Structures and algorithms in C++ by Adam Drozdek. 2001 Data Structures, algorithms, and applications in C++ by Sartaj Sahni. 2001 Algorithms and Data Structures by Niklaus Writh. 1985 Introduction to Algorithms by Cormen, Rivest, and Lieserson.
EC251 Fall 2008 Rajdeep Niyogi IITR 6

Introduction
Data structures provide a way of storing data in a computer so that it can be used efficiently. [wkpd] Data structures that are commonly used: 1. Array 2. Linked list 3. Stack 4. Queue 5. Binary tree, Heap 6. K-ary tree
EC251 Fall 2008 Rajdeep Niyogi IITR 7

Introduction
It is not appropriate to compare two DSs to suggest that x is better than y Rather, for an application in mind we need to suggest which DS is suitable for the purpose. If none suits properly, design a new data structure.

EC251 Fall 2008 Rajdeep Niyogi IITR

Introduction
Given, for some data set d we have designed or have decided to use a DS say x. What are we going to do with x ? This in turn implies what are we going to do with d? This in turn suggests some operations on the data set.
EC251 Fall 2008 Rajdeep Niyogi IITR 9

Introduction
some operations on the data set:
Example: Array: our first data structure Say we have an array of integers Int alpha[5] alpha = [3,7,2,1,5] 1. Reverse the array to get [5,1,2,7,3] 2. Sort the array to get [1,2,3,5,7] 3. Increase/decrease the middle element by one 4. Multiply each element with itself i.e., a2 Here we are concerned with operations on a static data

EC251 Fall 2008 Rajdeep Niyogi IITR

10

Motivation
Our concern is regarding dynamic data. Data sets that can shrink or grow. Suppose we want to remove the middle element of alpha. How can this be achieved? The intended operation is to shrink the data set by one. When we use an array: the objective is satisfied partially. In the computer memory the array size remains the same! We already know that the operation alpha[5] is undefined; Thus the data set cannot grow! This provides the motivation to talk about efficient DSs that will serve the purpose.
EC251 Fall 2008 Rajdeep Niyogi IITR 11

Motivation
It should however be noted that arrays provide an excellent way to store and organize data. Shortly we shall encounter another data structure called Tree. w.r.t this example array is better than tree Claim: for static data, arrays are the best choice. Proof: to be established in due course .
EC251 Fall 2008 Rajdeep Niyogi IITR 12

Motivation
Operations on dynamic data 1. Add a new element 2. Delete an element from the data set 3. Find the element with maximum value 4. Find the element with minimum value 5. Find the next highest, smallest valued element

EC251 Fall 2008 Rajdeep Niyogi IITR

13

Motivation
Let us consider the operations 3-5: Consider a tree representation of the data set
3 2 1 7

EC251 Fall 2008 Rajdeep Niyogi IITR

14

Motivation
Now we ask the question: when should we consider arrays and when trees? As we said, DSs are for some application in mind. The example is too trivial to suggest opting for trees. Now consider representing a family tree. Trees are the intuitive data structure for the purpose. A data structure should also reflect, resemble the convenient way that humans normally store or represent data.
EC251 Fall 2008 Rajdeep Niyogi IITR 15

Motivation
Some common representations of data by humans: pyramid How does a fruit vendor store oranges, mangoes? How does an office clerk store the office files? stack When a person goes to a railway counter to buy a ticket what does he see (normally) before him? queue Often we find someone from behind getting his ticket. How to priority queue represent this feature? If a person wants to know whether there is a rail connectivity between two locations what does he normally refer to? Map (technically, we call it a graph)
EC251 Fall 2008 Rajdeep Niyogi IITR 16

Motivation
Some common representations of data by humans (contd.) How can we represent an office hierarchy, state administration? K-Tree How can we represent file systems in a computer? K-Tree How can we represent the internet domain naming system? K-Tree If someone encounters the word nepotism for the first time, what should he do? Dictionary
EC251 Fall 2008 Rajdeep Niyogi IITR 17

Algorithms and DSs


An Algorithm designer is not concerned with DSs. Generally, an algorithm should be independent of the DS (actually) used. We should be able to verify its functioning with a pen and a paper. The only (sufficient) prerequisite for doing the verification is the knowledge of sets, lists, in most cases.
EC251 Fall 2008 Rajdeep Niyogi IITR 18

Aims of the course


When we implement an algorithm, a data structure is used---whether it is good or bad. A good, well-designed data structure leads to better performance. Thus the aims of this course : To understand the elementary DSs (operations, applications, usefulness) To implement the DSs To analyze and test the performance of the DSs
EC251 Fall 2008 Rajdeep Niyogi IITR 19

Objective of this course


The objective is to provide a foundation for understanding advanced data structures, and for independently designing efficient DSs

EC251 Fall 2008 Rajdeep Niyogi IITR

20

The Flow of the course


How do we intend to meet our aims and objectives?
Brief ideas of algorithms, computing model,computer Analyzing algorithms (best-case, worst-case, average case) brief introduction to basic mathematical objects (sets, graphs, trees) consider elementary DSs

EC251 Fall 2008 Rajdeep Niyogi IITR

21

Course Structures
In the lectures we shall use pseudocodes for understanding, analyzing, implementing the DSs. In the practicals we shall implement the DSs using an object-oriented language (C++) In the Tutorials we shall do exercises to acquire knowledge on the theoretical aspects of DSs.
EC251 Fall 2008 Rajdeep Niyogi IITR 22

When can we achieve?


Sincerity [be punctual in coming to the class, tut, lab] Decorum [do not create disturbance in the classroom]
this adversely affects the Instructor It also affects your classmates the overall class performance goes down this leads to wasting time

Honesty [if you think the Instructor did not explain some points
clearly, make it a point to contact him personally and ensure that the doubt is clarified.] feel free to contact me without any hesitation on any matters regarding the course. Cooperation [with all Instructors, TAs, and lab assistants] most imp. Class Attendance: obs., skip-in-totoinstitute rules
[end of lec.]

EC251 Fall 2008 Rajdeep Niyogi IITR

23

Das könnte Ihnen auch gefallen