0% found this document useful (0 votes)
20 views

01 Intro

This document discusses an introduction to data structures and algorithm analysis. It covers topics like data structures, algorithms, complexity analysis, recursion, induction, and algorithm correctness. The goal is for students to understand common data types and processing tools and how to apply them appropriately.

Uploaded by

Lộc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

01 Intro

This document discusses an introduction to data structures and algorithm analysis. It covers topics like data structures, algorithms, complexity analysis, recursion, induction, and algorithm correctness. The goal is for students to understand common data types and processing tools and how to apply them appropriately.

Uploaded by

Lộc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 15

Introduction

Data Structures and Algorithm Analysis in C, by Mark Allen Weiss, 2nd


edition, 1997, Addison-Wesley, ISBN 0-201-49840-5
Danang University of Science and Technology

Dang Thien Binh


[email protected]
Class Overview
 Introduction to many of the basic data structures used in
computer software
 Understand the data structures
 Analyze the algorithms that use them
 Know when to apply them

 Practice using these data structures by writing programs

Data Structures IT faculty 2/15


Goal
 You will understand
 what the tools are for storing and processing common data types
 which tools are appropriate for which need

 So that you will be able to


 make good design choices as a developer, project manager, or system
customer

Data Structures IT faculty 3/15


Course Topics
 Introduction to Algorithm Analysis
 Lists, Stacks, Queues
 Search Algorithms and Trees
 Hashing and Heaps
 Sorting
 Disjoint Sets
 Graph Algorithms

Data Structures IT faculty 4/15


Readings and References
 Reading
 Chapter 1, Data Structures and Algorithm Analysis in C, by Weiss

 Other References
 Sections 1-3, Pointers and Memory, by Parlante

Data Structures IT faculty 5/15


Data Structures: What?
 Need to organize program data according to problem being
solved
 Abstract Data Type (ADT) - A data object and a set of
operations for manipulating it
 List ADT with operations insert and delete
 Stack ADT with operations push and pop
 Note similarity to Java classes
 Private data structure and public methods

Data Structures IT faculty 6/15


Data Structures: Why?
 Program design depends crucially on how data is structured
for use by the program
 Implementation of some operations may become easier or harder
 Speed of program may dramatically decrease or increase
 Memory used may increase or decrease
 Debugging may be become easier or harder

Data Structures IT faculty 7/15


Algorithms Analysis: What?
 What is an algorithm?
 A sequence of steps (a “program”) that accomplishes a task
 Many different algorithms may correctly solve a given task
 but will it be within this lifetime?
 will it require gigabytes of main memory?

Data Structures IT faculty 8/15


Algorithms Analysis: Why?
 Understand the mathematical fundamentals needed to
analyze algorithms

 Learn how to compare the efficiency of different algorithms in


terms of running time and memory usage

 Study a number of standard algorithms for data manipulation


and learn to use them for solving new problems

Data Structures IT faculty 9/15


A Simple Function
 Find the sum of the first num integers stored in an array v.

Data Structures IT faculty 10/15


Programming via Recursion
 Write a recursive function to find the sum of the first num
integers stored in array v

Data Structures IT faculty 11/15


Proof by Induction
 Basis Step: The algorithm is correct for a base case or two by
inspection.

 Inductive Hypothesis (n=k): Assume that the algorithm


works correctly for the first k cases, for any k.

 Inductive Step (n=k+1): Given the hypothesis above, show


that the k+1 case will be calculated correctly.

Data Structures IT faculty 12/15


Program Correctness by Induction
 Basis Step: sum(v,0) = 0.

 Inductive Hypothesis (n=k): Assume sum(v,k) correctly


returns sum of first k elements of v, i.e. v[0]+v[1]+…+v[k-1].

 Inductive Step (n=k+1): sum(v,n) returns v[k]+sum(v,k)


which is the sum of first k+1 elements of v.

Data Structures IT faculty 13/15


Algorithms vs Programs
 Proving correctness of an algorithm is very important
 a well-designed algorithm is guaranteed to work correctly, and its
performance can be estimated

 Proving correctness of a program (an implementation) is


fraught with weird bugs
 Abstract Data Types are a way to bridge the gap between mathematical
algorithms and programs

Data Structures IT faculty 14/15


Readings and References
 Reading
 Chapter 1, Data Structures and Algorithm Analysis in C, by Weiss

 Other References
 Sections 1-3, Pointers and Memory, by Parlante

Data Structures IT faculty 15/15

You might also like