Data Structures for dealing with permutations - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Data Structures for dealing with permutations

Description:

We Define the TSP problem and consider the 2-opt algorithm ... We show the connection to another problem on permutations. TSP is cool. Taken from the TSP Homepage ... – PowerPoint PPT presentation

Number of Views:99
Avg rating:3.0/5.0
Slides: 22
Provided by: ela84
Category:

less

Transcript and Presenter's Notes

Title: Data Structures for dealing with permutations


1
Data Structures for dealing with permutations
  • Based on a paper by Fredman, Johnson, McGeoch and
    Ostheimer

2
Talk Outline
  • We Define the TSP problem and consider the 2-opt
    algorithm
  • We present the modified splay tree an
    interesting DS for implementing 2-opt.
  • We show the connection to another problem on
    permutations

3
TSP is cool
Taken from the TSP Homepage
4
TSP Of Ireland
Taken from the TSP Homepage
5
TSP
  • Given a complete graph with weights on the edges,
    find a minimum-weight hamiltonian tour
  • A tour can be viewed as a
  • permutation of the vertices

6
Local Improvement Heuristics
  • A nice approach to get a heuristic is to use
    local improvements
  • Start with a random tour
  • Repeatedly find a local improvement, and perform
    it
  • Return the tour when there are no more local
    improvements

7
A 2-move
  • (a, v1,v2,,vi,c,d,u1,,uj,b)
  • (a, v1,v2,,vi,c,b,uj,uj-1,,u1,d)

8
2-opt
  • Repeatedly performing 2-moves is called the 2-opt
    heuristic.
  • What is its running time?
  • O(nlogn) for producing the first tour
  • O(1) to draw a random improvement and check if it
    is good
  • O(n) for generating the new tour

9
Requirements from the DS
  • Operations we want to perform
  • Reverse part of the permutation
  • Return the successor of an element in the
    permutation

10
Data Structure for holding the tour
  • Tour in linked list performing a 2-move is
    easy. Accessing the vertices is hard.
  • Tour in array Access is easy, performing a
    2-move is hard.
  • Solution Hold the tour in the nodes of a
    balanced search tree!

11
The Modified Splay Tree
  • Each node of the tree can be marked as flipped
  • The tour is an in-order traversal of the tree,
    altered by the flipped markers

IFJCG A DHBE
12
Requirements from the DS
  • Operations we want to perform
  • Reverse part of the permutation
  • Return the successor of an element in the
    permutation
  • op 2 is trivially done in O(logn) in a balanced
    search tree (even with flipped markers)
  • op 1 can be done in O(logn) time if we use AVL
    trees or splay trees

13
(No Transcript)
14
Splay Trees
  • Invented by Sleator Tarjan
  • Support
  • Search
  • Insert, Delete
  • Splitting and Concatenation
  • all in logarithmic amortized time

15
Splay Trees
  • To perform an operation on an element we first
    splay it.
  • Splaying a node Performing (composite) rotations
    until it gets to the root
  • Rotations

x
y
x
y
A
C
B
C
A
B
16
Splay Trees With flipped markers
  • Observe that we can push the
  • flipped markers down

A
B
B
A
So, before performing any operation (even
rotation) just push the markers down, and were
O.K.
17
Reversing a Segment
x
  • If we want to reverse between x and y (non
    inclusive)
  • Splay y
  • Splay x
  • Then we can do the flip using O(1) operations

y
A
B
C
x
y
A
B
C
18
Signed Sorting by reversals
Given a signed permutation, find a shortest
sequence of reversals that transforms it to (1
2 n)
(
-
-
-
(3 4 -2 -5 1)
3
4
2
5
1)
19
Example
  • (3 4 -2 -5 1)
  • (-4 -3 -2 -5 1)
  • (-4 -3 -2 -1 5)
  • ( 1 2 3 4 5)

20
In SBR
  • We want to maintain a (signed) permutation under
    reversals this is the Modified Splay Tree (with
    signs)
  • More involved version We want to actually solve
    the problem. We maintain some reversals in a
    similar, but more involved, way.

21
Conclusions
  • We showed a Data Structure for holding
    permutations under reversals that is usefull both
    for TSP and for SBR
  • The idea of the flipped markers has further
    uses.
Write a Comment
User Comments (0)
About PowerShow.com