Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Data Structure, Spring 2007 Slide- 1 California State University, Fresno Introduction to Data Structure Introduction of Concepts Ming Li.

Similar presentations


Presentation on theme: "Introduction to Data Structure, Spring 2007 Slide- 1 California State University, Fresno Introduction to Data Structure Introduction of Concepts Ming Li."— Presentation transcript:

1 Introduction to Data Structure, Spring 2007 Slide- 1 California State University, Fresno Introduction to Data Structure Introduction of Concepts Ming Li Department of Computer Science California State University, Fresno Spring 2007

2 Introduction to Data Structure, Spring 2007 Slide- 2 California State University, Fresno Concepts - I A data structure is a systematic way of organizing and accessing data. –Primitive: int or char –Programmer-defined: bundle data with operations that manipulate the data. Operations (within the so called “Container”) –Insert –Remove –Search –Traversal –Etc.

3 Introduction to Data Structure, Spring 2007 Slide- 3 California State University, Fresno Concepts - II Why different container? –Efficiency!!! Space efficiency Time efficiency Comparison (see examples) –Array –Vector –List –Queue –Binary Search Tree

4 Introduction to Data Structure, Spring 2007 Slide- 4 California State University, Fresno Array Simple, fixed size Access by index, a[0], a[4], a[5],… –Many times we don’t know the index!!! Insertion –Shift remaining elements; –Limited by the array length Remove: –Shift remaining elements; –N times maximally Search: –Sequential, N times maximally

5 Introduction to Data Structure, Spring 2007 Slide- 5 California State University, Fresno Vector Simple, variable size –Dynamically grow/shrink according to the insert/remove operations. Access by index, a[0], a[4], a[5],… Insertion: –Shift remaining elements; –Grow size if full Remove: –Shift remaining elements; –Shrink size if not well utilized Search: –Sequential, N times maximally

6 Introduction to Data Structure, Spring 2007 Slide- 6 California State University, Fresno

7 Introduction to Data Structure, Spring 2007 Slide- 7 California State University, Fresno Example

8 Introduction to Data Structure, Spring 2007 Slide- 8 California State University, Fresno List More complicated –Dynamically grow/shrink according to the insert/remove operations. Access by front and the next pointer Insertion: –No shift on remaining elements; –Grow size by 1 Remove: –No shift on remaining elements; –Shrink size by 1 Search: –Sequential, N times maximally

9 Introduction to Data Structure, Spring 2007 Slide- 9 California State University, Fresno Example

10 Introduction to Data Structure, Spring 2007 Slide- 10 California State University, Fresno Binary Search Tree More complicated –Dynamically grow/shrink according to the insert/remove operations. Access by root and the children pointer Insertion: –No shift on remaining elements; –Grow size by 1 Remove: –No shift on remaining elements; –Shrink size by 1 Search: –logN time (height of the tree) for balanced tree


Download ppt "Introduction to Data Structure, Spring 2007 Slide- 1 California State University, Fresno Introduction to Data Structure Introduction of Concepts Ming Li."

Similar presentations


Ads by Google