Presentation is loading. Please wait.

Presentation is loading. Please wait.

UMass Lowell Computer Science 91.404 Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Tuesday, 11/13/01 Data Structures Makeup Lecture Linked Lists.

Similar presentations


Presentation on theme: "UMass Lowell Computer Science 91.404 Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Tuesday, 11/13/01 Data Structures Makeup Lecture Linked Lists."— Presentation transcript:

1 UMass Lowell Computer Science 91.404 Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Tuesday, 11/13/01 Data Structures Makeup Lecture Linked Lists & Trees

2 Linked Lists ä Types ä Singly vs. Doubly linked ä Pointer to Head and/or Tail ä NonCircular vs. Circular ä Type influences running time of operations 9 4 3 / head9 4 3 / head tail9 4 3 head

3 Doubly Linked List Operations source: 91.503 textbook Cormen et al.

4 Rooted Binary Tree Representation source: 91.503 textbook Cormen et al.

5 Multiple-Child Tree Representation source: 91.503 textbook Cormen et al.

6 Binary Tree Traversal ä “Visit” each node once  Running time in  (n) for an n-node binary tree ä Preorder: ABDCEF ä Visit node ä Visit left subtree ä Visit right subtree ä Inorder: DBAEFC ä Visit left subtree ä Visit node ä Visit right subtree ä Postorder: DBFECA ä Visit left subtree ä Visit right subtree ä Visit node B E C F D A

7 Binary Tree Traversal (continued) ä Preorder: ABDCEF ä Visit node ä Visit left subtree ä Visit right subtree B E C F D ATraversePreOrder(T) if T nil then return else Visit(T) TraversePreOrder(left[T]) TraversePreOrder(left[T]) TraversePreOrder(right[T]) TraversePreOrder(right[T])


Download ppt "UMass Lowell Computer Science 91.404 Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Tuesday, 11/13/01 Data Structures Makeup Lecture Linked Lists."

Similar presentations


Ads by Google