Course: Intro to Computer Science (Malmö Högskola)
Some classic data structures within computer science modeling: stacks, queues, vectors, linked-lists, graphs
Slides for Introductory session on K Means Clustering.
simple and good. ppt
Could be used for taking classes for MCA students on Clustering Algorithms for Data mining.
Prepared By K.T.Thomas HOD of Computer Science, Santhigiri College Vazhithala
Slides for Introductory session on K Means Clustering.
simple and good. ppt
Could be used for taking classes for MCA students on Clustering Algorithms for Data mining.
Prepared By K.T.Thomas HOD of Computer Science, Santhigiri College Vazhithala
this is a briefer overview about the Big O Notation. Big O Notaion are useful to check the Effeciency of an algorithm and to check its limitation at higher value. with big o notation some examples are also shown about its cases and some functions in c++ are also described.
•Common Problems Needs Computers
•The Search Problem
•Basic Search Algorithms
–Algorithms used for searching the contents of an array
•Linear or Sequential Search
•Binary Search
•Comparison Between Linear and Binary Search
•Algorithms for solving shortest path problems
–Sequential Search Algorithms
•Depth-First Search
•Breadth First Search
–Parallel or distributed Search Algorithms
•Parallel Depth-First Search
•Parallel Breadth First Search
Square transposition: an approach to the transposition process in block cipherjournalBEEI
The transposition process is needed in cryptography to create a diffusion effect on data encryption standard (DES) and advanced encryption standard (AES) algorithms as standard information security algorithms by the National Institute of Standards and Technology. The problem with DES and AES algorithms is that their transposition index values form patterns and do not form random values. This condition will certainly make it easier for a cryptanalyst to look for a relationship between ciphertexts because some processes are predictable. This research designs a transposition algorithm called square transposition. Each process uses square 8 × 8 as a place to insert and retrieve 64-bits. The determination of the pairing of the input scheme and the retrieval scheme that have unequal flow is an important factor in producing a good transposition. The square transposition can generate random and non-pattern indices so that transposition can be done better than DES and AES.
this is a briefer overview about the Big O Notation. Big O Notaion are useful to check the Effeciency of an algorithm and to check its limitation at higher value. with big o notation some examples are also shown about its cases and some functions in c++ are also described.
•Common Problems Needs Computers
•The Search Problem
•Basic Search Algorithms
–Algorithms used for searching the contents of an array
•Linear or Sequential Search
•Binary Search
•Comparison Between Linear and Binary Search
•Algorithms for solving shortest path problems
–Sequential Search Algorithms
•Depth-First Search
•Breadth First Search
–Parallel or distributed Search Algorithms
•Parallel Depth-First Search
•Parallel Breadth First Search
Square transposition: an approach to the transposition process in block cipherjournalBEEI
The transposition process is needed in cryptography to create a diffusion effect on data encryption standard (DES) and advanced encryption standard (AES) algorithms as standard information security algorithms by the National Institute of Standards and Technology. The problem with DES and AES algorithms is that their transposition index values form patterns and do not form random values. This condition will certainly make it easier for a cryptanalyst to look for a relationship between ciphertexts because some processes are predictable. This research designs a transposition algorithm called square transposition. Each process uses square 8 × 8 as a place to insert and retrieve 64-bits. The determination of the pairing of the input scheme and the retrieval scheme that have unequal flow is an important factor in producing a good transposition. The square transposition can generate random and non-pattern indices so that transposition can be done better than DES and AES.
JThermodynamicsCloud is software service for the chemical, or more specifically, the combustion research
domain. JThermodynamicsCloud service can be said to be an model driven application, where the ontology
is a platform independent model of the data and operational structures. The ontology, as used by the service,
has three distinct purposes: documentation, data structure definition and operational definitions. One goal of
the ontology is to place as much of the design and domain specific structures in the ontology rather than in
the application code. The application code interprets the ontology in the backend. The primary purpose of
the JThermodynamicsCloud is to perform thermdynamic calculations and manage the data needed to make
those calculations. The calculation itself is highly dependent on the varied types of molecular data found in
the database The complete service is a system with three interacting components, a user interface using
Angular, a (RESTful) backend written in JAVA (with the JENA API interpreting the ontology) and the
Google Firestore noSQL document database and Firebase storage. The service uses these three components
to make calculations for thermodynamic quantities based on molecular species structure. These different
platforms are united through the ontology.
JThermodynamicsCloud is software service for the chemical, or more specifically, the combustion research
domain. JThermodynamicsCloud service can be said to be an model driven application, where the ontology
is a platform independent model of the data and operational structures. The ontology, as used by the service,
has three distinct purposes: documentation, data structure definition and operational definitions. One goal of
the ontology is to place as much of the design and domain specific structures in the ontology rather than in
the application code. The application code interprets the ontology in the backend. The primary purpose of
the JThermodynamicsCloud is to perform thermdynamic calculations and manage the data needed to make
those calculations. The calculation itself is highly dependent on the varied types of molecular data found in
the database The complete service is a system with three interacting components, a user interface using
Angular, a (RESTful) backend written in JAVA (with the JENA API interpreting the ontology) and the
Google Firestore noSQL document database and Firebase storage. The service uses these three components
to make calculations for thermodynamic quantities based on molecular species structure. These different
platforms are united through the ontology.
JThermodynamicsCloud is software service for the chemical, or more specifically, the combustion research
domain. JThermodynamicsCloud service can be said to be an model driven application, where the ontology
is a platform independent model of the data and operational structures. The ontology, as used by the service,
has three distinct purposes: documentation, data structure definition and operational definitions. One goal of
the ontology is to place as much of the design and domain specific structures in the ontology rather than in
the application code. The application code interprets the ontology in the backend. The primary purpose of
the JThermodynamicsCloud is to perform thermdynamic calculations and manage the data needed to make
those calculations. The calculation itself is highly dependent on the varied types of molecular data found in
the database The complete service is a system with three interacting components, a user interface using
Angular, a (RESTful) backend written in JAVA (with the JENA API interpreting the ontology) and the
Google Firestore noSQL document database and Firebase storage. The service uses these three components
to make calculations for thermodynamic quantities based on molecular species structure. These different
platforms are united through the ontology.
ChemConnect: Poster for European Combustion Meeting 2017Edward Blurock
This is a poster presented at the European Combustion Meeting, April 2017. It explains the Reference Description Language (RDF) setup of the database and the direction and development of the ChemConnect database project as an efficient means of data retrieval and data exhange and how the project is moving towards being an Electronic Laboratory Notebook (ELN).
EU COST Action CM1404: WG€ - Efficient Data ExchangeEdward Blurock
This talk discusses the topic of data exchange within the combustion community. This is a summary of a task force on data exchange within the WG4 working group, Standard definition for data collection and mining toward a virtual chemistry of Smart Energy Carriers, within the SMARTCATS EU COST Action CM1404
ChemConnect: Characterizing CombusAon KineAc Data with ontologies and meta-‐...Edward Blurock
ChemConnect is a database that interconnects fine-grained information extracted from chemical kinetic and thermodynamic sources such as
CHEMKIN mechanism files, NASA polynomial files, and even the information behind automatic generation files.
The key to the interconnection is the Resource Description Framework (RDF) from Semantic Web technologies. The RDF is a triplet where an object item (first) is associated through a descriptor (second) to a subject item.
In this way the information of the object is connected (through the descriptor) to the subject.
In ChemConnect the object is word (text) and the subject can be text or a database item. The search mechanism within ChemConnect uses the object and subject text as search strings.
The presentation also contains an brief introduction to cloud computing.
This was presented at the COST Action 1404 SMARTCATS workshop on Databases and Systems Use Cases (http//http://www.smartcats.eu/wg4ws1dp/)
Poster: Characterizing Ignition behavior through morphing to generic curvesEdward Blurock
The qualitative notion that ignition processes have similar behavior, even over an extensive range of starting conditions, is quantitatively demonstrated through the production of a single ’generic’ ignition curve. The key to the production of the generic curve is the recognition that the basic shapes of the species and temperature profiles occurring in the ignition process differ only in their ’timing’. By ’morphing’ the time scale, the profile shapes can be made to align. From the aligned profile shapes a generic or ’average’ profile can be derived. Synchronizing chemical events modifies the ignition progress times. In addition to fixing the ignition time to have the progress value of one, intermediate ignition events (such as selected profile maxima or inflection points) that occur before ignition are also aligned to have specific ’normalized’ times.
The goal of the Very Open Data Project is to provide a software-technical foundation for this exchange of data, more specifically to provide an open database platform for data from the raw data coming from experimental measurements or models through intermediate manipulations to finally published results. The sheer expanse of the amount data involved creates some unique software-technical challenges. One of these challenges is addressed in the part of the study presented here, namely to characterize scientific data (with the initial focus being detailed chemistry data from the combustion kinetic community), so that efficient searches can be made. A formalization of this characterization comes in the form of schemas of descriptions of tags and keywords describing data and ontologies describing the relationship between data types and the relationship between the characterizations themselves. These will be translated to meta-data tags connected to the data points within a non-relational data of data for the community.
The focus of the initial work will be on data and its accessibility. As the project progresses, the emphasis will shift on not only having available data accessible for the community, but that the community itself will be able to, with emphasis on minimal effort, will be able contribute their own data. This will involve, for example, the concepts of the ‘electronic lab notebook’ and the existence and availability of extensive concept extraction tools, primarily from the chemical informatics field.
This describes a tabulation method based on computing, retaining and accessing a large, on the order of millions, number of individual kinetic time step calculations and approximations. It is essentially an extension of Pope’s In Situ Adaptive Tabulation
(ISAT) method. The primary differences lie in that not all configurations need be stored in memory and that a polynomial approximation is only calculated when enough points have accumulated within a localized area to be able to calculate the
polynomial approximation. The latter increases efficiency because no extra points are evaluated to form an approximation (as is done in ISAT). The speed up is expected to be that of ISAT.
Characterization Ignition Behavior through Morphing to Generic Ignition CurvesEdward Blurock
Presented at the International Conference of Chemical Kinetics, Ghent, Belgium, July, 2015
The qualitative notion that ignition processes have similar behavior, even over an extensive range of starting conditions, is quantitatively demonstrated through the production of a single ’generic’ ignition curve. The key to the production of the generic curve is the recognition that the basic shapes of the species and temperature profiles occurring in the ignition process differ only in their ’timing’. By ’morphing’ the time scale, the profile shapes can be made to align. From the aligned profile shapes, a generic or ’average’ profile can be derived. Synchronizing chemical events modifies the ignition progress times. In addition to fixing the ignition time to have the progress value of one, intermediate ignition events (such as selected profile maxima or inflection points) that occur before ignition are also aligned to have specific ’normalized’ times. With this additional synchronization, a single generic curve, derived from the average of the morphed curves, can be derived. This generic curve represents a kinetic modelers intuitive notion of the mechanism of the process.
Course: Programming Languages and Paradigms:
A brief introduction to imperative programming principles: history, von neumann, BNF, variables (r-values, l-values), modifiable data structures, order of evaluation, static and dynamic scopes, referencing environments, call by value, control flow (sequencing, selection, iteration), ...
Course: Programming Languages and Paradigms:
This introduces concepts related to programming languate design: abstraction, a bit of history, the syntax, semantics and pragmatics of programming languages, languages as abstraction, thought shaper, simplifier and law enforcer.program verification, denotational and operational semantics
Course: Intro to Computer Science (Malmö Högskola):
knowledge representation and abstraction, decision making, generalization, data acquistion (abstraction), machine learning, similarity
another version of abstraction
Course: Intro to Computer Science (Malmö Högskola):
A very general overview of computer science from machine, operating systems, networks, applications...
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
2. Why different data types?
Complexity of Manipulation
One
criteria:
The data structure can have an effect
on how difficult the task is
3. Vector of size n
Efficient for the nth element
A single arithmetic calculation
Complexity does not increase as the vector gets bigger
O(1)
76 8 9 10 11 120 1 2 3 4 5
Pos(v[0]) Pos(v[0]) + 5
Find ith element of vector
This is exactly an example for what a vector is designed for
4. Vector of size n
Insert before ith element in vector
76 8 9 10 11 120 1 2 3 4 5
1. Allocate vector of size n+1
2. Copy element 0 to i-1 to places 0 to i-1
and
copy elements i to n-1 to places i+1 to n
76 8 9 10 11 120 1 2 3 4 5
1 operation
n
operations
3. Set in element
76 8 9 10 11 120 1 2 3 4 5 13
1 operation
Vectors are not designed to be used with insertion operations
As the vector gets larger, the insertion takes more time/operations
O(n)
5. Complexity
O(1) Time/operation complexity does not increase
with the size of the problem
O(n) Time/operation complexity does increases linearly
with the size of the problem
Find ith element of vector
Insert before ith element in vector
7. Linked List
43210 5
Find ith element of linked list
43210 5
Have to traverse structure to ith element
Linked lists are not designed to find the ith element
As the list increases in size, the number of steps can increase
O(n)
8. Linked List
Insert an element
2
43210 5
2
43210 5
Change pointers… one operation
Linked lists are exactly designed to insert an element
Regardless of the size of the list, the insertion is still one
operation
9. Linear Search
I am thinking of a number between 1 and 10
If you just guess number (for example sequentially)
Best case: correct on the 1 guess
Worse case: correct after 10 guesses
On the average it will take you 5 guesses
In general:
for a number between 1 and n it will take you n/2 guesses
Complexity: n/2 guesses O(n)
Don’t worry about the constant ½…
The complexity increases linearly with the size of the problem
10. Binary Search
For every guess I will say whether it is correct, higher or lower
4
62
7531
Best Case:
1 guess
Worse Case:
3 guesses
At most log2 8 = 3 are needed
In general: log2 n guesses O(log n)
Extra information:
11. Complexity of operations
The proper data structure can increase the efficiency of an algorithm
For structures of size n
Increases linearly with size of structure
Does not depend on size of structure
12. Complexity of an Algorithm
O(c) Complexity does not increase with the size of the problem
Example: Find ith element in a vector
O(n) Complexity increases linearly with the size of the problem
Example: Find ith element in a linked list
O(log n) Complexity increases with the log of the problem
Example: Binary search
As the problem grows in size, how more difficult
(in terms of computation time/operations)
does the problem become
14. Why different data types?
A specific object implies a data structure
Another criteria:
15. Graph Data Structure
A set of nodes
A set of connections between the nodes
Both nodes and connections can have
properties associated to them
16. Graph Data Structure
A graph can be
a natural representation
for many
data objects and processes
17. Social Network
Node: The person
(facebook page)
Node: connects two people who know each other
(the friends of facebook page)
Each node has a list of connections
(the friends of facebook page)
24. Stacks
Characteristics:
Top: was the last thing added
To get to something in the middle
You have to remove what is on top first
LIFO:
Last In, First Out
25. Last in first out (LIFO)
D
C
B
A
B
A
top
C
B
A
top
D
C
B
A
top E
D
C
B
A
top
topA
Push C Push D Push EPush B Pop E
Two main operations:
Push and Pop
26. The Towers of Hanoi
A Stack-based Application
o GIVEN: three poles
o a set of discs on the first pole, discs of different sizes, the
smallest discs at the top
o GOAL: move all the discs from the left pole to the right
one.
o CONDITIONS: only one disc may be moved at a time.
o A disc can be placed either on an empty pole or on
top of a larger disc.
28. Complexity:
Towers of Hanoi
Complexity:
2n
Why?
To get to the bottom, you have to move all of the top object: 2(n-1)
Then you move the bottom object: 1
Then you have to move all the other objects back on top again: 2(n-1)
2(n-1) + 2(n-1) = 2 * 2(n-1) = 2n
29. A Legend
The Towers of Hanoi
In the great temple of Brahma in Benares,
on a brass plate under the dome that marks the center of the world
there are 64 disks of pure gold that
the priests carry one at a time between these diamond needles
According to Brahma's immutable law:
No disk may be placed on a smaller disk.
In the beginning of the world all 64 disks formed the Tower of Brahma on
one needle.
Now, however, the process of transfer of the tower from one needle to
another is in mid course.
When the last disk is finally in place, once again forming the Tower of
Brahma but on a different needle,
then will come the end of the world and all will turn to dust.
30. Is the End of the World
Approaching?
• Problem complexity 2n
• 64 gold discs
• Given 1 move a second
600,000,000,000 years until the end of the world
31. Queues
FILO: First In and Last Out
Objects are inserted in the back
And
Removed from the front
32. Queues
Computer systems must often provide a
“holding area” for messages
between two processes, two programs, or even two systems.
Real time systems
34. Priority Queue
Like a regular queue or stack datastructure, but where
additionally each element has a "priority" associated with it.
An element with high priority
is served before
an element with low priority.
If two elements have the same priority,
they are served according to their order in the queue.
There is an ordering associated with the
queue
35. Programming Paradigms
• Goto (like assembler and primitive/older languages)
• Iteration and Loops (while and for-next)
• Functional languages and Recursion
• Declarative
• Non-deterministic programming
Example: Factorial
n!º i
i=1
n
Õ n!º
1 n =1
n*(n-1)! n >1
ì
í
ï
îï
ü
ý
ï
þï
Implies a loop
Recursive mathematical definition
36. Goto statement
Loops a GOTO (or similar) statement
The GOTO jumps to a specified location (label or address)
n!º i
i=1
n
Õ
an index involved
The index is incremented until the end is reached i=1
factorial = 1;
loop:
factorial = factorial * I
if( i=n) goto exit
goto loop
exit
37. Iteration
Repetition of a block of code
n!º i
i=1
n
Õ
an index involved
The index is incremented until the end is reached
i=1
factorial = 1;
while( i <= n) {
factorial = factorial * i
i = i + 1
}
Once again involves a iteration counter
factorial = 1;
for i=1 to n {
factorial = factorial * I
}
39. Content of Recursion
• Base case(s).
o Values of the input variables for which we perform no
recursive calls are called base cases (there should be at
least one base case).
o Every possible chain of recursive calls must eventually
reach a base case.
• Recursive calls.
o Calls to the current method.
o Each recursive call should be defined so that it makes
progress towards a base case.
factorial(n) {
if(n=1) return 1
return factorial(n-1)*n
}
n!º
1 n =1
n*(n-1)! n >1
ì
í
ï
îï
ü
ý
ï
þï
40. How do I write a
recursive function?
• Determine the size factor
o The number: smaller number, smaller size
• Determine the base case(s)
o The case for n=1, the answer is 1
• Determine the general case(s)
o The recursive call: factorial(n)=factorial(n-1)*n
• Verify the algorithm
(use the "Three-Question-Method")
factorial(n) {
if(n=1) return 1
return factorial(n-1)*n
}
n!º
1 n =1
n*(n-1)! n >1
ì
í
ï
îï
ü
ý
ï
þï
41. Three-Question Verification Method
1. The Base-Case Question:
Is there a nonrecursive way out of the function,
and does the routine work correctly for this
"base" case?
2. The Smaller-Caller Question:
Does each recursive call to the function involve
a smaller case of the original problem, leading
inescapably to the base case?
3. The General-Case Question:
Assuming that the recursive call(s) work
correctly, does the whole function work
correctly?
42. Stacks
in recursion
factorial(n)
If (n=1)
return 1
else
return factorial(n-1)
n! = n*(n-1)*(n-2)*(n-3)*……* 1
5! = 5*4*3*2*1
Factorial(5)
Factorial(4)
Factorial(3)
Factorial(2)
Factorial(1) return 1
Return 2
Return 6
Return 24
Return 120 5!=120
Deep recursion can result in
running out of memory
43. tail recursion
Tail recursion is iteration
n!º
1 n =1
n*(n-1)! n >1
ì
í
ï
îï
ü
ý
ï
þï
factorial(n) {
factorial-help(n,1);
}
factorial-help(n, acc) {
if(n=1) return acc
return factorial-help(n-1,acc*n)
}
Tail recursion is a pattern of use that can
be compiled or interpreted as iteration,
avoiding the inefficiencies
A tail recursive function is one where every recursive call is the last thing
done by the function before returning and thus produces the function’s value
44. Declarative programming
Expresses the logic of a computation
without describing its control flow.
n!º
1 n =1
n*(n-1)! n >1
ì
í
ï
îï
ü
ý
ï
þï
factorial(1,1) factorial(N,F) :-
N1 is N-1,
factorial(N1,F1),F is N*F1.
45. Constraint Logic
Programming
factorial(1,1) factorial(N,F) :-
N1 is N-1,
factorial(N1,F1),F is N*F1.
Factorial(5,F) Returns F=120
Factorial(N.120) Creates an instantiation error
PROLOG has no knowledge of Real or Integer numbers
Mathematical manipulations cannot be made
46. Constraint Logic
Programming
factorial(1,1) factorial(N,F) :-
N1 is N-1,
factorial(N1,F1),F is N*F1.
Logic Programming
Constraint Logic
Programming
CLP
Formulas passed to
CLP
Reduced or solved
formulas returned
Mathmatical knowledge
about the numbers used
47. Probabilistic Algorithms
Non-deterministic
No exact control program flow
Leaves Some of Its Decisions To Chance
Outcome of the program in different runs is not necessarily the same
Monte Carlo Methods
Always Gives an answer
But not necessarily Correct
The probability of correctness go es up with time
Las Vegas Methods Never returns an incorrect answer
But sometimes it doesn’t give an answer
48. Probabilistic Algorithms
Probabilistic Algorithms in optimization:
Closer to human reasoning and problem solving
(for hard problems we don’t follow strict deterministic algorithms)
Finding
local and global
minimum
49. Probabilistic Algorithms
Classic gradient optimization find local minimum
The search path is always downhill toward minimum
Probabilistic algorithms allow search to go uphill sometimes
Randomness in the search for next step
Genetic Algorithms
Simulated Annealing to find global minimum
50. Probabilistic Algorithms
Calculate pi with a dart board
Area of square
d2
Area of Circle:
P
d
2
æ
è
ç
ö
ø
÷
2
prob =
circle
square
=
p
d
2
æ
è
ç
ö
ø
÷
2
d2
=
p
4
Probability dart will be in circle
d
number darts in circle
divided by
number of darts in
total
times
Is π
Monte Carlo Method
Always Gives an answer
But not necessarily Correct
The probability of correctness goes up with time