Introduction to data structures - PowerPoint PPT Presentation

1 / 31
About This Presentation
Title:

Introduction to data structures

Description:

e.g. S = representation' Substr(S,3,7) is present' String. Starting point ... e.g. string BINDERSTWINE' with four character-per-word packing. WINE. ERST. BIND. word i ... – PowerPoint PPT presentation

Number of Views:232
Avg rating:3.0/5.0
Slides: 32
Provided by: Dew
Category:

less

Transcript and Presenter's Notes

Title: Introduction to data structures


1
Introduction to data structures
2
Data and Information
  • Data are raw facts
  • Data are aggregated and summarized to form
    meaningful information
  • The result of decision is action, which in turn
    generate more data

3
Data and Information
Decision
Information
Data
Action
4
Kind of Decisions
  • There are 3 levels of decisions
  • Operational decisions, which govern the daily
    activities of the organization.
  • Control decisions or tactical decisions, which
    determine the way the organization executes
    designated mission.
  • Planning decisions or strategic decisions, which
    develop and define the organizations mission.

5
Data Management
  • Data must be managed in such a way that they are
    correct and are available to produce needed
    information.
  • Storage
  • Aggregation
  • Update
  • Retrieval
  • Protection
  • Measurement
  • Collection
  • Transcription
  • Validation
  • Organization

6
Data Management Objectives
  • To make data resilient, flexible, and adaptable
    to supporting decision making process.
  • Data must be represented and stored so that they
    can be accessed later.
  • Data must be organized so that they can be
    selectively and efficiently accessed.
  • Data must be processed and presented so that they
    support the user environment effectively.
  • Data must be protected and managed so that they
    retain their value.

7
What is Data Structures?
  • A data structure is a class of data that can be
    characterized by its organization and the
    operations that are defined on it.
  • Sometimes called data type

8
Classification of Data Structures
  • Primitive data structures i.e.integers, booleans,
    and characters
  • Simple data structures constructed from one or
    more primitives i.e. strings, arrays, and records
  • Linear data structures i.e. stacks, queues, and
    linear linked list
  • Nonlinear data structures i.e. trees and graphs
  • File organizations i.e. sequential, relative,
    indexed sequential, and multikey file
    organizations

9
Integers
  • Operation
  • Binary operators i.e. addition, subtraction,
    multiplication, division, exponentiation, etc.
  • Unary operators i.e. negation

, -3 ,-2 ,-1 ,0 ,1 ,2 ,3 ,
10
Booleans
  • Also called a logical
  • Have one of the two values true or false
  • Operation
  • Binary operators i.e. or and and
  • Unary operator i.e. not
  • Not has precedence over or and and
  • Relational operators i.e. ,They do not have boolean operands rather they
    are operators with boolean results, e.g. 3
    true

11
Booleans
Applied to first operand.
12
Characters
  • is an element taken from a set of symbols, which
    include the numeric digits, the alphabetic
    characters and some special characters.

0,1,2,3,4,5,6,7,8,9,A,B,C,D,,X,Y,Z,
,?,.,,,-,/
13
Strings
  • is a finite sequence of symbols taken from a
    character set which is called alphabet.
  • e.g. alphabet A C,D,1
  • A set of strings derived from alphabet A are
    CD1, CD, DDC, 1D111, and so forth.
  • Three major operations on strings are
  • Length
  • Concatenation
  • Substring

14
Strings
  • String length
  • Length operator has one operand, of type string,
    and produce a result of type integer.

N Length(S)
e.g. S computer Length(S) 8
15
Strings
  • String concatenation
  • Concatenation operates on two strings, placing
    them end to end to produce a resultant string.
  • Concatenation operator has two operands, both of
    type string, and produces a result of type string.

Concat(String1,String2)
e.g. A sale B person Concat(A,B) is
saleperson
16
Strings
  • Substring
  • Substring has a single string as one of its
    operands and generates a new string as its
    result.
  • Substring operator has one operand of type
    string, two operands of type integer, and
    produces a result of type string.

String
Number of characters to take
Substr(S,i,j)
Starting point
e.g. S representation Substr(S,3,7) is
present
17
Strings (Composite Operations)
  • Insertion
  • Insertion operator has two operands of type
    string, one operand of type integer, and produces
    a result of type string.
  • Insert the string S0 into the string S, such
    that the first character of S0 is the ith
    character of the result

Insert(S,S0,i)
e.g. S comment S0 ple Insert(S,
S0,4) is complement
18
Strings (Composite Operations)
  • Deletion
  • Deletion operator has one operands of type
    string, two operands of type integer, and
    produces a result of type string.

Delete(S,i,j)
  • To delete substring of length j that starts at
    the ith character from string S.

e.g. S database Delete(S, 5,4)
??? data
19
Strings and Integers
  • Strings with
  • Integer without or
  • So 1234 and 1234 are different.

Integer value
String value
  • String operators length, concatenation,
    substring- cannot be applied to variables that
    are of integer data type

20
Mapping to Storage Integers
  • One characteristic of logical data structure is
    that it may have several possible storage mapping
    or physical representation.
  • Sign and Magnitude Representation
  • Positive integers are identified by a plus sign
    and a string of digits which represent the
    magnitude.
  • Negative integers are identified by a minus sign
    and a string of digits which represent the
    magnitude.
  • e.g. 250, -100, 7, -7
  • e.g. 500 (-200) ?

21
Mapping to Storage Integers
  • Ones-Complement Representation
  • Ones-complement can be used to represent
    negative numbers.
  • Ones complement of X can be formed by
    subtracting from a long string of one. (Reverting
    bits of positive X from 1 to 0 and 0 to 1)
  • e.g. The ones complement form of 0101 (5) is
    represented as 1 1 1 1
  • 0 1 0 1-
  • 1 0 1 0 (-5)
  • e.g. 7 (5) ?

1
1
1
0111
1010
0010
1
0
0
0
22
Mapping to Storage Integers
  • Twos-Complement Representation
  • An easier method to get the two's complement of a
    number is as follows
  • 1. Starting from the right, find the first '1
  • 2. Invert all of the bits to the left of that
    one
  • Example
  • 0101001
  • 1010111

23
Mapping to Storage Integers
  • Twos-Complement Representation
  • To convert to -5 in twos complement notation,
    locate the first 1 in binary representation of 5
    (0101), and reverse all remaining left bits
  • 1011 (-5)
  • e.g. 7 (5) ?

1
1
1
1
ignored
0111
1011
0010
0
1
0
0
24
Mapping to Storage Characters
  • The two most prevalent encoding schemes are
  • Extended Binary Coded Decimal Interchange Code
    (EBCDIC)
  • 8 bits are required to represent any character in
    the character set.
  • American Standard Code for Information
    Interchange (ASCII)
  • 7 bits are required to represent any character in
    the character set.
  • Consume less storage and can be transmitted more
    quickly.

25
Mapping to Storage Characters
  • Special purpose schemes
  • Huffman Code
  • Characters are represented by a variable number
    of bits depending upon the relative frequency of
    occurrence of the character in the vocabulary of
    the application.
  • e.g.

26
Mapping to Storage Strings
  • To store string in storage, pointer which
    identifies a storage location is required.
  • e.g. string1ABCDEFG, string2BCD
  • There are 3 simple ways to store string variable
    in contiguous space.
  • 1.Keep string name, starting address, and length
  • The corresponding storage format could be
  • A B C D E F G B C D

PTR1S
PTR2S
27
Mapping to Storage Strings
  • 2.Keep strings name, its starting address, and
    terminating address
  • The corresponding storage format could be
  • A B C D E F G B C D
  • OR (overlaying the strings)

PTR1S
PTR1T
PTR2T
PTR2S
A B C D E F G
PTR1S
PTR1T
PTR2S
PTR2T
28
Mapping to Storage Strings
  • 3.Keep strings name and its starting address. Use
    an end of string marker in storage to delimit the
    string.
  • The corresponding storage format could be
  • A B C D E F G B C D

PTR1S
PTR2S
29
Mapping to Storage Strings
  • Packed-String Representation
  • Placing each of the successive codes for the
    characters in successive storage words, with as
    many of the characters as possible in any given
    word.
  • e.g. string BINDERSTWINE with four
    character-per-word packing

word i
word i1
word i2
30
Mapping to Storage Strings
  • Packed-String Representation
  • Number of words required to store string S is
    Length(S)/K, where K represents characters per
    word.
  • For example, String S decisionmaker with 32
    bits per word.
  • Number of words required is 13/4 4 words
  • Sometimes the character codes fit words evenly
    If there are 16 bits per word, EBCDIC with 8 bits
    per character fits very well. However, ASCII,
    with 7 bits per characters, will allow two
    characters in a 16-bit word with two unusable
    bits remaining.

31
Mapping to Storage Strings
  • Unpacked-String Representation
  • Storing one to a word the character codes for
    each of the successive characters.
  • e.g. string BINDERSTWINE stored in unpacked
    format as follow
  • The number of words required to store string S in
    unpacked format is Length(S).
Write a Comment
User Comments (0)
About PowerShow.com