CSCE 210 Data Structures and Algorithms - PowerPoint PPT Presentation

Loading...

PPT – CSCE 210 Data Structures and Algorithms PowerPoint presentation | free to view - id: 248275-ZjgwO



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

CSCE 210 Data Structures and Algorithms

Description:

Introduction to S/W Design. Software for Problem Solving. Software Development Process ... using namespace std; typedef int itemtype ; // Function Prototypes ... – PowerPoint PPT presentation

Number of Views:90
Avg rating:3.0/5.0
Slides: 26
Provided by: dramrg
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: CSCE 210 Data Structures and Algorithms


1
CSCE 210 Data Structures and Algorithms
  • Prof. Amr Goneid
  • AUC
  • Part 1. Introduction to S/W Design

2
Introduction to S/W Design
  • Software for Problem Solving
  • Software Development Process
  • Top-Down Design
  • Elements of Module Design
  • Example of a Design Document

3
1.Software for Problem Solving
  • Use of S/W

Problem Domain
S/W
TO
Decide, Learn, View Interact, Play, …….
4
2. Software Development Process
  • Stages of S/W Production

Specify Requirements
Solution Strategy
S/W Production
S/W Testing
Problem Definition
Maintenance Upgrade
5
Software Production

Implementation (Programs)
Debugging
S/W Design
Performance Analysis / Benchmarks
6
3. Top-Down Design
  • Divide and Conquer Strategy.
  • Given problem X (Level 0). Divide it into
    sub-problems X1, X2, …, Xn (Level 1) such that
    solving X1, then X2, then … solves X completely.
  • Repeat for each sub-problem until we reach basic
    or trivial implementation level.

7
Top-Down Design
  • Level

0
X
1
X1
X2
X3
Xn
2
X21
X22
. .
8
Modules
  • In C

Function Xi
Sub-Problem Xi
Implemented as
Main Function X
Main Problem X
Implemented as
9
4. Elements of Module Design

With What Resources? (Data)
What? Purpose
How? (Algorithm)
Module Design
10
Elements of Module Design

Functional Specs
Data Specs
Algorithm Specs
Pseudo- code
11
Elements of Module Design
  • S/W Design for Each Module
  • Functional Specifications the purpose of the
    module and what it is supposed to do (What to do)
  • Data Specifications the data resources needed by
    the module to achieve it functionality (with
    what)
  • Algorithm Specification the algorithm or
    methodology used by the module (How to do it)
  • In addition, for Each Module we should specify
  • Precondition the state of processing or data
    before the module is executed (state before)
  • Postcondition the state of processing or data
    after the module is executed (state after)

12
Some Guidelines for Module Design
  • Transparency of Purpose
  • Correctness
  • Completeness
  • Ease of Use
  • Efficiency
  • Writability
  • Maintainability

13
5. Example of a Design Document
  • Problem Definition
  • To find the median of (n) integers.
  • Requirement Specification
  • - Input(s) n, and list of integers in random
    order.
  • - Output(s) The median.

14
Example(continued)
  • Solution Strategy
  • The median of a list of integers is an integer
    below which and above which there is an equal
    number of integers. To find the median of a list
    of (n) integers
  • 1. Input random list of (n) integers
  • 2. Sort list in ascending order.
  • 3. Median is the integer at (n/2)
  • 3. Print median.

15
Example(continued)
  • S/W Design
  • Structured (Top-Down) Design
  • Yields a main module, a sorting module, and a
    median module.

main
sort
median
16
Example(continued)
  • Sorting Module sort( )
  • Functional Specification
  • Receives list, returns sorted list.
  • Input (s) n and list
  • Output (s) sorted list
  • Precondition none
  • Postcondition the list is sorted
  • Data Specification
  • No extra data needed
  • Algorithm Specification
  • Uses the method of Selection Sort.

17
Example(continued)
  • How selection sort works (optional)
  • Assume list occupies locations 0.. n-1
  • Repeat for list items k from 0 to n-2
  • Assume smallest item to be at location (k)
  • Examine items k1 to n-1 and find location of
    smallest
  • Exchange that element with that at (k)

18
Example(continued)
  • Median Module median( )
  • Functional Specification
  • Receives sorted list, returns median.
  • Input (s) n and list
  • Output (s) median
  • Precondition list is sorted
  • Postcondition none
  • Data Specification
  • No extra data needed
  • Algorithm Specification
  • median is the element at (n/2) in the sorted
    list

19
Example(continued)
  • Main Module main( )
  • Functional Specification
  • Inputs list, prints median.
  • Input (s) n and list (form keyboard)
  • Output (s) median (on screen)
  • Precondition none
  • Postcondition median is printed
  • Data Specification
  • - MAX 100 to represent maximum list size
  • - An Array (a) of size MAX to store list.
  • - n is the actual list size.

20
Example(continued)
  • main( ) (continued)
  • Algorithm Specification
  • Input n.
  • Check that n does not exceed MAX.
  • Input random list into array (a).
  • Call sorting module.
  • Call median module
  • Display median

21
Example (implementation)
  • include ltiostreamgt
  • using namespace std
  • typedef int itemtype
  • // Function Prototypes
  • void sort (itemtype a , int n)
  • itemtype median (itemtype a , int n)
  • //________________________________________________
    __________
  • int main( ) // Start of main function
  • const int MAX 100 // Data Declarations
  • itemtype aMAX, m
  • int k, n
  • cin gtgt n // Read size of data
  • if (n gt MAX) n MAX // to prevent array
    overflow

22
Example (implementation)
  • for (k 0 k lt n k) cin gtgt ak // Read
    data into array
  • sort(a,n) // Call sorting module
  • m median(a,n) // Call median module
  • cout ltlt m // Display median
  • return 0
  • //________________________________________________
    ___

23
Example (implementation)
  • void sort (itemtype a , int n) // Sort module
  • // Selection Sort Algorithm
  • // Precondition None
  • // Postcondition Array a is sorted
  • int k, j, min // Module Local Data
  • itemtype temp
  • for (k 0 k lt n-1 k )
  • min k
  • for ( j k1 j lt n j) if (aj lt amin )
    min j
  • temp amin amin ak ak temp
  • //________________________________________________
    ____

24
Example (implementation)
  • itemtype median (itemtype a , int n) //median
    module
  • // Computes median
  • // Precondition Array a is sorted
  • // Postcondition None
  • return (an/2)
  • //________________________________________________
    ____

25
Learn on your own about
  • Waterfall and Spiral Models
  • UML
  • S/W system Life Cycle
About PowerShow.com