SlideShare a Scribd company logo
Running Head: ALGEBRA2
Algebra2
Student 1
INITIAL VALUES:
current_position = 0
low_price = 0
high_price = 0
STEP 1:
Set the low_price to the stock price at the current_position.
Set the high_price to the stock price at the current_position.
STEP 2:
Set the current_position to the subsequent position.
STEP 3:
Compare the low_price with the stock price at
the current_position.
STEP 4:
If the low_price is less than the stock at
the current_position then do the following.
Compare the high_price with the stock at the current_position.
If the high_price is less than the stock at the current_position,
set the high_price to the stock at the current_position.
Go to STEP 2.
If the low_price is greater than the stock at
the current_position then do the following.
Set the low_price as the stock at the current_position.
Set the high_price to the stock at the current_position. [since
the high_price must come after the low_price, this will “reset”
the high_price by making it equal to the new low_price.]
Go to STEP 2.
EXAMPLE:
Here is an example of the values that are set through an
iteration of the algorithm.
input = [143, 122, 121, 119, 147, 170, 172, 180, 170, 161]
current_position = 0
low_price = 143
high_price = 143
current_position = 1
low_price = 122
high_price = 122
current_position = 2
low_price = 121
high_price = 121
current_position = 3
low_price = 119
high_price = 119
current_position = 4
low_price = 119
high_price = 147
current_position = 5
low_price = 119
high_price = 170
current_position = 6
low_price = 119
high_price = 172
current_position = 7
low_price = 119
high_price = 180
current_position = 8
low_price = 119
high_price = 180
current_position = 9
low_price = 119
high_price = 180
Student 2
Solution
:
The last 10 days stock market position as given below: -
Day 1- $143, Day 2- $122, Day 3- $121,
Day 4- $119, Day 5- $147, Day 6- $170,
Day 7- $172, Day 8- $180, Day 9- $170, Day 10- $161
Given above Current stock value for last 10 days that is 1 to 10,
let’s take the initial current values for the stocks as mentioned
below by assuming zero to initial:
Current Stock Market Position = 0
High Stock Market Price = $0
Low Stock Market Price = $0
Algorithm
Input dollar values as per numbers of days {$143, $122, $121,
$119, $147, $170, $172, $180, $170, and $161}
1. Let compare the High and Low Stock market price to the
Current market position price as per each day.
Example:
Current Stock Market Position = 0
High Stock Market Price = $0
Low Stock Market Price = $0
2. Let compare the Current Stock market position price to per
day stock price.
Example:
Current Stock Market Position = 1
High Stock Market Price = $122
Low Stock Market Price = $122
3. Let compare the High and Low Stock market price to per
day stock position price.
Example:
Current Stock Market Position = 2
High Stock Market Price = $121
Low Stock Market Price = $121
4. Let check the current stock market position to find the Low
Stock market Price and High Stock market price to buy and sell
with the following steps.
a. If the current Stock market stock position is Low, then
compare it with High Stock market stock price.
b. If the current Stock market stock position is High, then
compare it with Low Stock market stock price.
c. Repeat the above the above two to per current stock market
stock position to set the high and low market stock price.
Example:
Current Stock Market Position = 3
High Stock Market Price = $119
Low Stock Market Price = $119
Current Stock Market Position = 4
High Stock Market Price = $147
Low Stock Market Price = $119
Current Stock Market Position = 5
High Stock Market Price = $170
Low Stock Market Price = $119
5. Hence the stock prices for the per day current market
position keep on undoing the stock prices on a per day basis to
find the actual buying stock and date in Low price before the
selling stock date in High price depend on the current market
stock position as shown in above step 2, 3 and 4 with examples.
Example:
Current Stock Market Position = 6
High Stock Market Price = $172
Low Stock Market Price = $119
Current Stock Market Position = 7
High Stock Market Price = $180
Low Stock Market Price = $119
Current Stock Market Position = 8
High Stock Market Price = $180
Low Stock Market Price = $119
Current Stock Market Position = 9
High Stock Market Price = $180
Low Stock Market Price = $119
6. Therefore, the buying date lowest price is $119 and the
selling Highest stock price after buying date is $180 as shown
in the examples of per day Current Stock Market Position from
1 to 9.

More Related Content

More from MARK547399

After watching the video, Euro Doomed Bloomberg QuickTakes, do some.docx
After watching the video, Euro Doomed Bloomberg QuickTakes, do some.docxAfter watching the video, Euro Doomed Bloomberg QuickTakes, do some.docx
After watching the video, Euro Doomed Bloomberg QuickTakes, do some.docx
MARK547399
 
After watching Adam Driver’s TED talk about his journey from bei.docx
After watching Adam Driver’s TED talk about his journey from bei.docxAfter watching Adam Driver’s TED talk about his journey from bei.docx
After watching Adam Driver’s TED talk about his journey from bei.docx
MARK547399
 
After watching all the films in Week Two’s content (with the excepti.docx
After watching all the films in Week Two’s content (with the excepti.docxAfter watching all the films in Week Two’s content (with the excepti.docx
After watching all the films in Week Two’s content (with the excepti.docx
MARK547399
 
After time traveling through many periods in some of our oldest .docx
After time traveling through many periods in some of our oldest .docxAfter time traveling through many periods in some of our oldest .docx
After time traveling through many periods in some of our oldest .docx
MARK547399
 
After studying the course materials located on Module 1., answer.docx
After studying the course materials located on Module 1., answer.docxAfter studying the course materials located on Module 1., answer.docx
After studying the course materials located on Module 1., answer.docx
MARK547399
 
After reviewing your latest submission, the CIO has found some a.docx
After reviewing your latest submission, the CIO has found some a.docxAfter reviewing your latest submission, the CIO has found some a.docx
After reviewing your latest submission, the CIO has found some a.docx
MARK547399
 
After reviewing Zinns and Schweikarts personal assumptions, belief.docx
After reviewing Zinns and Schweikarts personal assumptions, belief.docxAfter reviewing Zinns and Schweikarts personal assumptions, belief.docx
After reviewing Zinns and Schweikarts personal assumptions, belief.docx
MARK547399
 
After reviewing the resources provided, do you believe that we posse.docx
After reviewing the resources provided, do you believe that we posse.docxAfter reviewing the resources provided, do you believe that we posse.docx
After reviewing the resources provided, do you believe that we posse.docx
MARK547399
 
After reading The Successful Organization Keeping the Talent .docx
After reading The Successful Organization Keeping the Talent .docxAfter reading The Successful Organization Keeping the Talent .docx
After reading The Successful Organization Keeping the Talent .docx
MARK547399
 
After reviewing the policy brief by the Urban Institute on the pros .docx
After reviewing the policy brief by the Urban Institute on the pros .docxAfter reviewing the policy brief by the Urban Institute on the pros .docx
After reviewing the policy brief by the Urban Institute on the pros .docx
MARK547399
 
After reflecting on this week’s overview and textbook reading, discu.docx
After reflecting on this week’s overview and textbook reading, discu.docxAfter reflecting on this week’s overview and textbook reading, discu.docx
After reflecting on this week’s overview and textbook reading, discu.docx
MARK547399
 
After reading this weeks resources including Ready or Not Protecti.docx
After reading this weeks resources including Ready or Not Protecti.docxAfter reading this weeks resources including Ready or Not Protecti.docx
After reading this weeks resources including Ready or Not Protecti.docx
MARK547399
 
After reading this article, create an initial discussion post re.docx
After reading this article, create an initial discussion post re.docxAfter reading this article, create an initial discussion post re.docx
After reading this article, create an initial discussion post re.docx
MARK547399
 
After reading the play Los Vendidos by Luis Valdez and then watchi.docx
After reading the play Los Vendidos by Luis Valdez and then watchi.docxAfter reading the play Los Vendidos by Luis Valdez and then watchi.docx
After reading the play Los Vendidos by Luis Valdez and then watchi.docx
MARK547399
 
After reading the material from Shafer-Landau concerning the appeal .docx
After reading the material from Shafer-Landau concerning the appeal .docxAfter reading the material from Shafer-Landau concerning the appeal .docx
After reading the material from Shafer-Landau concerning the appeal .docx
MARK547399
 
After reading The Magic Key The Educational Journey of Mexican Amer.docx
After reading The Magic Key The Educational Journey of Mexican Amer.docxAfter reading The Magic Key The Educational Journey of Mexican Amer.docx
After reading The Magic Key The Educational Journey of Mexican Amer.docx
MARK547399
 
After reading the chapters attached, write one and a half pages (1.5.docx
After reading the chapters attached, write one and a half pages (1.5.docxAfter reading the chapters attached, write one and a half pages (1.5.docx
After reading the chapters attached, write one and a half pages (1.5.docx
MARK547399
 
after reading the lecture, I have to create your own manifesto that .docx
after reading the lecture, I have to create your own manifesto that .docxafter reading the lecture, I have to create your own manifesto that .docx
after reading the lecture, I have to create your own manifesto that .docx
MARK547399
 
After reading the information on stockholders equity in Chapter.docx
After reading the information on stockholders equity in Chapter.docxAfter reading the information on stockholders equity in Chapter.docx
After reading the information on stockholders equity in Chapter.docx
MARK547399
 
After reading the first chapter in our textbook, use the followi.docx
After reading the first chapter in our textbook, use the followi.docxAfter reading the first chapter in our textbook, use the followi.docx
After reading the first chapter in our textbook, use the followi.docx
MARK547399
 

More from MARK547399 (20)

After watching the video, Euro Doomed Bloomberg QuickTakes, do some.docx
After watching the video, Euro Doomed Bloomberg QuickTakes, do some.docxAfter watching the video, Euro Doomed Bloomberg QuickTakes, do some.docx
After watching the video, Euro Doomed Bloomberg QuickTakes, do some.docx
 
After watching Adam Driver’s TED talk about his journey from bei.docx
After watching Adam Driver’s TED talk about his journey from bei.docxAfter watching Adam Driver’s TED talk about his journey from bei.docx
After watching Adam Driver’s TED talk about his journey from bei.docx
 
After watching all the films in Week Two’s content (with the excepti.docx
After watching all the films in Week Two’s content (with the excepti.docxAfter watching all the films in Week Two’s content (with the excepti.docx
After watching all the films in Week Two’s content (with the excepti.docx
 
After time traveling through many periods in some of our oldest .docx
After time traveling through many periods in some of our oldest .docxAfter time traveling through many periods in some of our oldest .docx
After time traveling through many periods in some of our oldest .docx
 
After studying the course materials located on Module 1., answer.docx
After studying the course materials located on Module 1., answer.docxAfter studying the course materials located on Module 1., answer.docx
After studying the course materials located on Module 1., answer.docx
 
After reviewing your latest submission, the CIO has found some a.docx
After reviewing your latest submission, the CIO has found some a.docxAfter reviewing your latest submission, the CIO has found some a.docx
After reviewing your latest submission, the CIO has found some a.docx
 
After reviewing Zinns and Schweikarts personal assumptions, belief.docx
After reviewing Zinns and Schweikarts personal assumptions, belief.docxAfter reviewing Zinns and Schweikarts personal assumptions, belief.docx
After reviewing Zinns and Schweikarts personal assumptions, belief.docx
 
After reviewing the resources provided, do you believe that we posse.docx
After reviewing the resources provided, do you believe that we posse.docxAfter reviewing the resources provided, do you believe that we posse.docx
After reviewing the resources provided, do you believe that we posse.docx
 
After reading The Successful Organization Keeping the Talent .docx
After reading The Successful Organization Keeping the Talent .docxAfter reading The Successful Organization Keeping the Talent .docx
After reading The Successful Organization Keeping the Talent .docx
 
After reviewing the policy brief by the Urban Institute on the pros .docx
After reviewing the policy brief by the Urban Institute on the pros .docxAfter reviewing the policy brief by the Urban Institute on the pros .docx
After reviewing the policy brief by the Urban Institute on the pros .docx
 
After reflecting on this week’s overview and textbook reading, discu.docx
After reflecting on this week’s overview and textbook reading, discu.docxAfter reflecting on this week’s overview and textbook reading, discu.docx
After reflecting on this week’s overview and textbook reading, discu.docx
 
After reading this weeks resources including Ready or Not Protecti.docx
After reading this weeks resources including Ready or Not Protecti.docxAfter reading this weeks resources including Ready or Not Protecti.docx
After reading this weeks resources including Ready or Not Protecti.docx
 
After reading this article, create an initial discussion post re.docx
After reading this article, create an initial discussion post re.docxAfter reading this article, create an initial discussion post re.docx
After reading this article, create an initial discussion post re.docx
 
After reading the play Los Vendidos by Luis Valdez and then watchi.docx
After reading the play Los Vendidos by Luis Valdez and then watchi.docxAfter reading the play Los Vendidos by Luis Valdez and then watchi.docx
After reading the play Los Vendidos by Luis Valdez and then watchi.docx
 
After reading the material from Shafer-Landau concerning the appeal .docx
After reading the material from Shafer-Landau concerning the appeal .docxAfter reading the material from Shafer-Landau concerning the appeal .docx
After reading the material from Shafer-Landau concerning the appeal .docx
 
After reading The Magic Key The Educational Journey of Mexican Amer.docx
After reading The Magic Key The Educational Journey of Mexican Amer.docxAfter reading The Magic Key The Educational Journey of Mexican Amer.docx
After reading The Magic Key The Educational Journey of Mexican Amer.docx
 
After reading the chapters attached, write one and a half pages (1.5.docx
After reading the chapters attached, write one and a half pages (1.5.docxAfter reading the chapters attached, write one and a half pages (1.5.docx
After reading the chapters attached, write one and a half pages (1.5.docx
 
after reading the lecture, I have to create your own manifesto that .docx
after reading the lecture, I have to create your own manifesto that .docxafter reading the lecture, I have to create your own manifesto that .docx
after reading the lecture, I have to create your own manifesto that .docx
 
After reading the information on stockholders equity in Chapter.docx
After reading the information on stockholders equity in Chapter.docxAfter reading the information on stockholders equity in Chapter.docx
After reading the information on stockholders equity in Chapter.docx
 
After reading the first chapter in our textbook, use the followi.docx
After reading the first chapter in our textbook, use the followi.docxAfter reading the first chapter in our textbook, use the followi.docx
After reading the first chapter in our textbook, use the followi.docx
 

Recently uploaded

Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 

Recently uploaded (20)

Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 

Running head algebra2 algebra2student 1 initial values

  • 1. Running Head: ALGEBRA2 Algebra2 Student 1 INITIAL VALUES: current_position = 0 low_price = 0 high_price = 0 STEP 1: Set the low_price to the stock price at the current_position. Set the high_price to the stock price at the current_position. STEP 2: Set the current_position to the subsequent position. STEP 3: Compare the low_price with the stock price at the current_position. STEP 4: If the low_price is less than the stock at the current_position then do the following. Compare the high_price with the stock at the current_position. If the high_price is less than the stock at the current_position, set the high_price to the stock at the current_position. Go to STEP 2. If the low_price is greater than the stock at the current_position then do the following. Set the low_price as the stock at the current_position. Set the high_price to the stock at the current_position. [since the high_price must come after the low_price, this will “reset” the high_price by making it equal to the new low_price.] Go to STEP 2. EXAMPLE: Here is an example of the values that are set through an iteration of the algorithm. input = [143, 122, 121, 119, 147, 170, 172, 180, 170, 161]
  • 2. current_position = 0 low_price = 143 high_price = 143 current_position = 1 low_price = 122 high_price = 122 current_position = 2 low_price = 121 high_price = 121 current_position = 3 low_price = 119 high_price = 119 current_position = 4 low_price = 119 high_price = 147 current_position = 5 low_price = 119 high_price = 170 current_position = 6 low_price = 119 high_price = 172 current_position = 7 low_price = 119 high_price = 180 current_position = 8 low_price = 119 high_price = 180 current_position = 9 low_price = 119 high_price = 180
  • 3. Student 2 Solution : The last 10 days stock market position as given below: - Day 1- $143, Day 2- $122, Day 3- $121, Day 4- $119, Day 5- $147, Day 6- $170, Day 7- $172, Day 8- $180, Day 9- $170, Day 10- $161 Given above Current stock value for last 10 days that is 1 to 10, let’s take the initial current values for the stocks as mentioned below by assuming zero to initial: Current Stock Market Position = 0 High Stock Market Price = $0 Low Stock Market Price = $0 Algorithm Input dollar values as per numbers of days {$143, $122, $121, $119, $147, $170, $172, $180, $170, and $161} 1. Let compare the High and Low Stock market price to the Current market position price as per each day. Example: Current Stock Market Position = 0 High Stock Market Price = $0
  • 4. Low Stock Market Price = $0 2. Let compare the Current Stock market position price to per day stock price. Example: Current Stock Market Position = 1 High Stock Market Price = $122 Low Stock Market Price = $122 3. Let compare the High and Low Stock market price to per day stock position price. Example: Current Stock Market Position = 2 High Stock Market Price = $121 Low Stock Market Price = $121 4. Let check the current stock market position to find the Low Stock market Price and High Stock market price to buy and sell with the following steps. a. If the current Stock market stock position is Low, then compare it with High Stock market stock price. b. If the current Stock market stock position is High, then compare it with Low Stock market stock price. c. Repeat the above the above two to per current stock market stock position to set the high and low market stock price. Example: Current Stock Market Position = 3 High Stock Market Price = $119
  • 5. Low Stock Market Price = $119 Current Stock Market Position = 4 High Stock Market Price = $147 Low Stock Market Price = $119 Current Stock Market Position = 5 High Stock Market Price = $170 Low Stock Market Price = $119 5. Hence the stock prices for the per day current market position keep on undoing the stock prices on a per day basis to find the actual buying stock and date in Low price before the selling stock date in High price depend on the current market stock position as shown in above step 2, 3 and 4 with examples. Example: Current Stock Market Position = 6 High Stock Market Price = $172 Low Stock Market Price = $119 Current Stock Market Position = 7 High Stock Market Price = $180 Low Stock Market Price = $119 Current Stock Market Position = 8 High Stock Market Price = $180 Low Stock Market Price = $119 Current Stock Market Position = 9 High Stock Market Price = $180 Low Stock Market Price = $119
  • 6. 6. Therefore, the buying date lowest price is $119 and the selling Highest stock price after buying date is $180 as shown in the examples of per day Current Stock Market Position from 1 to 9.