CSC 2300 Data Structures - PowerPoint PPT Presentation

About This Presentation
Title:

CSC 2300 Data Structures

Description:

... Types (ADT) Linear Structures Operations. Arrays and Vectors. Linked Lists. A Linked List. Deletion from a Linked List. Insertion into a Linked List. Discussion ... – PowerPoint PPT presentation

Number of Views:59
Avg rating:3.0/5.0
Slides: 25
Provided by: stude6
Learn more at: http://www.cs.rpi.edu
Category:
Tags: csc | data | structures

less

Transcript and Presenter's Notes

Title: CSC 2300 Data Structures


1
CSC 2300Data Structures Algorithms
  • February 2, 2007
  • Chapter 3. Lists, Stacks, and Queues

2
What You Should Already Know
3
Today Linear Structures
4
Abstract Data Types (ADT)
5
Linear Structures Operations
6
Arrays and Vectors
7
Linked Lists
8
A Linked List
9
Deletion from a Linked List
10
Insertion into a Linked List
11
Discussion
  • In principle, if we know where a change is to be
    made, inserting or removing an item from a linked
    list does not require moving lots of items, and
    instead involves only a constant number of
    changes to node links.
  • What are the special cases?
  • Adding to the front or removing the first item
    requires a link to the front of the linked list.
  • Adding at the end requires a link to the last
    node.
  • What about removing the last item?
  • We must find the next-to-last item.
  • How to do so efficiently?

12
A Doubly Linked List
  • How to reduce coding work to handle the special
    cases?

13
Header and Tail Nodes
  • What if the list were empty?

14
Insertion in Doubly Linked List
15
Remove Node in Doubly Linked List
  • p-gtprev-gtnext p-gtnext
  • p-gtnext-gtprev p-gtprev
  • delete p

16
Erase Routines
17
Standard Template Library (STL)
18
STL vector
19
STL list
20
Stacks
21
Stack Model
  • Input to a stack is by push, output is by pop and
    top

22
Stack Model
  • Only the top element is accessible

23
Queues
24
Queue Model
Write a Comment
User Comments (0)
About PowerShow.com