Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 1 Data Structures and Algorithms. Primary Goals Present commonly used data structures Present commonly used data structures Introduce the idea.

Similar presentations


Presentation on theme: "Chapter 1 Data Structures and Algorithms. Primary Goals Present commonly used data structures Present commonly used data structures Introduce the idea."— Presentation transcript:

1 Chapter 1 Data Structures and Algorithms

2 Primary Goals Present commonly used data structures Present commonly used data structures Introduce the idea of tradeoffs; reinforce the concept of costs and benefits associated with every data structure Introduce the idea of tradeoffs; reinforce the concept of costs and benefits associated with every data structure Measure the effectiveness of a data structure or algorithm Measure the effectiveness of a data structure or algorithm

3 Computer Programming Goals There are two, sometime conflicting: There are two, sometime conflicting: 1. To design an algorithm that is easy to understand, code and debug 2. To design an algorithm that make efficient use of the computer’s resources. This course is mainly concerned with goal number 2. This course is mainly concerned with goal number 2.

4 What is a data structure? In the most general, a data structure is any data representation and its associated operations. In the most general, a data structure is any data representation and its associated operations. More typically, a data structure is meant to be an organization or structuring for a collection of data items. More typically, a data structure is meant to be an organization or structuring for a collection of data items.

5 Efficiency and Cost A solution to a problem is efficient if it solves the problem within the required resource constraints A solution to a problem is efficient if it solves the problem within the required resource constraints Examples: total space to store data, time allowed to perform Examples: total space to store data, time allowed to perform The cost of a solution is the amount of resources that the solution consumes. The cost of a solution is the amount of resources that the solution consumes. Often the cost is measured in terms of one key resource Often the cost is measured in terms of one key resource

6 Efficiency and Cost A solution can also be efficient if it requires fewer resources than other know solutions A solution can also be efficient if it requires fewer resources than other know solutions When solving problems, you will want to analyze the different data structures available and choose accordingly. When solving problems, you will want to analyze the different data structures available and choose accordingly. You want to make sure you choose both efficient and cost effective solutions You want to make sure you choose both efficient and cost effective solutions Conversely, you don’t need a sledge hammer to put in a thumbtack Conversely, you don’t need a sledge hammer to put in a thumbtack

7 Choosing your Data Structure You should follow these steps You should follow these steps 1. Analyze your problem to determine the resource constraints that any solution must meet 2. Determine the basic operations that must be supported and quantify the resource constraints for each operation 3. Select the data structure that best meets these requirements

8 Operational Questions When choosing data structures, here are some questions to ask. When choosing data structures, here are some questions to ask. Are all data items inserted into the data structure at the beginning, or are the insertions interspersed with other operations? Are all data items inserted into the data structure at the beginning, or are the insertions interspersed with other operations? Can data items be deleted? Can data items be deleted? Are all data items process in some well-defined order, or is search for specific data items allowed? Are all data items process in some well-defined order, or is search for specific data items allowed?

9 Abstract Data Types and Data Structures Type a collection of values Type a collection of values A simple type has no subparts A simple type has no subparts An aggregate type or composite type contains several pieces of information An aggregate type or composite type contains several pieces of information A data item is a piece of information or a record whose value is drawn from a type. A data item is a piece of information or a record whose value is drawn from a type. It is said to be a member of a type It is said to be a member of a type A data type is a type together with a collection of operations to manipulate the type. A data type is a type together with a collection of operations to manipulate the type.

10 Abstract Data Types and Data Structures There is a distinction between the logical concept of a data type and its physical implementation There is a distinction between the logical concept of a data type and its physical implementation Example: Trees can be implemented both in a linked fashion or an array based fashion Example: Trees can be implemented both in a linked fashion or an array based fashion An Abstract Data Type (ADT) is the realization of a data type as a software component. An Abstract Data Type (ADT) is the realization of a data type as a software component. An ADT does not specify how the data type is implemented An ADT does not specify how the data type is implemented

11 Abstract Data Types and Data Structures A data structure is the implementation for an ADT A data structure is the implementation for an ADT ADT’s allow programmers to manage complexity through abstraction ADT’s allow programmers to manage complexity through abstraction Data items have both a logical and a physical form Data items have both a logical and a physical form The definition of the data item in terms of an ADT is the logical form The definition of the data item in terms of an ADT is the logical form The implementation of the data item within the data structure is its physical form The implementation of the data item within the data structure is its physical form


Download ppt "Chapter 1 Data Structures and Algorithms. Primary Goals Present commonly used data structures Present commonly used data structures Introduce the idea."

Similar presentations


Ads by Google