MultiDimensional Array implementation for TSP - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

MultiDimensional Array implementation for TSP

Description:

Using Multi-Dimensional Array to Solve TSP- An Idea ... While the pop operation is a deletion of the first node. 10/1/09. Meng-Lai Yin ECE304 ... – PowerPoint PPT presentation

Number of Views:76
Avg rating:3.0/5.0
Slides: 14
Provided by: csupo
Category:

less

Transcript and Presenter's Notes

Title: MultiDimensional Array implementation for TSP


1
Multi-Dimensional Array implementation for TSP
Variations of Linked List
2
A Special Case of TSP
D
1
10
2
3
3
2
2
3
5
S
7
3
6
4
5
7
5
4
Note this is only one example, not a general
description of the problem.
3
Using Multi-Dimensional Array to Solve TSP- An
Idea
  • Use a 2 dimensional array to store the distance
    between cities, named D
  • Use permutation to generate all possible paths,
    store the paths in an array of structures, named
    P. Each element of the array can contain the
    order and the cost of a particular path.
  • Trace D against every element in P to obtain the
    total cost.
  • Compare total cost of all elements in P to obtain
    the best path.

4
Issues to be discussed
  • Space needed
  • Time complexity

5
Review of the Linked List
  • Whats good about using linked list over the
    array structure?
  • What are the basic operations?
  • How do you implement the basic operations on a
    basic linked list structure?

A list
A node
6
Homework
  • Write a C program with two classes Node
    LinkedList
  • The Node class has 2 public data members a
    data (int type), and a pointer points to the
    next Node object. (Node).
  • The LinkedList class has 2 public data members a
    pointer points to the first Node object, and the
    size of the list (int).
  • The LinkedList has public member functions to
    conduct the 5 basic operations list_initialize,
    check_empty, traverse, insertion, and deletion.

7
Variations
  • A standard linked list (1) only the first node
    is directly accessible (2) each node consists of
    a data part and a single link that connects to
    its successor
  • Variations of the standard linked list exist
    circular-linked lists, linked stacks and queues,
    doubly-linked lists, multiply linked lists (in
    the text)

8
Linked Stacks and Queues
  • Similar to the deficiency issues of the
    array-based implementation of list, stacks ad
    queues can have the same problem
  • Using a linked list instead of an array allows
    the stack or queue to grow without limit (except
    for available memory) and to shrink without
    wasting unused storage.
  • A stack is a essentially a list in which items
    can be accessed at only one end. The push
    operation is simple an insertion at the beginning
    of a linked list. While the pop operation is a
    deletion of the first node.

9
Linked Queue
  • A linked implementation of a queue is a simple
    extension of the linked implementation of stacks.

queue
stack
10
Circular Linked List
A circular list
A node
11
Double Linked Lists
A double linked list
A node
12
Multiple-Linked Lists
  • Nodes contain info with more than one link

List 1
List 2
13
Midterm ideas
  • Coverage basics of algorithm analysis, sorting
    algorithms, multi-dimensional arrays, linked
    lists veriations
  • Questions
  • Styles
Write a Comment
User Comments (0)
About PowerShow.com