SlideShare une entreprise Scribd logo
1  sur  25
Télécharger pour lire hors ligne
First Year BA (IT)
CT1120 Algorithms
Lecture 15
Dr. Zia Ush Shamszaman
z.shamszaman1@nuigalway.ie
1
School of Computer Science, College of Science and Engineering
31-01-2020
Overview
•  Data Structure
–  Stack
–  Queue
–  Tree
•  Reviewing previous lectures
•  Feedback and Assessment
231-01-2020
3
Data Structure Concepts
•  Data Structures are containers:
–  they hold other data
–  arrays are a data structure
–  ... so are lists
•  Other types of data structures:
–  stack, queue, tree,
binary search tree, hash table,
dictionary or map, set, and on and on
•  Different types of data structures are
optimized for certain types of operations
31-01-2020
Basic Data Structure
Basic Data Structures
Linear Data Structures Non-Linear Data Structures
Arrays Linked Lists Stacks Queues Trees Graphs Hash Tables
31-01-2020 4
Array
Linked list
Tree
Queue
Stack
Linear Data Structure
31-01-2020 5
6
Data Structure Operations
•  Data Structures will have 3 core operations
–  a way to add things
–  a way to remove things
–  a way to access things
•  Details of these operations depend on the data
structure
–  Example: List, add at the end, access by
location, remove by location
•  More operations added depending on what data
structure is designed to do
31-01-2020
Data Structure Operations
Ø  Traversing: Accessing each record exactly once so that certain
items in the record may be processed.
Ø  Searching: Finding the location of the record with a given key value,
or finding the locations of all records which satisfy one or more
conditions.
Ø  Insertion: Adding a new record to the structure.
Ø  Deletion: Removing a record from the structure.
Following two are special operations:
Ø  Sorting: Arranging the records in some logical order.
Ø  Merging: Combining the records in two different sorted files into a
single sorted file.
31-01-2020 7
Selection of Data Structure
•  The choice of particular data model depends
on two consideration:
–  It must be rich enough in structure to
represent the relationship between data
elements
–  The structure should be simple enough that
one can effectively process the data when
necessary
31-01-2020 8
Stack
•  A Stack is a list of elements in which an
element may be inserted or deleted at
one end which is known as TOP of the
stack.
31-01-2020 9
Stack
•  Collection with access only to the last
element inserted
•  Last in First out (LIFO)
•  Insert/Push
•  Remove/Pop
•  Top
•  Make empty
TopData4
Data3
Data2
Data1
push
pop
31-01-2020 10
Stack Operation
31-01-2020 11
•  Stack() creates a new stack that is empty. It needs no
parameters and returns an empty stack.
•  push(item) adds a new item to the top of the stack. It needs
the item and returns nothing.
•  pop() removes the top item from the stack. It needs no
parameters and returns the item. The stack is modified.
•  peek() returns the top item from the stack but does not
remove it. It needs no parameters. The stack is not
modified.
•  isEmpty() tests to see whether the stack is empty. It needs
no parameters and returns a boolean value.
•  size() returns the number of items on the stack. It needs no
parameters and returns an integer.
31-01-2020 12
Example
from pythonds.basic import Stack
s=Stack()
print(s.isEmpty())
s.push(4)
s.push('dog')
print(s.peek())
s.push(True)
print(s.size())
print(s.isEmpty())
s.push(8.4)
print(s.pop())
print(s.pop())
print(s.size())
31-01-2020 13
True
dog
3
False
8.4
True
2
Output
Queue
•  A queue is an ordered collection of items where
the addition of new items happens at one end,
called the “rear,” and the removal of existing
items occurs at the other end, commonly called
the “front.”
•  As an element enters the queue it starts at the
rear and makes its way toward the front, waiting
until that time when it is the next element to be
removed..
31-01-2020 14
Queue
•  Collection with access only to the item that has
been present the longest
•  Last in Last Out (LILO)/First in First Out(FIFO)
•  enqueue, dequeue, front
•  priority queues and dequeue
31-01-2020 15
Basic Operation
•  Queue() creates a new queue that is empty. It needs no
parameters and returns an empty queue.
•  enqueue(item) adds a new item to the rear of the
queue. It needs the item and returns nothing.
•  dequeue() removes the front item from the queue. It
needs no parameters and returns the item. The queue
is modified.
•  isEmpty() tests to see whether the queue is empty. It
needs no parameters and returns a boolean value.
•  size() returns the number of items in the queue. It
needs no parameters and returns an integer.
31-01-2020 16
31-01-2020 17
Example
q=Queue()
q.enqueue(4)
q.enqueue('dog')
q.enqueue(True)
print(q.size())
31-01-2020 18
Tree
•  A Tree is a collection of elements called nodes.
•  One of the node is distinguished as a root, along with a
relation (“parenthood”) that places a hierarchical
structure on the nodes.
31-01-2020 19
Vocabulary & Definitions
•  Node
–  A node is a fundamental part of a tree. It can have a
name, which we call the “key.” A node may also have
additional information. We call this additional information
the “payload.” While the payload information is not
central to many tree algorithms, it is often critical in
applications that make use of trees.
•  Edge
–  An edge is another fundamental part of a tree. An edge
connects two nodes to show that there is a relationship
between them. Every node (except the root) is connected
by exactly one incoming edge from another node. Each
node may have several outgoing edges.
•  Root
–  The root of the tree is the only node in the tree that has
no incoming edges.
31-01-2020 20
Vocabulary & Definitions
•  Path
–  A path is an ordered list of nodes that are connected by
edges. For example, Mammal → Carnivora → Felidae →
Felis → Domestica is a path.
•  Children
–  The set of nodes 𝑐 that have incoming edges from the
same node to are said to be the children of that node.
•  Parent
–  A node is the parent of all the nodes it connects to with
outgoing edges.
31-01-2020 21
Vocabulary & Definitions
•  Sibling
–  Nodes in the tree that are children of the same parent
are said to be siblings.
•  Subtree
–  A subtree is a set of nodes and edges comprised of a
parent and all the descendants of that parent.
•  Leaf Node
–  A leaf node is a node that has no children. For example,
Human and Chimpanzee are leaf nodes
31-01-2020 22
Next Lecture
Class test
Syllabus (all three lectures)
31-01-2020 23
Useful Links	
•  http://www.csanimated.com/animation.php?t=Quicksort
•  http://www.hakansozer.com/category/c/
•  http://www.nczonline.net/blog/2012/11/27/computer-science-in-
javascript-quicksort/
•  http://www.sorting-algorithms.com/shell-sort
•  https://www.tutorialspoint.com/
•  https://www.hackerearth.com/
•  www.khanacademy.org/computing/computer-science/algorithms
31-01-2020 24
Feedback & Assessment
31-01-2020 25

Contenu connexe

Tendances

Data Structures - Lecture 2 [Introduction to Data Structures]
Data Structures - Lecture 2 [Introduction to Data Structures]Data Structures - Lecture 2 [Introduction to Data Structures]
Data Structures - Lecture 2 [Introduction to Data Structures]Muhammad Hammad Waseem
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structureadeel hamid
 
Introduction to Data Structure part 1
Introduction to Data Structure part 1Introduction to Data Structure part 1
Introduction to Data Structure part 1ProfSonaliGholveDoif
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structureZaid Shabbir
 
Introduction of Data Structure
Introduction of Data StructureIntroduction of Data Structure
Introduction of Data StructureMandavi Classes
 
Elementary data organisation
Elementary data organisationElementary data organisation
Elementary data organisationMuzamil Hussain
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURERohit Rai
 
Data structures Lecture no.3
Data structures Lecture no.3Data structures Lecture no.3
Data structures Lecture no.3AzharIqbal710687
 
Data structures Lecture no. 2
Data structures Lecture no. 2Data structures Lecture no. 2
Data structures Lecture no. 2AzharIqbal710687
 
Linear Data Structures - List, Stack and Queue
Linear Data Structures - List, Stack and QueueLinear Data Structures - List, Stack and Queue
Linear Data Structures - List, Stack and QueueSelvaraj Seerangan
 
Introduction To Data Structures.
Introduction To Data Structures.Introduction To Data Structures.
Introduction To Data Structures.Education Front
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure pptNalinNishant3
 
Data structures lectures no 1
Data structures lectures no 1Data structures lectures no 1
Data structures lectures no 1AzharIqbal710687
 
Files and data storage
Files and data storageFiles and data storage
Files and data storageZaid Shabbir
 
data structure
data structuredata structure
data structurehashim102
 
data structures and algorithms Unit 1
data structures and algorithms Unit 1data structures and algorithms Unit 1
data structures and algorithms Unit 1infanciaj
 

Tendances (20)

Data Structures - Lecture 2 [Introduction to Data Structures]
Data Structures - Lecture 2 [Introduction to Data Structures]Data Structures - Lecture 2 [Introduction to Data Structures]
Data Structures - Lecture 2 [Introduction to Data Structures]
 
Data structures
Data structuresData structures
Data structures
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Lecture1 data structure(introduction)
Lecture1 data structure(introduction)Lecture1 data structure(introduction)
Lecture1 data structure(introduction)
 
Introduction to Data Structure part 1
Introduction to Data Structure part 1Introduction to Data Structure part 1
Introduction to Data Structure part 1
 
Trees
TreesTrees
Trees
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Introduction of Data Structure
Introduction of Data StructureIntroduction of Data Structure
Introduction of Data Structure
 
Elementary data organisation
Elementary data organisationElementary data organisation
Elementary data organisation
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
Data structures Lecture no.3
Data structures Lecture no.3Data structures Lecture no.3
Data structures Lecture no.3
 
Data structures Lecture no. 2
Data structures Lecture no. 2Data structures Lecture no. 2
Data structures Lecture no. 2
 
Linear Data Structures - List, Stack and Queue
Linear Data Structures - List, Stack and QueueLinear Data Structures - List, Stack and Queue
Linear Data Structures - List, Stack and Queue
 
Introduction To Data Structures.
Introduction To Data Structures.Introduction To Data Structures.
Introduction To Data Structures.
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
 
Data structures lectures no 1
Data structures lectures no 1Data structures lectures no 1
Data structures lectures no 1
 
Data structure
Data structureData structure
Data structure
 
Files and data storage
Files and data storageFiles and data storage
Files and data storage
 
data structure
data structuredata structure
data structure
 
data structures and algorithms Unit 1
data structures and algorithms Unit 1data structures and algorithms Unit 1
data structures and algorithms Unit 1
 

Similaire à L 15 ct1120

1.Introduction to Data Structures and Algorithms.pptx
1.Introduction to Data Structures and Algorithms.pptx1.Introduction to Data Structures and Algorithms.pptx
1.Introduction to Data Structures and Algorithms.pptxBlueSwede
 
chapter09 -Programming Data Structures.pdf
chapter09 -Programming Data Structures.pdfchapter09 -Programming Data Structures.pdf
chapter09 -Programming Data Structures.pdfsatonaka3
 
Unit 1 linked list
Unit 1 linked listUnit 1 linked list
Unit 1 linked listLavanyaJ28
 
Data structure unitfirst part1
Data structure unitfirst part1Data structure unitfirst part1
Data structure unitfirst part1Amar Rawat
 
Data structure unitfirst part1
Data structure unitfirst part1Data structure unitfirst part1
Data structure unitfirst part1Amar Rawat
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptxSaralaT3
 
STACK AND QUEUE CIRCULAR QUEUE PPTS.pptx
STACK AND QUEUE CIRCULAR QUEUE PPTS.pptxSTACK AND QUEUE CIRCULAR QUEUE PPTS.pptx
STACK AND QUEUE CIRCULAR QUEUE PPTS.pptxsunitha1792
 
1.1 introduction to Data Structures.ppt
1.1 introduction to Data Structures.ppt1.1 introduction to Data Structures.ppt
1.1 introduction to Data Structures.pptAshok280385
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptxsarala9
 
Unit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdfUnit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdfKanchanPatil34
 
unit-ids17-180709051413-1.pdf
unit-ids17-180709051413-1.pdfunit-ids17-180709051413-1.pdf
unit-ids17-180709051413-1.pdfKarthiKeyan326587
 

Similaire à L 15 ct1120 (20)

1.Introduction to Data Structures and Algorithms.pptx
1.Introduction to Data Structures and Algorithms.pptx1.Introduction to Data Structures and Algorithms.pptx
1.Introduction to Data Structures and Algorithms.pptx
 
chapter09 -Programming Data Structures.pdf
chapter09 -Programming Data Structures.pdfchapter09 -Programming Data Structures.pdf
chapter09 -Programming Data Structures.pdf
 
Unit 1 linked list
Unit 1 linked listUnit 1 linked list
Unit 1 linked list
 
Unit 1.ppt
Unit 1.pptUnit 1.ppt
Unit 1.ppt
 
ds bridge.pptx
ds bridge.pptxds bridge.pptx
ds bridge.pptx
 
Data structure unitfirst part1
Data structure unitfirst part1Data structure unitfirst part1
Data structure unitfirst part1
 
Data structure unitfirst part1
Data structure unitfirst part1Data structure unitfirst part1
Data structure unitfirst part1
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
Data Structures
Data StructuresData Structures
Data Structures
 
STACK AND QUEUE CIRCULAR QUEUE PPTS.pptx
STACK AND QUEUE CIRCULAR QUEUE PPTS.pptxSTACK AND QUEUE CIRCULAR QUEUE PPTS.pptx
STACK AND QUEUE CIRCULAR QUEUE PPTS.pptx
 
lecture 02.2.ppt
lecture 02.2.pptlecture 02.2.ppt
lecture 02.2.ppt
 
1.1 introduction to Data Structures.ppt
1.1 introduction to Data Structures.ppt1.1 introduction to Data Structures.ppt
1.1 introduction to Data Structures.ppt
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
unit 1.pptx
unit 1.pptxunit 1.pptx
unit 1.pptx
 
Linked list
Linked listLinked list
Linked list
 
lecture4.pdf
lecture4.pdflecture4.pdf
lecture4.pdf
 
Linked list ppt
Linked list pptLinked list ppt
Linked list ppt
 
Data Structures 3
Data Structures 3Data Structures 3
Data Structures 3
 
Unit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdfUnit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdf
 
unit-ids17-180709051413-1.pdf
unit-ids17-180709051413-1.pdfunit-ids17-180709051413-1.pdf
unit-ids17-180709051413-1.pdf
 

Plus de Zia Ush Shamszaman

Pdfslide.net book of-abstracts-insight-student-conference-2015
Pdfslide.net book of-abstracts-insight-student-conference-2015Pdfslide.net book of-abstracts-insight-student-conference-2015
Pdfslide.net book of-abstracts-insight-student-conference-2015Zia Ush Shamszaman
 
Hacking with Backtrack Lecture-3
Hacking with Backtrack Lecture-3Hacking with Backtrack Lecture-3
Hacking with Backtrack Lecture-3Zia Ush Shamszaman
 
Hacking with Backtrack Lecture-2
Hacking with Backtrack Lecture-2Hacking with Backtrack Lecture-2
Hacking with Backtrack Lecture-2Zia Ush Shamszaman
 
Hacking with Backtrack Lecture-1
Hacking with Backtrack Lecture-1Hacking with Backtrack Lecture-1
Hacking with Backtrack Lecture-1Zia Ush Shamszaman
 
On the need for applications aware adaptive middleware in real-time RDF data ...
On the need for applications aware adaptive middleware in real-time RDF data ...On the need for applications aware adaptive middleware in real-time RDF data ...
On the need for applications aware adaptive middleware in real-time RDF data ...Zia Ush Shamszaman
 
On the need for applications aware adaptive middleware in real-time RDF data ...
On the need for applications aware adaptive middleware in real-time RDF data ...On the need for applications aware adaptive middleware in real-time RDF data ...
On the need for applications aware adaptive middleware in real-time RDF data ...Zia Ush Shamszaman
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary searchZia Ush Shamszaman
 

Plus de Zia Ush Shamszaman (12)

Pdfslide.net book of-abstracts-insight-student-conference-2015
Pdfslide.net book of-abstracts-insight-student-conference-2015Pdfslide.net book of-abstracts-insight-student-conference-2015
Pdfslide.net book of-abstracts-insight-student-conference-2015
 
Hacking with Backtrack Lecture-3
Hacking with Backtrack Lecture-3Hacking with Backtrack Lecture-3
Hacking with Backtrack Lecture-3
 
Hacking with Backtrack Lecture-2
Hacking with Backtrack Lecture-2Hacking with Backtrack Lecture-2
Hacking with Backtrack Lecture-2
 
Hacking with Backtrack Lecture-1
Hacking with Backtrack Lecture-1Hacking with Backtrack Lecture-1
Hacking with Backtrack Lecture-1
 
On the need for applications aware adaptive middleware in real-time RDF data ...
On the need for applications aware adaptive middleware in real-time RDF data ...On the need for applications aware adaptive middleware in real-time RDF data ...
On the need for applications aware adaptive middleware in real-time RDF data ...
 
On the need for applications aware adaptive middleware in real-time RDF data ...
On the need for applications aware adaptive middleware in real-time RDF data ...On the need for applications aware adaptive middleware in real-time RDF data ...
On the need for applications aware adaptive middleware in real-time RDF data ...
 
L 19 ct1120
L 19 ct1120L 19 ct1120
L 19 ct1120
 
L 18 ct1120
L 18 ct1120L 18 ct1120
L 18 ct1120
 
L 17 ct1120
L 17 ct1120L 17 ct1120
L 17 ct1120
 
L 14-ct1120
L 14-ct1120L 14-ct1120
L 14-ct1120
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary search
 
Bangladesh
BangladeshBangladesh
Bangladesh
 

Dernier

Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一ffjhghh
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysismanisha194592
 
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.pptxolyaivanovalion
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxolyaivanovalion
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
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 interactionfulawalesam
 
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 signalsInvezz1
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiSuhani Kapoor
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiSuhani Kapoor
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSAishani27
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFxolyaivanovalion
 

Dernier (20)

Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
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
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
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
 
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
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICS
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 

L 15 ct1120

  • 1. First Year BA (IT) CT1120 Algorithms Lecture 15 Dr. Zia Ush Shamszaman z.shamszaman1@nuigalway.ie 1 School of Computer Science, College of Science and Engineering 31-01-2020
  • 2. Overview •  Data Structure –  Stack –  Queue –  Tree •  Reviewing previous lectures •  Feedback and Assessment 231-01-2020
  • 3. 3 Data Structure Concepts •  Data Structures are containers: –  they hold other data –  arrays are a data structure –  ... so are lists •  Other types of data structures: –  stack, queue, tree, binary search tree, hash table, dictionary or map, set, and on and on •  Different types of data structures are optimized for certain types of operations 31-01-2020
  • 4. Basic Data Structure Basic Data Structures Linear Data Structures Non-Linear Data Structures Arrays Linked Lists Stacks Queues Trees Graphs Hash Tables 31-01-2020 4
  • 6. 6 Data Structure Operations •  Data Structures will have 3 core operations –  a way to add things –  a way to remove things –  a way to access things •  Details of these operations depend on the data structure –  Example: List, add at the end, access by location, remove by location •  More operations added depending on what data structure is designed to do 31-01-2020
  • 7. Data Structure Operations Ø  Traversing: Accessing each record exactly once so that certain items in the record may be processed. Ø  Searching: Finding the location of the record with a given key value, or finding the locations of all records which satisfy one or more conditions. Ø  Insertion: Adding a new record to the structure. Ø  Deletion: Removing a record from the structure. Following two are special operations: Ø  Sorting: Arranging the records in some logical order. Ø  Merging: Combining the records in two different sorted files into a single sorted file. 31-01-2020 7
  • 8. Selection of Data Structure •  The choice of particular data model depends on two consideration: –  It must be rich enough in structure to represent the relationship between data elements –  The structure should be simple enough that one can effectively process the data when necessary 31-01-2020 8
  • 9. Stack •  A Stack is a list of elements in which an element may be inserted or deleted at one end which is known as TOP of the stack. 31-01-2020 9
  • 10. Stack •  Collection with access only to the last element inserted •  Last in First out (LIFO) •  Insert/Push •  Remove/Pop •  Top •  Make empty TopData4 Data3 Data2 Data1 push pop 31-01-2020 10
  • 11. Stack Operation 31-01-2020 11 •  Stack() creates a new stack that is empty. It needs no parameters and returns an empty stack. •  push(item) adds a new item to the top of the stack. It needs the item and returns nothing. •  pop() removes the top item from the stack. It needs no parameters and returns the item. The stack is modified. •  peek() returns the top item from the stack but does not remove it. It needs no parameters. The stack is not modified. •  isEmpty() tests to see whether the stack is empty. It needs no parameters and returns a boolean value. •  size() returns the number of items on the stack. It needs no parameters and returns an integer.
  • 13. Example from pythonds.basic import Stack s=Stack() print(s.isEmpty()) s.push(4) s.push('dog') print(s.peek()) s.push(True) print(s.size()) print(s.isEmpty()) s.push(8.4) print(s.pop()) print(s.pop()) print(s.size()) 31-01-2020 13 True dog 3 False 8.4 True 2 Output
  • 14. Queue •  A queue is an ordered collection of items where the addition of new items happens at one end, called the “rear,” and the removal of existing items occurs at the other end, commonly called the “front.” •  As an element enters the queue it starts at the rear and makes its way toward the front, waiting until that time when it is the next element to be removed.. 31-01-2020 14
  • 15. Queue •  Collection with access only to the item that has been present the longest •  Last in Last Out (LILO)/First in First Out(FIFO) •  enqueue, dequeue, front •  priority queues and dequeue 31-01-2020 15
  • 16. Basic Operation •  Queue() creates a new queue that is empty. It needs no parameters and returns an empty queue. •  enqueue(item) adds a new item to the rear of the queue. It needs the item and returns nothing. •  dequeue() removes the front item from the queue. It needs no parameters and returns the item. The queue is modified. •  isEmpty() tests to see whether the queue is empty. It needs no parameters and returns a boolean value. •  size() returns the number of items in the queue. It needs no parameters and returns an integer. 31-01-2020 16
  • 19. Tree •  A Tree is a collection of elements called nodes. •  One of the node is distinguished as a root, along with a relation (“parenthood”) that places a hierarchical structure on the nodes. 31-01-2020 19
  • 20. Vocabulary & Definitions •  Node –  A node is a fundamental part of a tree. It can have a name, which we call the “key.” A node may also have additional information. We call this additional information the “payload.” While the payload information is not central to many tree algorithms, it is often critical in applications that make use of trees. •  Edge –  An edge is another fundamental part of a tree. An edge connects two nodes to show that there is a relationship between them. Every node (except the root) is connected by exactly one incoming edge from another node. Each node may have several outgoing edges. •  Root –  The root of the tree is the only node in the tree that has no incoming edges. 31-01-2020 20
  • 21. Vocabulary & Definitions •  Path –  A path is an ordered list of nodes that are connected by edges. For example, Mammal → Carnivora → Felidae → Felis → Domestica is a path. •  Children –  The set of nodes 𝑐 that have incoming edges from the same node to are said to be the children of that node. •  Parent –  A node is the parent of all the nodes it connects to with outgoing edges. 31-01-2020 21
  • 22. Vocabulary & Definitions •  Sibling –  Nodes in the tree that are children of the same parent are said to be siblings. •  Subtree –  A subtree is a set of nodes and edges comprised of a parent and all the descendants of that parent. •  Leaf Node –  A leaf node is a node that has no children. For example, Human and Chimpanzee are leaf nodes 31-01-2020 22
  • 23. Next Lecture Class test Syllabus (all three lectures) 31-01-2020 23
  • 24. Useful Links •  http://www.csanimated.com/animation.php?t=Quicksort •  http://www.hakansozer.com/category/c/ •  http://www.nczonline.net/blog/2012/11/27/computer-science-in- javascript-quicksort/ •  http://www.sorting-algorithms.com/shell-sort •  https://www.tutorialspoint.com/ •  https://www.hackerearth.com/ •  www.khanacademy.org/computing/computer-science/algorithms 31-01-2020 24