Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unit 1 - Introducing Abstract Data Type (ADT) Part 3 – Slides 1 to 11.

Similar presentations


Presentation on theme: "Unit 1 - Introducing Abstract Data Type (ADT) Part 3 – Slides 1 to 11."— Presentation transcript:

1 Unit 1 - Introducing Abstract Data Type (ADT) Part 3 – Slides 1 to 11

2 Unit Objectives Solve a problem using a concrete data type (CDT) ◦ Apply 4 steps of software development process  Side trip -> UML class diagram Solve same problem using an abstract data type ◦ Introduce abstract data type (ADT) ◦ Introduce our first ADT -> List  Design ADT List  First implementation: array-based List  Side trip -> pointers and linked lists  Second implementation: link-based List ◦ Compare both ADT List implementations  Side trip -> efficiency analysis CMPT 225 - Anne Lavergne2 Part 3

3 Side Trip – Pointers and linked lists CMPT 225 - Anne Lavergne3

4 Let’s first talk about Array Data structure (or CDT) Diagram of an array Indexing data structure ◦ Direct access CMPT 225 - Anne Lavergne4

5 What can you do with an Array 1. Insert 2. Delete 3. Traverse 4. Number of elements 5. Expand CMPT 225 - Anne Lavergne5

6 Problems with Array? Capacity required when creating an array ◦ Overestimate array’s capacity  ◦ Underestimate array’s capacity  May run out of space  Solution: expand array  How expensive is this operation? CMPT 225 - Anne Lavergne6

7 linked list To understand linked list, we first need to understand pointers If we are unfamiliar with pointers or would like to refresh our knowledge of pointers ◦ See Reading list for Lecture 7 on our course web site CMPT 225 - Anne Lavergne7

8 Let’s now talk about linked list Linked data structure (or CDT) ◦ Sequential access Diagram of an linked list CMPT 225 - Anne Lavergne8

9 linked list - Components Visually Head of linked list Node or link of linked list CMPT 225 - Anne Lavergne9

10 Examples of linked lists CMPT 225 - Anne Lavergne10

11 What can we do with a linked list 1. Insert 2. Delete 3. Traverse 4. Number of elements 5. Concat CMPT 225 - Anne Lavergne11


Download ppt "Unit 1 - Introducing Abstract Data Type (ADT) Part 3 – Slides 1 to 11."

Similar presentations


Ads by Google