Doubly Linked Lists - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Doubly Linked Lists

Description:

Circular Doubly Linked Lists. Implemented on a Computer it might look something like this. ... and Path Length Depth Discussion. 15. Main Index. Contents. 15 ... – PowerPoint PPT presentation

Number of Views:474
Avg rating:3.0/5.0
Slides: 21
Provided by: alaneu
Category:
Tags: doubly | linked | lists

less

Transcript and Presenter's Notes

Title: Doubly Linked Lists


1
CSE 331- Lecture 14
Chapter 9 Doubly Linked Lists API Implementation
Header Node Circular Form Chapter 10 Tree
Terminology node, leaf, root, parent, child,
height Binary Tree
Return Midterm Exam Answer questions
about Maze Search Program
2
Abstract Model of a List Object
3
Circular Doubly Linked Lists
  • Implemented on a Computer it might look something
    like this.

The 4 node is the front() node the 2 node is
the back() node begin() returns an iterator to
the 4 node end() returns an iterator to he header
node
4
Updating a Doubly Linked List
5
Inserting a Node at a Position
// insert newNode before curr newNode-gtprev
curr-gtprev newNode-gtnext curr curr-gtprev-gtnext
newNode curr-gtprev newNode
6
Deleting a Node at a Position
// unlink the node (curr) from the
list curr-gtprev-gtnext curr-gtnext curr-gtnext-gtp
rev curr-gtprev delete curr
7
Tree Structures
8
Tree Structures
9
Tree Structures
10
Tree Terminology
  • Node location containing value(s)
  • Parent node 1 link above here in tree
  • Child node 1 link below here in tree
  • Root top (first) node in tree
  • Leaf A node without any children
  • Interior node any non-leaf node
  • Ancestor any node on a path between root and
    here
  • Descendent any node reachable by a path from
    here downward in tree
  • Level number of links traversed from root to
    here
  • Height (depth) length of longest path from root
    to any leaf
  • Subtree Any node (chosen as root) along with
    all of its descendents

11
Tree Node Level and Path Length
12
Binary Tree Definition
  • A binary tree T is a finite set of nodes with one
    of the following properties
  • (a) T is a tree if the set of nodes is empty.
    (An empty tree is a tree.)
  • (b) The set consists of a root, R, and exactly
    two distinct binary trees, the left
    subtree TL and the right subtreeTR.
    The nodes in T consist of node R and all
    the nodes in TL and TR.

13
Binary Tree Nodes
14
Tree Node Level and Path Length Depth Discussion
15
Tree Node Level and Path Length Depth Discussion
16
Tree Node Level and Path Length Depth Discussion
17
Tree Node Level and Path Length Depth Discussion
18
Summary Slide 1
- Doubly linked lists - provide the most
flexible implementation for the sequential
list. - Its nodes have pointers to the next
and the previous node, so the program can
traverse a list in either the forward or
backward direction. - Traverse a list by
starting at the first node and follow the
sequence of next nodes until you arrive back
at the header. - To traverse a list in reverse
order, start at the last node and follow the
sequence of previous nodes until arriving back
at the header.
19
Summary Slide 2
- trees - hierarchical structures that place
elements in nodes along branches that
originate from a root. - Nodes in a tree are
subdivided into levels in which the topmost
level holds the root node. - Any node in a
tree may have multiple successors at the
next level. Hence a tree is a non-linear
structure. - Tree terminology with which you
should be familiar parent child
descendents leaf node interior node
subtree.
20
Summary Slide 3
- Binary Trees - Most effective as a storage
structure if it has high density - ie
data are located on relatively short paths from
the root. - A complete binary tree has
the highest possible density - an n-node
complete binary tree has depth int(log2n).
- At the other extreme, a degenerate binary tree
is equivalent to a linked list and exhibits
O(n) access times.
Write a Comment
User Comments (0)
About PowerShow.com