SlideShare a Scribd company logo
14
Most read
15
Most read
16
Most read
Online Algorithms
And their Applications
Definition
• In computer science, an online algorithm is one that can process its
input piece-by-piece in a serial fashion, i.e., in the order that the input
is fed to the algorithm, without having the entire input available from
the start.
• Online algorithms may produce the results that are not optimal as it
doesn’t have the complete input.
Offline Algorithms
• An offline algorithm is one which is given the whole problem data
from the beginning and is required to output an answer which solves
the problem at hand.
• Offline algorithms produce the optimal solution as it is given the
complete input.
Competitive Analysis
• Competitive analysis is a method of analyzing online algorithms, in
which the performance of an online algorithm is compared to the
performance of an optimal offline algorithm.
• The competitive ratio of an algorithm, is defined as the worst-case
ratio of its cost divided by the optimal cost, over all possible inputs.
• The competitive ratio of an online problem is the best competitive
ratio achieved by an online algorithm.
Secretary Problem
• The secretary problem is one of many names for a famous problem of the
optimal stopping theory. The problem has been studied extensively in the fields
of applied probability, statistics, and decision theory. It is also known as the
marriage problem, the sultan's dowry problem, the best choice problem, etc.
Formulation:
• Although there are many variations, the basic problem can be stated as
follows:
• There is a single secretarial position to fill.
• There are n applicants for the position, and the value of n is known.
• The applicants, if seen altogether, can be ranked from best to worst
unambiguously.
Secretary Problem
• The applicants are interviewed sequentially in random order, with each order
being equally likely.
• Immediately after an interview, the interviewed applicant is either accepted or
rejected, and the decision is irrevocable.
• The decision to accept or reject an applicant can be based only on the relative
ranks of the applicants interviewed so far.
• The objective of the general solution is to have the highest probability of
selecting the best applicant of the whole group. This is the same as maximizing
the expected payoff, with payoff defined to be one for the best applicant and zero
otherwise.
Terminology: A candidate is defined as an applicant who, when interviewed, is better than all
the applicants interviewed previously. Skip is used to mean "reject immediately after the
interview".
Secretary Problem
Strategy to solve:
One strategy could be-
Always pick the ith candidate from some predetermined i ϵ [1,N]
P(Success) = 1/N
We can do much better than 1/N by applying the following rule, which yields the
optimal solution:
Interview and reject the first r applicants, for r < N. Accept the very next applicant
that is better than all the first r you interviewed.
P(Success) =P(r)
We will now show that the optimal solution is found by optimizing P(r) by the
standard route of solving:
P’(r) = 0
Secretary Problem
• Solution:
The following diagram will be helpful to visualize the problem:
Let R be the last applicant you will see before you actually start considering
hiring anyone (the last one you're going to reject no matter what). Let the
best applicant of all N, i* occur arbitrarily at n + 1, and N is the total number
of applicants you have the potential to interview. We then can say that i* will
not be chosen unless both of the following conditions are met:
Secretary Problem
1. n ≥ r
2. The highest applicant in [1, n] is the same highest applicant in [1, r]
The probability of this happening for some given n is
This basically stems from the fact that the probability of i* occuring at
n+1 is 1/N and the probability of condition (2) is r/n . We can obtain
P(r) by summing over all possible n ≥ r :
Secretary Problem
By inspecting the expression in the limit as N → ∞, letting
and , we find the following:
So in the limit as N grows in infinitely large, we find that the ratio of
applicants reviewed and rejected to the number of total applicants
approaches x. We see then that solving P’( r ) = 0 for r gives us the
optimal ratio and the probability of success P(roptimal).
Secretary Problem
The ratio of r to N is optimal at 1/e yielding a probability of success of,
coincidentally, 1/e as well. So for N >> 1 the roptimal is nearly N/e,
otherwise it can be found by computing P(r) directly.
Secretary Problem
All Together Now
• The secretary problem is the problem of deciding whether or not one should stick with
what they have or take their chances on something new.
• Examples of secretary problems include finding a husband or wife, hiring a secretary, and
alligator hunting.
• The solution to the secretary problem suggests that the optimal dating strategy is to
estimate the maximum number of people you’re willing to date, (N), and then date
(sqrt{N}) people and marry the next person who is better than all of those.
• In laboratory experiments, people often stop searching too soon when solving secretary
problems. This suggests that the average person doesn’t date enough people prior to
marriage.
• At the end of the day, the secretary problem is a mathematical abstraction and there is
more to finding the “right” person than dating a certain number of people.
Applications: Stock Market
Stock Market
• The market in which shares of publicly held companies are issued and
traded either through exchanges or over-the-counter markets. Also
known as the equity market, the stock market is one of the most vital
components of a free-market economy, as it provides companies with
access to capital in exchange for giving investors a slice of ownership
in the company.
• The stock market makes it possible to grow small initial sums of
money into large ones, and to become wealthy without taking the risk
of starting a business or making the sacrifices that often accompany a
high-paying career.
Stock Market
• Today, most stock market trades are executed electronically, and even
the stocks themselves are almost always held in electronic form, not
as physical certificates.
Stock Market Prediction
• Stock market prediction is the act of trying to determine the future
value of a company stock or other financial instrument traded on an
exchange. The successful prediction of a stock's future price could
yield significant profit. The efficient-market hypothesis suggests that
stock price movements are governed by the random walk hypothesis
and thus are inherently unpredictable. Others disagree and those
with this viewpoint possess myriad methods and technologies which
purportedly allow them to gain future price information.
• Some believe that the prediction of share price is pure speculation
but some believe that there is some mathematics involved.
Use of Algorithm in Stock Prediction
• Online algorithms play an important role in stock prediction.
• We can develop algorithms which can predict future price of stocks to
some extent with some probability of error in prediction.
• Believing that history repeats itself, a potential algorithm for stock
prediction could be developed which gives the output based on the
previous data of stock prices available and generate results.
Use of Algorithm in Stock Prediction
• Is there any algorithm available which could predict the stock price
with 100% accuracy??
Portfolio Management
• The term portfolio refers to any collection of financial assets such as
cash, shares. Portfolios may be held by individual investors and/or
managed by financial professionals, hedge funds, banks and other
financial institutions.
• Portfolio Management is the art and science of making decisions
about investment mix and policy, matching investments to objectives,
asset allocation for individuals and institutions, and balancing risk
against performance.
Vikas Jindal
B.Tech., CSE
IIT Patna
vikasjindal.iitp@gmail.com
Thank You!

More Related Content

PPTX
Recurrent Neural Networks (RNNs)
PPTX
Classification Algorithm.
PPT
Heuristic Search Techniques Unit -II.ppt
ODP
Machine Learning with Decision trees
PPTX
Multilayer perceptron
PDF
Autoencoders
PPT
Propositional And First-Order Logic
PPT
key distribution in network security
Recurrent Neural Networks (RNNs)
Classification Algorithm.
Heuristic Search Techniques Unit -II.ppt
Machine Learning with Decision trees
Multilayer perceptron
Autoencoders
Propositional And First-Order Logic
key distribution in network security

What's hot (20)

PPTX
MPI message passing interface
PPTX
Naive Bayes Presentation
PPTX
Multiprocessor system
PPTX
Product Cipher
PPTX
Hyperparameter Tuning
PDF
Dimensionality Reduction
PDF
Introduction to Algorithms Complexity Analysis
PPT
K mean-clustering
PPTX
Single source Shortest path algorithm with example
PPTX
NLP_KASHK:Markov Models
PPTX
Cache coherence ppt
PPT
Deadlock in operating systems
PPTX
Semantic nets in artificial intelligence
PPTX
Data Mining: clustering and analysis
PPTX
Applications of paralleL processing
DOC
Chapter 4 (final)
PPTX
Shuffle exchange networks
PDF
Decision trees in Machine Learning
PPTX
Introduction to Prolog
PPT
2.4 rule based classification
MPI message passing interface
Naive Bayes Presentation
Multiprocessor system
Product Cipher
Hyperparameter Tuning
Dimensionality Reduction
Introduction to Algorithms Complexity Analysis
K mean-clustering
Single source Shortest path algorithm with example
NLP_KASHK:Markov Models
Cache coherence ppt
Deadlock in operating systems
Semantic nets in artificial intelligence
Data Mining: clustering and analysis
Applications of paralleL processing
Chapter 4 (final)
Shuffle exchange networks
Decision trees in Machine Learning
Introduction to Prolog
2.4 rule based classification
Ad

Viewers also liked (19)

PDF
5 + 1 ingrediente pentru o prezentare de succes
PPTX
All_Care's_PowerPoint_Presentation (1)
PDF
Blended learning
PDF
David J. Alder Resume
PDF
Libro el caballero de la armada oxidada
PPTX
Online Algorithms - An Introduction
PDF
Indiabankingsectorreportaugust2013 140201021707-phpapp01
DOC
0601044 icici prudential life insurance
DOC
0601021 equity research
PDF
0601054 commodity market
PDF
Study of market potential for enterprise messaging solution
DOC
0601080 ales promotion activities in patna urban market
DOCX
Software requirements specification of Library Management System
PDF
Leading Jordanian Company Integrated Technology Group showcases its innovativ...
PPTX
Sprains
DOCX
Tugas 2
PDF
OTDK_Kémiai reakciók Raman-jel alapú szabályozásának fejlesztése
PDF
CV via pic
PPTX
CIA 4 COMS 1010
5 + 1 ingrediente pentru o prezentare de succes
All_Care's_PowerPoint_Presentation (1)
Blended learning
David J. Alder Resume
Libro el caballero de la armada oxidada
Online Algorithms - An Introduction
Indiabankingsectorreportaugust2013 140201021707-phpapp01
0601044 icici prudential life insurance
0601021 equity research
0601054 commodity market
Study of market potential for enterprise messaging solution
0601080 ales promotion activities in patna urban market
Software requirements specification of Library Management System
Leading Jordanian Company Integrated Technology Group showcases its innovativ...
Sprains
Tugas 2
OTDK_Kémiai reakciók Raman-jel alapú szabályozásának fejlesztése
CV via pic
CIA 4 COMS 1010
Ad

Similar to Online algorithms and their applications (20)

PDF
The Hiring Problem
DOCX
Secretary Problem
PPTX
Indicator Random Variables
PDF
ENTROPY-COST RATIO MAXIMIZATION MODEL FOR EFFICIENT STOCK PORTFOLIO SELECTION...
PDF
D05511625
PDF
Bt0080 fundamentals of algorithms1
PDF
Stopping Rule for Secretory Problem - Presentation by Haoyang Tian, Wesam Als...
PDF
Operations research
PPTX
Operational research ppt
PPT
Dessler ch5
PDF
A Labour Market Model With Multiple Criteria
PDF
Operations Research-2nd edition
DOCX
Human Resources.docx
PDF
Operations research by p. rama murthy
PDF
Quantitative Methods for Business ( PDFDrive ).pdf
PDF
25893434.pdf
PPT
1-introduction.ppt
PPT
1-introductionOPERARION RESEARCH TECHNIQUES.ppt
DOCX
Mathematical blog #2
The Hiring Problem
Secretary Problem
Indicator Random Variables
ENTROPY-COST RATIO MAXIMIZATION MODEL FOR EFFICIENT STOCK PORTFOLIO SELECTION...
D05511625
Bt0080 fundamentals of algorithms1
Stopping Rule for Secretory Problem - Presentation by Haoyang Tian, Wesam Als...
Operations research
Operational research ppt
Dessler ch5
A Labour Market Model With Multiple Criteria
Operations Research-2nd edition
Human Resources.docx
Operations research by p. rama murthy
Quantitative Methods for Business ( PDFDrive ).pdf
25893434.pdf
1-introduction.ppt
1-introductionOPERARION RESEARCH TECHNIQUES.ppt
Mathematical blog #2

Recently uploaded (20)

DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Cloud computing and distributed systems.
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Electronic commerce courselecture one. Pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Machine learning based COVID-19 study performance prediction
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
KodekX | Application Modernization Development
PDF
Encapsulation theory and applications.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Unlocking AI with Model Context Protocol (MCP)
The AUB Centre for AI in Media Proposal.docx
Cloud computing and distributed systems.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Electronic commerce courselecture one. Pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Review of recent advances in non-invasive hemoglobin estimation
Machine learning based COVID-19 study performance prediction
NewMind AI Weekly Chronicles - August'25 Week I
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
The Rise and Fall of 3GPP – Time for a Sabbatical?
KodekX | Application Modernization Development
Encapsulation theory and applications.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Network Security Unit 5.pdf for BCA BBA.
Unlocking AI with Model Context Protocol (MCP)

Online algorithms and their applications

  • 2. Definition • In computer science, an online algorithm is one that can process its input piece-by-piece in a serial fashion, i.e., in the order that the input is fed to the algorithm, without having the entire input available from the start. • Online algorithms may produce the results that are not optimal as it doesn’t have the complete input.
  • 3. Offline Algorithms • An offline algorithm is one which is given the whole problem data from the beginning and is required to output an answer which solves the problem at hand. • Offline algorithms produce the optimal solution as it is given the complete input.
  • 4. Competitive Analysis • Competitive analysis is a method of analyzing online algorithms, in which the performance of an online algorithm is compared to the performance of an optimal offline algorithm. • The competitive ratio of an algorithm, is defined as the worst-case ratio of its cost divided by the optimal cost, over all possible inputs. • The competitive ratio of an online problem is the best competitive ratio achieved by an online algorithm.
  • 5. Secretary Problem • The secretary problem is one of many names for a famous problem of the optimal stopping theory. The problem has been studied extensively in the fields of applied probability, statistics, and decision theory. It is also known as the marriage problem, the sultan's dowry problem, the best choice problem, etc. Formulation: • Although there are many variations, the basic problem can be stated as follows: • There is a single secretarial position to fill. • There are n applicants for the position, and the value of n is known. • The applicants, if seen altogether, can be ranked from best to worst unambiguously.
  • 6. Secretary Problem • The applicants are interviewed sequentially in random order, with each order being equally likely. • Immediately after an interview, the interviewed applicant is either accepted or rejected, and the decision is irrevocable. • The decision to accept or reject an applicant can be based only on the relative ranks of the applicants interviewed so far. • The objective of the general solution is to have the highest probability of selecting the best applicant of the whole group. This is the same as maximizing the expected payoff, with payoff defined to be one for the best applicant and zero otherwise. Terminology: A candidate is defined as an applicant who, when interviewed, is better than all the applicants interviewed previously. Skip is used to mean "reject immediately after the interview".
  • 7. Secretary Problem Strategy to solve: One strategy could be- Always pick the ith candidate from some predetermined i ϵ [1,N] P(Success) = 1/N We can do much better than 1/N by applying the following rule, which yields the optimal solution: Interview and reject the first r applicants, for r < N. Accept the very next applicant that is better than all the first r you interviewed. P(Success) =P(r) We will now show that the optimal solution is found by optimizing P(r) by the standard route of solving: P’(r) = 0
  • 8. Secretary Problem • Solution: The following diagram will be helpful to visualize the problem: Let R be the last applicant you will see before you actually start considering hiring anyone (the last one you're going to reject no matter what). Let the best applicant of all N, i* occur arbitrarily at n + 1, and N is the total number of applicants you have the potential to interview. We then can say that i* will not be chosen unless both of the following conditions are met:
  • 9. Secretary Problem 1. n ≥ r 2. The highest applicant in [1, n] is the same highest applicant in [1, r] The probability of this happening for some given n is This basically stems from the fact that the probability of i* occuring at n+1 is 1/N and the probability of condition (2) is r/n . We can obtain P(r) by summing over all possible n ≥ r :
  • 10. Secretary Problem By inspecting the expression in the limit as N → ∞, letting and , we find the following: So in the limit as N grows in infinitely large, we find that the ratio of applicants reviewed and rejected to the number of total applicants approaches x. We see then that solving P’( r ) = 0 for r gives us the optimal ratio and the probability of success P(roptimal).
  • 11. Secretary Problem The ratio of r to N is optimal at 1/e yielding a probability of success of, coincidentally, 1/e as well. So for N >> 1 the roptimal is nearly N/e, otherwise it can be found by computing P(r) directly.
  • 12. Secretary Problem All Together Now • The secretary problem is the problem of deciding whether or not one should stick with what they have or take their chances on something new. • Examples of secretary problems include finding a husband or wife, hiring a secretary, and alligator hunting. • The solution to the secretary problem suggests that the optimal dating strategy is to estimate the maximum number of people you’re willing to date, (N), and then date (sqrt{N}) people and marry the next person who is better than all of those. • In laboratory experiments, people often stop searching too soon when solving secretary problems. This suggests that the average person doesn’t date enough people prior to marriage. • At the end of the day, the secretary problem is a mathematical abstraction and there is more to finding the “right” person than dating a certain number of people.
  • 14. Stock Market • The market in which shares of publicly held companies are issued and traded either through exchanges or over-the-counter markets. Also known as the equity market, the stock market is one of the most vital components of a free-market economy, as it provides companies with access to capital in exchange for giving investors a slice of ownership in the company. • The stock market makes it possible to grow small initial sums of money into large ones, and to become wealthy without taking the risk of starting a business or making the sacrifices that often accompany a high-paying career.
  • 15. Stock Market • Today, most stock market trades are executed electronically, and even the stocks themselves are almost always held in electronic form, not as physical certificates.
  • 16. Stock Market Prediction • Stock market prediction is the act of trying to determine the future value of a company stock or other financial instrument traded on an exchange. The successful prediction of a stock's future price could yield significant profit. The efficient-market hypothesis suggests that stock price movements are governed by the random walk hypothesis and thus are inherently unpredictable. Others disagree and those with this viewpoint possess myriad methods and technologies which purportedly allow them to gain future price information. • Some believe that the prediction of share price is pure speculation but some believe that there is some mathematics involved.
  • 17. Use of Algorithm in Stock Prediction • Online algorithms play an important role in stock prediction. • We can develop algorithms which can predict future price of stocks to some extent with some probability of error in prediction. • Believing that history repeats itself, a potential algorithm for stock prediction could be developed which gives the output based on the previous data of stock prices available and generate results.
  • 18. Use of Algorithm in Stock Prediction • Is there any algorithm available which could predict the stock price with 100% accuracy??
  • 19. Portfolio Management • The term portfolio refers to any collection of financial assets such as cash, shares. Portfolios may be held by individual investors and/or managed by financial professionals, hedge funds, banks and other financial institutions. • Portfolio Management is the art and science of making decisions about investment mix and policy, matching investments to objectives, asset allocation for individuals and institutions, and balancing risk against performance.
  • 20. Vikas Jindal B.Tech., CSE IIT Patna vikasjindal.iitp@gmail.com Thank You!