Download presentation
Presentation is loading. Please wait.
Published byAltan Mungan Modified over 5 years ago
1
Data Structures Goal: organize data Criteria: facilitate efficient
storage of data retrieval of data manipulation of data Process: select and design appropriate data types
2
Examples
3
Tradeoff
4
abstract data type (ADT)
5
implementation of an ADT
7
Simple Data Types (§2.2)
8
Boolean data
9
Character Data
10
Integer Data
11
Sign-magnitude representation
12
Two's complement representation
14
Biased representation
15
Problems with Integer Representation
Limited Capacity -- a finite number of bits Overflow - addition or multiplication can exceed largest value permitted by storage scheme Underflow - subtraction or multiplication can exceed smallest value permitted by storage scheme Not a perfect representation of (mathematical) integers can only store a finite (sub)range of them
16
Real Data
17
Problems with Real Representation
18
C-Style One-Dimensional Arrays (§2.3)
19
Declaring arrays in C++
20
Subscript operator
22
Array Initialization
25
Initializations with no array size specified
26
Addresses
28
C-Style Multidimensional Arrays
35
Problems with C-Style Arrays
Capacity cannot change. No predefined operations on non-char arrays. ® Must perform bounds checking, size restrictions, ... C-style arrays aren't self-contained. ® Must pass size (and/or capacity) to array-processing functions. Solution (OOP): Encapsulate array, capacity, size, and operations in a class. ® vector
42
A commercial for OOP: Two programming paradigms
Object-oriented: ( C++, Java, and Smalltalk) Focuses on the nouns of a problem's specification Programmers: Determine what objects are needed for a problem and how they should work together to solve the problem. Create types called classes made up ofdata members and function members to operate on the data. Instances of a type (class) are called objects. Procedural: ( C, FORTRAN, and Pascal ) Action-oriented — concentrates on the verbs of a problem's specification Programmers: Identify basic tasks to be performed to solve problem Implement the actions required to do these tasks as subprograms (procedures/functions/subroutines) Group these subprograms into programs/modules/libraries, which together make up a complete system for solving the problem
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.