2. Formal Intro to Data Structures and Algorithms
2. Formal Intro to Data Structures and Algorithms
Algorithms
Topic 2: Formal intro to course
Need for Data Structure
• Data structures organize the data => more efficient programs.
2
Organizing Data
• Any organization for a collection of records that 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.
3
Abstract Data Types
• Collection
• Operations on data
Data abstraction
Composition, specification &
implementation
• Composition of ADT
• Specification of ADT
• Implementation of ADT
wall of ADT operations
The ADT List
• What is a list?
10
Selecting a Data Structure
Select a data structure as follows:
11
Some Questions
• Are all data inserted into the data structure at the beginning, or are
insertions interspersed with other operations?
12
Data Structure Philosophy
Each data structure has costs and benefits.
13
Arrays
16
An Array-Based ADT List
Separation of Files
• any serious project is going to need splitting up into several files in order to be
manageable.
• Advantages of separation of files
1. speed up compilation
2. Increase organization
3. Facilitate code reuse
4. Share code between projects
5. Split coding responsibilities among programmers
• Separate File List has some basic guidelines
• Put things together which are used together
• Create classes for domain objects (eg files, collections etc)
Save as ListA.h
Each new module/package/class will have its separate header file
An Array-Based ADT List
• ListA.cpp
An Array-Based ADT List
• main.cpp