Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...Edureka!
This Edureka "Python Loops" tutorial (Python Tutorial Blog: https://goo.gl/wd28Zr) will help you in understanding different types of loops used in Python. You will be learning how to implement all the loops in python practically. Below are the topics covered in this tutorial:
1) Why to use loops?
2) What are loops?
3) Types of loops in Python: While, For, Nested
4) Demo on each Python loop
Arrays In Python | Python Array Operations | EdurekaEdureka!
** Python Certification Training: https://www.edureka.co/python **
This Edureka PPT on 'Arrays in Python' will help you establish a strong hold on all the fundamentals in the Python programming language. Below are the topics covered in this PPT:
What is an array?
Is python list same as an array?
How to create arrays in python?
Accessing array elements
Basic array operations
- Finding the length of an array
- Adding Elements
- Removing elements
- Array concatenation
- Slicing
- Looping
Python Tutorial Playlist: https://goo.gl/WsBpKe
Blog Series: http://bit.ly/2sqmP4s
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Queues
a. Concept and Definition
b. Queue as an ADT
c. Implementation of Insert and Delete operation of:
• Linear Queue
• Circular Queue
For More:
https://github.com/ashim888/dataStructureAndAlgorithm
http://www.ashimlamichhane.com.np/
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...Edureka!
This Edureka "Python Loops" tutorial (Python Tutorial Blog: https://goo.gl/wd28Zr) will help you in understanding different types of loops used in Python. You will be learning how to implement all the loops in python practically. Below are the topics covered in this tutorial:
1) Why to use loops?
2) What are loops?
3) Types of loops in Python: While, For, Nested
4) Demo on each Python loop
Arrays In Python | Python Array Operations | EdurekaEdureka!
** Python Certification Training: https://www.edureka.co/python **
This Edureka PPT on 'Arrays in Python' will help you establish a strong hold on all the fundamentals in the Python programming language. Below are the topics covered in this PPT:
What is an array?
Is python list same as an array?
How to create arrays in python?
Accessing array elements
Basic array operations
- Finding the length of an array
- Adding Elements
- Removing elements
- Array concatenation
- Slicing
- Looping
Python Tutorial Playlist: https://goo.gl/WsBpKe
Blog Series: http://bit.ly/2sqmP4s
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Queues
a. Concept and Definition
b. Queue as an ADT
c. Implementation of Insert and Delete operation of:
• Linear Queue
• Circular Queue
For More:
https://github.com/ashim888/dataStructureAndAlgorithm
http://www.ashimlamichhane.com.np/
Array
Introduction
One-dimensional array
Multidimensional array
Advantage of Array
Write a C program using arrays that produces the multiplication of two matrices.
String literals in python are surrounded by either single quotation marks, or double quotation marks. Strings can be output to screen using the print function. For example: print("hello"). Like many other popular programming languages, strings in Python are arrays of bytes representing unicode characters.
Growth of Functions
CMSC 56 | Discrete Mathematical Structure for Computer Science
October 6, 2018
Instructor: Allyn Joy D. Calcaben
College of Arts & Sciences
University of the Philippines Visayas
Other than some generic containers like list, Python in its definition can also handle containers with specified data types. Array can be handled in python by module named “array“. They can be useful when we have to manipulate only a specific data type values.
in this how the split() function work with string in python is discussed
TO DOWNLOAD MORE INFORMATION:
https://computerassignmentsforu.blogspot.com/p/stringinpythonsplit.html
VIDEO TUTORIAL LINK:
https://youtu.be/6BvslDmk1Z8
Array
Introduction
One-dimensional array
Multidimensional array
Advantage of Array
Write a C program using arrays that produces the multiplication of two matrices.
String literals in python are surrounded by either single quotation marks, or double quotation marks. Strings can be output to screen using the print function. For example: print("hello"). Like many other popular programming languages, strings in Python are arrays of bytes representing unicode characters.
Growth of Functions
CMSC 56 | Discrete Mathematical Structure for Computer Science
October 6, 2018
Instructor: Allyn Joy D. Calcaben
College of Arts & Sciences
University of the Philippines Visayas
Other than some generic containers like list, Python in its definition can also handle containers with specified data types. Array can be handled in python by module named “array“. They can be useful when we have to manipulate only a specific data type values.
in this how the split() function work with string in python is discussed
TO DOWNLOAD MORE INFORMATION:
https://computerassignmentsforu.blogspot.com/p/stringinpythonsplit.html
VIDEO TUTORIAL LINK:
https://youtu.be/6BvslDmk1Z8
Queue is a collection whose elements are added at one end and removed from the other end
What is a Queue
Conceptual View of a Queue
Uses of Queues in Computing
Operations on a Queue
Implementation of a Queue
Applications
Downloadable Resources
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Data and AI
Round table discussion of vector databases, unstructured data, ai, big data, real-time, robots and Milvus.
A lively discussion with NJ Gen AI Meetup Lead, Prasad and Procure.FYI's Co-Found
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...John Andrews
SlideShare Description for "Chatty Kathy - UNC Bootcamp Final Project Presentation"
Title: Chatty Kathy: Enhancing Physical Activity Among Older Adults
Description:
Discover how Chatty Kathy, an innovative project developed at the UNC Bootcamp, aims to tackle the challenge of low physical activity among older adults. Our AI-driven solution uses peer interaction to boost and sustain exercise levels, significantly improving health outcomes. This presentation covers our problem statement, the rationale behind Chatty Kathy, synthetic data and persona creation, model performance metrics, a visual demonstration of the project, and potential future developments. Join us for an insightful Q&A session to explore the potential of this groundbreaking project.
Project Team: Jay Requarth, Jana Avery, John Andrews, Dr. Dick Davis II, Nee Buntoum, Nam Yeongjin & Mat Nicholas
Adjusting primitives for graph : SHORT REPORT / NOTESSubhajit Sahu
Graph algorithms, like PageRank Compressed Sparse Row (CSR) is an adjacency-list based graph representation that is
Multiply with different modes (map)
1. Performance of sequential execution based vs OpenMP based vector multiply.
2. Comparing various launch configs for CUDA based vector multiply.
Sum with different storage types (reduce)
1. Performance of vector element sum using float vs bfloat16 as the storage type.
Sum with different modes (reduce)
1. Performance of sequential execution based vs OpenMP based vector element sum.
2. Performance of memcpy vs in-place based CUDA based vector element sum.
3. Comparing various launch configs for CUDA based vector element sum (memcpy).
4. Comparing various launch configs for CUDA based vector element sum (in-place).
Sum with in-place strategies of CUDA mode (reduce)
1. Comparing various launch configs for CUDA based vector element sum (in-place).
The Building Blocks of QuestDB, a Time Series Databasejavier ramirez
Talk Delivered at Valencia Codes Meetup 2024-06.
Traditionally, databases have treated timestamps just as another data type. However, when performing real-time analytics, timestamps should be first class citizens and we need rich time semantics to get the most out of our data. We also need to deal with ever growing datasets while keeping performant, which is as fun as it sounds.
It is no wonder time-series databases are now more popular than ever before. Join me in this session to learn about the internal architecture and building blocks of QuestDB, an open source time-series database designed for speed. We will also review a history of some of the changes we have gone over the past two years to deal with late and unordered data, non-blocking writes, read-replicas, or faster batch ingestion.
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...pchutichetpong
M Capital Group (“MCG”) expects to see demand and the changing evolution of supply, facilitated through institutional investment rotation out of offices and into work from home (“WFH”), while the ever-expanding need for data storage as global internet usage expands, with experts predicting 5.3 billion users by 2023. These market factors will be underpinned by technological changes, such as progressing cloud services and edge sites, allowing the industry to see strong expected annual growth of 13% over the next 4 years.
Whilst competitive headwinds remain, represented through the recent second bankruptcy filing of Sungard, which blames “COVID-19 and other macroeconomic trends including delayed customer spending decisions, insourcing and reductions in IT spending, energy inflation and reduction in demand for certain services”, the industry has seen key adjustments, where MCG believes that engineering cost management and technological innovation will be paramount to success.
MCG reports that the more favorable market conditions expected over the next few years, helped by the winding down of pandemic restrictions and a hybrid working environment will be driving market momentum forward. The continuous injection of capital by alternative investment firms, as well as the growing infrastructural investment from cloud service providers and social media companies, whose revenues are expected to grow over 3.6x larger by value in 2026, will likely help propel center provision and innovation. These factors paint a promising picture for the industry players that offset rising input costs and adapt to new technologies.
According to M Capital Group: “Specifically, the long-term cost-saving opportunities available from the rise of remote managing will likely aid value growth for the industry. Through margin optimization and further availability of capital for reinvestment, strong players will maintain their competitive foothold, while weaker players exit the market to balance supply and demand.”
Adjusting OpenMP PageRank : SHORT REPORT / NOTESSubhajit Sahu
For massive graphs that fit in RAM, but not in GPU memory, it is possible to take
advantage of a shared memory system with multiple CPUs, each with multiple cores, to
accelerate pagerank computation. If the NUMA architecture of the system is properly taken
into account with good vertex partitioning, the speedup can be significant. To take steps in
this direction, experiments are conducted to implement pagerank in OpenMP using two
different approaches, uniform and hybrid. The uniform approach runs all primitives required
for pagerank in OpenMP mode (with multiple threads). On the other hand, the hybrid
approach runs certain primitives in sequential mode (i.e., sumAt, multiply).
Data Structures and Algorithm - Week 3 - Stacks and Queues
1. Data Structures and
Algorithms
Week 3: Stack and Queues
Ferdin Joe John Joseph, PhD
Faculty of Information Technology
Thai-Nichi Institute of Technology, Bangkok
2. Week 3
• Stack
• Queues
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
2
3. Developing an ADT
• ADT stack operations
• Create an empty stack
• Determine whether a stack is empty
• Add a new item to the stack
• Remove from the stack the item that was added most
recently
• Remove all the items from the stack
• Retrieve from the stack the item that was added most
recently
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
3
4. Developing an ADT During the
Design of a Solution
• A stack
• Last-in, first-out (LIFO)
property
• The last item placed on
the stack will be the
first item removed
• Analogy
• A stack of dishes in a
cafeteria
Stack of cafeteria dishes
Lecture series for Data Structures and
Algorithms, Data Science and Analytics, Thai-
Nichi Institute of Technology
7A-4
5. Refining the Definition of the ADT
Stack
• Pseudocode for the ADT stack operations
createStack()
// Creates an empty stack.
isEmpty()
// Determines whether a stack is empty.
push(newItem) throws StackException
// Adds newItem to the top of the stack.
// Throws StackException if the insertion is
// not successful.
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
5
6. Refining the Definition of the ADT
Stack
• Pseudocode for the ADT stack operations (Cont)
pop() throws StackException
// Retrieves and then removes the top of the stack.
// Throws StackException if the deletion is not
// successful.
popAll()
// Removes all items from the stack.
peek() throws StackException
// Retrieves the top of the stack. Throws
// StackException if the retrieval is not successful
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
6
7. Simple Applications of the ADT Stack:
Checking for Balanced Braces
• A stack can be used to verify whether a program
contains balanced braces
• An example of balanced braces
abc{defg{ijk}{l{mn}}op}qr
• An example of unbalanced braces
abc{def}}{ghij{kl}m
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
7
8. Checking for Balanced Braces
• Requirements for balanced braces
• Each time you encounter a "{", push it on the stack
• Each time you encounter a “}”, it matches an already
encountered “{”, pop "{" off the stack
• When you reach the end of the string, you should have
matched each “{” and the stack should be empty
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
8
9. Checking for Balanced Braces
Traces of the algorithm that checks for balanced braces
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
9
10. Implementations of the ADT Stack
• The ADT stack can be implemented using
• An array
• A linked list
• The ADT list in the JCF
• StackInterface
• Provides a common specification for the three
implementations
• StackException
• Used by StackInterface
• Extends java.lang.RuntimeException
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
10
11. Implementations of the ADT Stack
Implementation of the
ADT stack that use a)
an array; b) a linked list;
c) an ADT list
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
11
12. An Array-Based Implementation of
the ADT Stack
• StackArrayBased class
• Implements StackInterface
• Instances
• Stacks
• Private data fields
• An array of Objects called items
• The index top
An array-based implementation
Lecture series for Data Structures and
Algorithms, Data Science and Analytics, Thai-
Nichi Institute of Technology
12
13. A Reference-Based
Implementation of the ADT Stack
A reference-based
implementation
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
13
14. Comparing Implementations
• All of the three implementations are ultimately
array based or reference based
• Fixed size versus dynamic size
• An array-based implementation
• Uses fixed-sized arrays
• Prevents the push operation from adding an item to the stack if
the stack’s size limit has been reached
• A reference-based implementation
• Does not put a limit on the size of the stack
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
14
15. Evaluating Postfix Expressions
• A postfix calculator
• Requires you to enter postfix expressions
• Example: 2 3 4 + * (= 2*(3+4))
• When an operand is entered, the calculator
• Pushes it onto a stack
• When an operator is entered, the calculator
• Applies it to the top two operands of the stack
• Pops the operands from the stack
• Pushes the result of the operation on the stack
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
15
16. Evaluating Postfix Expressions
The action of a postfix calculator when evaluating the expression 2 * (3 + 4)
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
16
17. Evaluating Postfix Expressions
• To evaluate a postfix expression which is entered as
a string of characters
• Simplifying assumptions
• The string is a syntactically correct postfix expression
• No unary operators are present
• No exponentiation operators are present
• Operands are single lowercase letters that represent integer
values
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
17
18. Converting Infix Expressions to
Equivalent Postfix Expressions
• An infix expression can be evaluated by first being converted
into an equivalent postfix expression
• Facts about converting from infix to postfix
• Operands always stay in the same order with respect to one
another
• An operator will move only “to the right” with respect to the
operands
• All parentheses are removed
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
18
19. Converting Infix Expressions to
Equivalent Postfix Expressions
A trace of the algorithm that converts the infix expression a - (b + c * d)/e to postfix form
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
19
20. Java Implementation
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
20
21. Week 3
• Stack
• Queues
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
21
22. The Abstract Data Type Queue
• A queue
• New items enter at the back, or rear, of the queue
• Items leave from the front of the queue
• First-in, first-out (FIFO) property
• The first item inserted into a queue is the first item to leave
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
22
23. The Abstract Data Type Queue
• ADT queue operations
• Create an empty queue
• Determine whether a queue is empty
• Add a new item to the queue
• Remove from the queue the item that was added
earliest
• Remove all the items from the queue
• Retrieve from the queue the item that was added
earliest
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
23
24. The Abstract Data Type Queue
• Queues
• Are appropriate for many real-world situations
• Example: A line to buy a movie ticket
• Have applications in computer science
• Example: A request to print a document
• A simulation
• Discrete event simulator
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
24
25. The Abstract Data Type Queue
• Pseudocode for the ADT queue operations
createQueue()
// Creates an empty queue.
isEmpty()
// Determines whether a queue is empty
enqueue(newItem) throws QueueException
// Adds newItem at the back of a queue. Throws
// QueueException if the operation is not
// successful
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
25
26. The Abstract Data Type Queue
• Pseudocode for the ADT queue operations (Cont)
dequeue() throws QueueException
// Retrieves and removes the front of a queue.
// Throws QueueException if the operation is
// not successful.
dequeueAll()
// Removes all items from a queue
peek() throws QueueException
// Retrieves the front of a queue. Throws
// QueueException if the retrieval is not
// successful
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
26
27. The Abstract Data Type Queue
Some queue operations
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
27
28. Simple Applications of the ADT
Queue: Reading a String of
Characters
• A queue can retain characters in the order in
which they are typed
queue.createQueue()
while (not end of line) {
Read a new character ch
queue.enqueue(ch)
}
• Once the characters are in a queue, the system can
process them as necessary
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
28
29. Recognizing Palindromes
• A palindrome
• A string of characters that reads the same from left to
right as its does from right to left
• To recognize a palindrome, a queue can be used in
conjunction with a stack
• A stack can be used to reverse the order of occurrences
• A queue can be used to preserve the order of
occurrences
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
29
30. Recognizing Palindromes
• A nonrecursive recognition
algorithm for palindromes
• As you traverse the
character string from left to
right, insert each character
into both a queue and a
stack
• Compare the characters at
the front of the queue and
the top of the stack
The results of inserting a string
into both a queue and a stack
Lecture series for Data Structures and
Algorithms, Data Science and Analytics, Thai-
Nichi Institute of Technology
7A-30
31. Implementations of the ADT
Queue
• A queue can have either
• An array-based implementation
• A reference-based implementation
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
31
32. A Reference-Based Implementation
• Possible implementations of a queue
• A linear linked list with two external references
• A reference to the front
• A reference to the back
A reference-based implementation of a queue: a) a linear linked list with two
external references
Lecture series for Data Structures and
Algorithms, Data Science and Analytics, Thai-
Nichi Institute of Technology
7A-32
33. A Reference-Based Implementation
• Possible implementations of a queue (Continued)
• A circular linked list with one external reference
• A reference to the back
A reference-based implementation of a queue: b) a circular linear linked list with one
external reference
Lecture series for Data Structures and
Algorithms, Data Science and Analytics, Thai-
Nichi Institute of Technology
7A-33
34. A Reference-Based
Implementation
Inserting an item into a nonempty queue
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
34
35. A Reference-Based
Implementation
Inserting an item into an empty queue: a) before insertion; b) after insertion
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
35
36. A Reference-Based
Implementation
Deleting an item from a queue of more than one item
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
36
37. An Implementation That Uses the
ADT List
• If the item in position 1 of a list list represents
the front of the queue, the following
implementations can be used
• dequeue()
list.remove(1)
• peek()
list.get(1)
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
37
38. An Implementation That Uses the
ADT List
• If the item at the end of the list represents the
back of the queue, the following implementations
can be used
• enqueue(newItem)
list.add(list.size()+1, newItem)
An implementation that uses the ADT list
Lecture series for Data Structures and
Algorithms, Data Science and Analytics, Thai-
Nichi Institute of Technology
7A-38
39. Application: Simulation
A blank line at at time a) 0; b) 12
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
39
40. Application: Simulation
A blank line at at time c) 20; d) 38
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
40
41. Java Implementation
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
41
42. The ADT Priority Queue
• Organize data by priorities
• Example: weekly “to do” list
• Priority value
• We will say high value high priority
• Operations
• Test for empty
• Add to queue in sorted position
• Remove/get entry with highest priority
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
42
43. Real-life Priority Queue
• Example : triage in a hospital emergency room
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
43
44. Real-life Priority Queue
• Example : Public Transport in Thailand
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
44
45. Priority Queue
A priority queue is an ADT with the property that
only the highest-priority element can be accessed
at any time.
Queue
Enque an item
Item returned has been in the queue the
longest amount of time.
Priority Queue
Enque a pair <item, priority>
Item returned has the highest priority.
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
45
46. Tracking Your Assignments
• Pseudocode to organize assignments,
responsibilities
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
46
47. Application: Simulation
• Simulation models behavior of systems
• Problem to solve
• Approximate average time bank customer must wait for
service from a teller
• Decrease in customer wait time with each new teller added
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
47
48. Application: Simulation
• Sample arrival and transaction times
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
48
49. Application: Simulation
• A bank line at time (a) 0; (b) 20; (c) 22; (d) 26
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
49
50. Application: Simulation
• A bank line at time (a) 0; (b) 20; (c) 22; (d) 26
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
50
51. Application: Simulation
• Pseudocode for an event loop
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
51
52. Application: Simulation
• Time-driven simulation
• Simulates the ticking of a clock
• Event-driven simulation considers
• Only the times of certain events,
• In this case, arrival-s and departures
• Event list contains
• All future arrival and departure events
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
52
53. Application: Simulation
• A typical instance of (a) an arrival event;
(b) a departure event
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
53
54. Application: Simulation
• Two tasks required to process each event
• Update the bank line: Add or remove customers
• Update the event queue: Add or remove events
• New customer
• Always enters bank line
• Served while at the front of the line
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
54
55. Application: Simulation
• A trace of the bank simulation algorithm for the data
(20, 6), (22, 4), (23, 2), (30, 3)
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
55
56. Java Implementation
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
56
57. Java Implementation
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
57
58. Activity - Graded
• Create a priority queue code using Java for
implementing Visa on Arrival passengers. Priority
should be of order below
• Elderly 55+
• Pregnant Women
• Differently abled
• Women with infants
Code should be submitted to canvas portal before
next class. Those who complete by today’s class will
receive a bonus point.
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
58
59. Next Week
Tree ADT and its applications
Tree Traversals
Binary Trees
Implementation in Java
Lecture series for Data Structures and
Algorithms, Data Science and Analytics,
Thai-Nichi Institute of Technology
59