Training - PowerPoint PPT Presentation

About This Presentation
Title:

Training

Description:

Data structures is concerned with the representation and ... Countless. Algorithm Strategies. Greedy. Divide and Conquer. Dynamic Programming. Exhaustive Search ... – PowerPoint PPT presentation

Number of Views:58
Avg rating:3.0/5.0
Slides: 21
Provided by: Agam3
Category:

less

Transcript and Presenter's Notes

Title: Training


1
Data Structures Algorithms
ltShiuh-Sheng Yugt
2
What The Course Is About
  • Data structures is concerned with the
    representation and manipulation of data.
  • All programs manipulate data.
  • So, all programs represent data in some way.
  • Data manipulation requires an algorithm.

3
What The Course Is About
  • We shall study ways to represent data and
    algorithms to manipulate these representations.

4
Functions of Data Structures
  • Add
  • Index
  • Key
  • Position
  • Priority
  • Get
  • Change
  • Delete

5
Common Data Structures
  • Array
  • Stack
  • Queue
  • Linked List
  • Tree
  • Heap
  • Hash Table
  • Priority Queue

6
How many Algorithms?
  • Countless

7
Algorithm Strategies
  • Greedy
  • Divide and Conquer
  • Dynamic Programming
  • Exhaustive Search
  • Approximation Algorithms
  • Randomized Algorithms

8
Which Data Structure or Algorithm is better?
  • Must Meet Requirement
  • High Performance
  • Low RAM footprint
  • Easy to implement
  • Encapsulated

9
Prerequisites
  • C
  • Asymptotic Complexity
  • Big Oh, Theta, and Omega notations

10
Web Site
  • programming.im.ncnu.edu.tw

11
Assignments
  • Assignment guidelines

12
Sorting
  • Rearrange a0, a1, , an-1 into ascending
    order. When done, a0 lt a1 lt lt an-1
  • 8, 6, 9, 4, 3 gt 3, 4, 6, 8, 9

13
Sort Methods
  • Insertion Sort
  • Bubble Sort
  • Selection Sort
  • Count Sort
  • Shaker Sort
  • Shell Sort
  • Heap Sort
  • Merge Sort
  • Quick Sort

14
Insert An Element
  • Given a sorted list/sequence, insert a new
    element
  • Given 3, 6, 9, 14
  • Insert 5
  • Result 3, 5, 6, 9, 14

15
Insert an Element
  • 3, 6, 9, 14 insert 5
  • Compare new element (5) and last one (14)
  • Shift 14 right to get 3, 6, 9, , 14
  • Shift 9 right to get 3, 6, , 9, 14
  • Shift 6 right to get 3, , 6, 9, 14
  • Insert 5 to get 3, 5, 6, 9, 14

16
Insert An Element
  • / insert t into a0i-1 /
  • int j
  • for (j i - 1 j gt 0 t lt aj j--)
  • aj 1 aj
  • aj 1 t

17
Insertion Sort
  • Start with a sequence of size 1
  • Repeatedly insert remaining elements

18
Insertion Sort
  • Sort 7, 3, 5, 6, 1
  • Start with 7 and insert 3 gt 3, 7
  • Insert 5 gt 3, 5, 7
  • Insert 6 gt 3, 5, 6, 7
  • Insert 1 gt 1, 3, 5, 6, 7

19
Insertion Sort
  • for (i 1 i lt n i)
  • / insert ai into a0i-1 /
  • / code to insert comes here /

20
Insertion Sort
  • for (i 1 i lt n i)
  • / insert ai into a0i-1 /
  • int t ai
  • int j
  • for (j i - 1 j gt 0 t lt aj j--)
  • aj 1 aj
  • aj 1 t
Write a Comment
User Comments (0)
About PowerShow.com