Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 A Introduction to Data Structures and Algorithm Analysis Data Structures Asst. Professor Kiran Soni.

Similar presentations


Presentation on theme: "1 A Introduction to Data Structures and Algorithm Analysis Data Structures Asst. Professor Kiran Soni."— Presentation transcript:

1 1 A Introduction to Data Structures and Algorithm Analysis Data Structures Asst. Professor Kiran Soni

2 2 The Need for Data Structures Data structures organize data  more efficient programs. More powerful computers  more complex applications. More complex applications demand more calculations. Complex computing tasks are unlike our everyday experience.

3 3 What is a data structure? In a general sense, any data representation is a data structure. Example: An integer More typically, a data structure is meant to be an organization for a collection of data items.

4 4 Organizing Data Any organization for a collection of records can be searched, processed in any order, or modified. The choice of data structure and algorithm can make the difference between a program running in a few seconds or many days.

5 5 Efficiency A solution is said to be efficient if it solves the problem within its resource constraints. Space Time The cost of a solution is the amount of resources that the solution consumes.

6 6 Selecting a Data Structure Select a data structure as follows: 1. Analyze the problem to determine the resource constraints a solution must meet. 2. Determine the basic operations that must be supported. Quantify the resource constraints for each operation. 3. Select the data structure that best meets these requirements.

7 7 Data Structure Philosophy Each data structure has costs and benefits. Rarely is one data structure better than another in all situations. A data structure requires: space for each data item it stores, time to perform each basic operation, programming effort.

8 8 Data Structure Philosophy Each problem has constraints on available space and time. Only after a careful analysis of problem characteristics can we know the best data structure for the task. Bank example: Start account: a few minutes Transactions: a few seconds Close account: overnight continued

9 9 Goals of this Course 1. Reinforce the concept that costs and benefits exist for every data structure. 2. Learn the commonly used data structures. These form a programmer's basic data structure ``toolkit.'‘ 3. Understand how to measure the cost of a data structure or program. These techniques also allow you to judge the merits of new data structures that you or others might invent.

10 10 Abstract Data Types Abstract Data Type (ADT): a definition for a data type solely in terms of a set of values and a set of operations on that data type. Each ADT operation is defined by its inputs and outputs. Encapsulation: Hide implementation details.

11 11 Data Structure A data structure is the physical implementation of an ADT. Each operation associated with the ADT is implemented by one or more subroutines in the implementation. In a OO language such as C++, an ADT and its implementation together make up a class. Data structure usually refers to an organization for data in main memory. File structure: an organization for data on peripheral storage, such as a disk drive.

12 12 Logical vs. Physical Form Data items have both a logical and a physical form. Logical form: definition of the data item within an ADT. Ex: Integers in mathematical sense: +, - Physical form: implementation of the data item within a data structure. Ex: 16/32 bit integers, overflow.

13 13 Data Type ADT: Type Operations Data Items: Logical Form Data Items: Physical Form Data Structure: Storage Space Subroutines

14 14 Algorithms and Programs Algorithm: a method or a process followed to solve a problem. A recipe: The algorithm gives us a “recipe” for solving the problem by performing a series of steps, where each step is completely understood and doable. An algorithm takes the input to a problem (function) and transforms it to the output. A mapping of input to output. A problem can be solved by many algorithms.

15 Jay Hind 15


Download ppt "1 A Introduction to Data Structures and Algorithm Analysis Data Structures Asst. Professor Kiran Soni."

Similar presentations


Ads by Google