SlideShare a Scribd company logo
1 of 19
DATA STRUCTURES &
ALGORITHMS
R.PRABHU
132912
B-SEC
4/3/2015 Prabhu Mike
Introduction
Definition:
Given a set of cities and the distance between each
possible pair, the Travelling Salesman Problem is to
find the best possible way of ‘visiting all the cities
exactly once and returning to the starting point’
4/3/2015 Prabhu Mike
The Traveling Salesman
• Computer scientists call the problem of
finding an optimal path between n points the
traveling salesman problem (TSP)
• The TSP is a famous problem
– first posed by Irish mathematician
W. R. Hamilton in the 19th century
– intensely studied in
operations research and
other areas since 1930
This tour of 13,500 US cities was
generated by an advanced algorithm that
used several “tricks” to limit the number of
possible tours
http://www.tsp.gatech.edu/
Required 5 “CPU-years”
4/3/2015 Prabhu Mike
A genetic algorithm for a computationally demanding problem
The Traveling Salesman
• Maps and Tours
• Exhaustive Search
• Random Search
• The Genetic Algorithm
• Crossovers
4/3/2015 Prabhu Mike
Find a tour with minimum distance, visiting every city only once
Madiera Island (west of Morocco in Atlantic ocean)
4/3/2015 Prabhu Mike
Applications of TSP
• Even in its purest form the TSP, has several applications such
as planning, logistics, and the manufacture of microchips.
• Slightly modified, it appears as a sub-problem in many areas,
such as DNA sequencing.
• In these applications, the concept city represents, for example,
customers, soldering points, or DNA fragments
• The concept distance represents travelling times or cost, or a
similarity measure between DNA fragments.
• As TSP is a NP hard problem it is often used as a benchmark
for optimization techniques.
4/3/2015 Prabhu Mike
Applications of TSP
Mechanical arm
• When a mechanical arm is used to fasten the nuts for assembling parts, it
moves through each nut in proper order and returns to the initial position.
• The most economical travelling route will enable the mechanical arm to
finish its work within the shortest time.
Integrated circuit
• Inserting electrical elements in the manufacturing of integrated circuits
consumes certain energy when moving from one electrical element to the
other during manufacturing.
• We need to arrange the manufacturing order to minimize the energy
consumption.
In both these cases, TSP is required to be solved as a sub-problem.
4/3/2015 Prabhu Mike
Genetic Algorithms for TSP
Genetic algorithm has many steps in it
Evolution
• finding out good members from the population
Cross Over
• combining two parent members to form two new
different members(children) with similar characteristics
as parents.
• Some of newly formed members are altered randomly
• Keeps them from becoming identical and converging to
a local minima
4/3/2015 Prabhu Mike
• Completing the graph
– Missing edges are inserted with a weight of
Infinity (INF)
4/3/2015 Prabhu Mike
4/3/2015
Doubly-Linked Lists
It is a way of going both directions in
a linked list, forward and reverse.
 Many applications require a quick
access to the predecessor node of some
node in list.
Prabhu Mike
4/3/2015
Advantages over Singly-linked Lists
• Quick update operations:
such as: insertions, deletions at both ends (head
and tail), and also at the middle of the list.
• A node in a doubly-linked list store two
references:
• A next link; that points to the next node in the list,
and
• A prev link; that points to the previous node in the
list.
Prabhu Mike
4/3/2015
Doubly Linked List
• A doubly linked list provides a natural
implementation of the List ADT
• Nodes implement Position and store:
• element
• link to the previous node
• link to the next node
• Special trailer and header nodes
prev next
elem
trailerheader nodes/positions
elements
node
Prabhu Mike
A linked list as
an array of records
• What are the advantages of using linked
lists?
(1) Dynamic memory allocation
(2) Efficient insertion-deletion (for sorted lists)
• Can we implement a linked list without
dynamic memory allocation ?
4/3/2015 Prabhu Mike
Prabhu Mike
Singly Linked Lists
• A singly linked list is a
concrete data structure
consisting of a sequence of
nodes
• Each node stores
– element
– link to the next node
next
elem node
A B C D

4/3/2015
Prabhu Mike
Insertion
• We visualize operation insertAfter(p, X), which returns position q
A B X C
A B C
p
A B C
p
X
q
p q
4/3/2015
Prabhu Mike
Insertion Algorithm
Algorithm insertAfter(p,e):
Create a new node v
v.setElement(e)
v.setPrev(p){link v to its predecessor}
v.setNext(p.getNext()) {link v to its successor}
(p.getNext()).setPrev(v) {link p’s old successor to v}
p.setNext(v) {link p to its new successor, v}
return v {the position for the element e}
4/3/2015
Prabhu Mike
Deletion
• We visualize remove(p), where p == last()
A B C D
p
A B C
D
p
A B C
4/3/2015
Prabhu Mike
Deletion Algorithm
Algorithm remove(p):
t = p.element {a temporary variable to hold the
return value}
(p.getPrev()).setNext(p.getNext()) {linking out p}
(p.getNext()).setPrev(p.getPrev())
p.setPrev(null) {invalidating the position p}
p.setNext(null)
return t
4/3/2015
Thank
you..
4/3/2015 Prabhu Mike

More Related Content

Viewers also liked

동남아시아
동남아시아동남아시아
동남아시아
bvnrtw
 
Letter Of Reccomendation - Lemay
Letter Of Reccomendation - LemayLetter Of Reccomendation - Lemay
Letter Of Reccomendation - Lemay
Matthew Templeton
 
Traveling salesman problem__theory_and_applications
Traveling salesman problem__theory_and_applicationsTraveling salesman problem__theory_and_applications
Traveling salesman problem__theory_and_applications
Sachin Kheveria
 

Viewers also liked (20)

PARIS KOMATCHI LOGO
PARIS KOMATCHI LOGOPARIS KOMATCHI LOGO
PARIS KOMATCHI LOGO
 
동남아시아
동남아시아동남아시아
동남아시아
 
PPT TIC
PPT TICPPT TIC
PPT TIC
 
Revolucion de Tupac Amaru
Revolucion de Tupac AmaruRevolucion de Tupac Amaru
Revolucion de Tupac Amaru
 
Letter Of Reccomendation - Lemay
Letter Of Reccomendation - LemayLetter Of Reccomendation - Lemay
Letter Of Reccomendation - Lemay
 
Taller
TallerTaller
Taller
 
фарбований
фарбованийфарбований
фарбований
 
Cs6503 theory of computation may june 2016 be cse anna university question paper
Cs6503 theory of computation may june 2016 be cse anna university question paperCs6503 theory of computation may june 2016 be cse anna university question paper
Cs6503 theory of computation may june 2016 be cse anna university question paper
 
Thessa mea shinette avila dal demo
Thessa mea shinette avila dal demoThessa mea shinette avila dal demo
Thessa mea shinette avila dal demo
 
Cs6660 compiler design may june 2016 Answer Key
Cs6660 compiler design may june 2016 Answer KeyCs6660 compiler design may june 2016 Answer Key
Cs6660 compiler design may june 2016 Answer Key
 
Cs6660 compiler design november december 2016 Answer key
Cs6660 compiler design november december 2016 Answer keyCs6660 compiler design november december 2016 Answer key
Cs6660 compiler design november december 2016 Answer key
 
Lexical analysis
Lexical analysisLexical analysis
Lexical analysis
 
Mez medical virology
Mez medical virologyMez medical virology
Mez medical virology
 
Compiler Design Lecture Notes
Compiler Design Lecture NotesCompiler Design Lecture Notes
Compiler Design Lecture Notes
 
The National Antibiotic Guidelines: Shepherding Clinicians towards Rational u...
The National Antibiotic Guidelines: Shepherding Clinicians towards Rational u...The National Antibiotic Guidelines: Shepherding Clinicians towards Rational u...
The National Antibiotic Guidelines: Shepherding Clinicians towards Rational u...
 
Compiler design syntax analysis
Compiler design syntax analysisCompiler design syntax analysis
Compiler design syntax analysis
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer key
 
Traveling salesman problem__theory_and_applications
Traveling salesman problem__theory_and_applicationsTraveling salesman problem__theory_and_applications
Traveling salesman problem__theory_and_applications
 
Traveling salesman problem
Traveling salesman problemTraveling salesman problem
Traveling salesman problem
 
Compiler Design - Introduction to Compiler
Compiler Design - Introduction to CompilerCompiler Design - Introduction to Compiler
Compiler Design - Introduction to Compiler
 

Similar to Data structures & algorithms

circularlinklist-190205164051.pptx
circularlinklist-190205164051.pptxcircularlinklist-190205164051.pptx
circularlinklist-190205164051.pptx
MeghaKulkarni27
 
Data Structure - Complete Basic Overview.ppt
Data Structure - Complete Basic Overview.pptData Structure - Complete Basic Overview.ppt
Data Structure - Complete Basic Overview.ppt
ak8820
 

Similar to Data structures & algorithms (20)

Linked List
Linked ListLinked List
Linked List
 
Computer networks unit iii
Computer networks    unit iiiComputer networks    unit iii
Computer networks unit iii
 
Unit 1 linked list
Unit 1 linked listUnit 1 linked list
Unit 1 linked list
 
Data Structures 3
Data Structures 3Data Structures 3
Data Structures 3
 
Fundamentals of kinematics and mechanisms
Fundamentals of kinematics and mechanismsFundamentals of kinematics and mechanisms
Fundamentals of kinematics and mechanisms
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.ppt
 
Table Retrieval and Generation
Table Retrieval and GenerationTable Retrieval and Generation
Table Retrieval and Generation
 
Recommender Systems and Linked Open Data
Recommender Systems and Linked Open DataRecommender Systems and Linked Open Data
Recommender Systems and Linked Open Data
 
circularlinklist-190205164051.pptx
circularlinklist-190205164051.pptxcircularlinklist-190205164051.pptx
circularlinklist-190205164051.pptx
 
DATA STRUCTURES AND LINKED LISTS IN C.pptx
DATA STRUCTURES AND LINKED LISTS IN C.pptxDATA STRUCTURES AND LINKED LISTS IN C.pptx
DATA STRUCTURES AND LINKED LISTS IN C.pptx
 
DATA STRUCTURES AND LINKED LISTS IN C.pptx
DATA STRUCTURES AND LINKED LISTS IN C.pptxDATA STRUCTURES AND LINKED LISTS IN C.pptx
DATA STRUCTURES AND LINKED LISTS IN C.pptx
 
Exception & Database
Exception & DatabaseException & Database
Exception & Database
 
ds-lecture-4-171012041008 (1).pdf
ds-lecture-4-171012041008 (1).pdfds-lecture-4-171012041008 (1).pdf
ds-lecture-4-171012041008 (1).pdf
 
Data Structure - Complete Basic Overview.ppt
Data Structure - Complete Basic Overview.pptData Structure - Complete Basic Overview.ppt
Data Structure - Complete Basic Overview.ppt
 
Linked list
Linked listLinked list
Linked list
 
lecture 02.2.ppt
lecture 02.2.pptlecture 02.2.ppt
lecture 02.2.ppt
 
FEM_PPT.ppt
FEM_PPT.pptFEM_PPT.ppt
FEM_PPT.ppt
 
Link list
Link listLink list
Link list
 
linked list.pptx
linked list.pptxlinked list.pptx
linked list.pptx
 
II B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptxII B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptx
 

More from Prabhu R (12)

Power plant engineering
Power plant engineeringPower plant engineering
Power plant engineering
 
Power electronics
Power electronicsPower electronics
Power electronics
 
Oops
OopsOops
Oops
 
Measurement & instrumentation ppt
Measurement & instrumentation pptMeasurement & instrumentation ppt
Measurement & instrumentation ppt
 
Linear intergrated circuit
Linear intergrated circuitLinear intergrated circuit
Linear intergrated circuit
 
Electrical machines 2
Electrical machines 2Electrical machines 2
Electrical machines 2
 
Electrical machines
Electrical machinesElectrical machines
Electrical machines
 
Electronic devices and circuit
Electronic devices and circuitElectronic devices and circuit
Electronic devices and circuit
 
Digital logic circuit
Digital logic circuit Digital logic circuit
Digital logic circuit
 
Digital signal processing
Digital signal processingDigital signal processing
Digital signal processing
 
Control system
Control systemControl system
Control system
 
Tcsc ppt
Tcsc pptTcsc ppt
Tcsc ppt
 

Recently uploaded

Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
amitlee9823
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
AroojKhan71
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
amitlee9823
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
amitlee9823
 
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
amitlee9823
 

Recently uploaded (20)

Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
ALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptxALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptx
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science Project
 
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Saket (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bellandur ☎ 7737669865 🥵 Book Your One night Stand
 
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
Mg Road Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Banga...
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 

Data structures & algorithms

  • 2. Introduction Definition: Given a set of cities and the distance between each possible pair, the Travelling Salesman Problem is to find the best possible way of ‘visiting all the cities exactly once and returning to the starting point’ 4/3/2015 Prabhu Mike
  • 3. The Traveling Salesman • Computer scientists call the problem of finding an optimal path between n points the traveling salesman problem (TSP) • The TSP is a famous problem – first posed by Irish mathematician W. R. Hamilton in the 19th century – intensely studied in operations research and other areas since 1930 This tour of 13,500 US cities was generated by an advanced algorithm that used several “tricks” to limit the number of possible tours http://www.tsp.gatech.edu/ Required 5 “CPU-years” 4/3/2015 Prabhu Mike
  • 4. A genetic algorithm for a computationally demanding problem The Traveling Salesman • Maps and Tours • Exhaustive Search • Random Search • The Genetic Algorithm • Crossovers 4/3/2015 Prabhu Mike
  • 5. Find a tour with minimum distance, visiting every city only once Madiera Island (west of Morocco in Atlantic ocean) 4/3/2015 Prabhu Mike
  • 6. Applications of TSP • Even in its purest form the TSP, has several applications such as planning, logistics, and the manufacture of microchips. • Slightly modified, it appears as a sub-problem in many areas, such as DNA sequencing. • In these applications, the concept city represents, for example, customers, soldering points, or DNA fragments • The concept distance represents travelling times or cost, or a similarity measure between DNA fragments. • As TSP is a NP hard problem it is often used as a benchmark for optimization techniques. 4/3/2015 Prabhu Mike
  • 7. Applications of TSP Mechanical arm • When a mechanical arm is used to fasten the nuts for assembling parts, it moves through each nut in proper order and returns to the initial position. • The most economical travelling route will enable the mechanical arm to finish its work within the shortest time. Integrated circuit • Inserting electrical elements in the manufacturing of integrated circuits consumes certain energy when moving from one electrical element to the other during manufacturing. • We need to arrange the manufacturing order to minimize the energy consumption. In both these cases, TSP is required to be solved as a sub-problem. 4/3/2015 Prabhu Mike
  • 8. Genetic Algorithms for TSP Genetic algorithm has many steps in it Evolution • finding out good members from the population Cross Over • combining two parent members to form two new different members(children) with similar characteristics as parents. • Some of newly formed members are altered randomly • Keeps them from becoming identical and converging to a local minima 4/3/2015 Prabhu Mike
  • 9. • Completing the graph – Missing edges are inserted with a weight of Infinity (INF) 4/3/2015 Prabhu Mike
  • 10. 4/3/2015 Doubly-Linked Lists It is a way of going both directions in a linked list, forward and reverse.  Many applications require a quick access to the predecessor node of some node in list. Prabhu Mike
  • 11. 4/3/2015 Advantages over Singly-linked Lists • Quick update operations: such as: insertions, deletions at both ends (head and tail), and also at the middle of the list. • A node in a doubly-linked list store two references: • A next link; that points to the next node in the list, and • A prev link; that points to the previous node in the list. Prabhu Mike
  • 12. 4/3/2015 Doubly Linked List • A doubly linked list provides a natural implementation of the List ADT • Nodes implement Position and store: • element • link to the previous node • link to the next node • Special trailer and header nodes prev next elem trailerheader nodes/positions elements node Prabhu Mike
  • 13. A linked list as an array of records • What are the advantages of using linked lists? (1) Dynamic memory allocation (2) Efficient insertion-deletion (for sorted lists) • Can we implement a linked list without dynamic memory allocation ? 4/3/2015 Prabhu Mike
  • 14. Prabhu Mike Singly Linked Lists • A singly linked list is a concrete data structure consisting of a sequence of nodes • Each node stores – element – link to the next node next elem node A B C D  4/3/2015
  • 15. Prabhu Mike Insertion • We visualize operation insertAfter(p, X), which returns position q A B X C A B C p A B C p X q p q 4/3/2015
  • 16. Prabhu Mike Insertion Algorithm Algorithm insertAfter(p,e): Create a new node v v.setElement(e) v.setPrev(p){link v to its predecessor} v.setNext(p.getNext()) {link v to its successor} (p.getNext()).setPrev(v) {link p’s old successor to v} p.setNext(v) {link p to its new successor, v} return v {the position for the element e} 4/3/2015
  • 17. Prabhu Mike Deletion • We visualize remove(p), where p == last() A B C D p A B C D p A B C 4/3/2015
  • 18. Prabhu Mike Deletion Algorithm Algorithm remove(p): t = p.element {a temporary variable to hold the return value} (p.getPrev()).setNext(p.getNext()) {linking out p} (p.getNext()).setPrev(p.getPrev()) p.setPrev(null) {invalidating the position p} p.setNext(null) return t 4/3/2015