SlideShare a Scribd company logo
1 of 11
Algorithm #1

      CHANGE transaction;
one transaction per master record
Assumptions
• Let the sentinel value be equal to 999
• Let there be a function Get_Next_Master defined as
  follows:
       if eof(master)
          master_key = sentinel
          else input next master record
• Let there be a function Get_Next_Trans defined as
  follows:
       if eof(trans)
           trans_key = sentinel
           else input next trans record

                     Prepared by Perla P. Cosme        2
Let’s simulate the SFO using
            Algorithm #1

We shall use the same example as what we
 presented previously.




                 Prepared by Perla P. Cosme   3
The First Algorithm
CHANGE transaction; one transaction per record



  MF 3            6           10             11



    TF 1           3             4           11   17
       C           C             C           C    C


                Prepared by Perla P. Cosme             4
Get_Next_Master
Get_Next_Trans
While NOT (master_key==sentinel AND trans_key==sentinel)
  if (master_key < trans_key)
      { output master record to new master file
          Get_Next_master
       }
       else if (master_key == trans_key)
                { make a change in the master record
                    output master record to new master file
                    Get_Next_Trans
                    Get_Next_Master
                  }
             else
                 { print “no matching record in the master file”
                    Get_Next_Trans
                  }

                             Prepared by Perla P. Cosme            5
Analysis
There are three (3) possible case that we can
  identify when comparing the master key and
  the transaction key:
2.Master key < transaction key
3.Master key = transaction key
4.Master key > transaction key



                  Prepared by Perla P. Cosme    6
There is no transaction

                  Analysis
                                                for the master record,
                                                 hence, it will just be
                                               copied or written to the
                                                   new master file.

There are three (3) possible case that we can
  identify when comparing the master key and
  the transaction key:
2.Master key < transaction key
3.Master key = transaction key
4.Master key > transaction key



                  Prepared by Perla P. Cosme                              7
When master key is equal

                    Analysis
                                                   to transaction key, that
                                                    means that the record
                                                 exists, and hence, we can
                                                  implement the CHANGE
There are three (3) possible cases that we can           transaction.

   identify when comparing the master key and the
   transaction key:
2. Master key < transaction key
3. Master key = transaction key
4. Master key > transaction key

Note: Among the 3 cases above, it is only in case #2
 above where we are allowed to change. Why?

                    Prepared by Perla P. Cosme                                8
When this condition

                  Analysis
                                                holds true, that means
                                                 that the transaction is
                                                  invalid because you
                                               cannot change a record if
                                               the record does not exist
There are three (3) possible case that we can      in the master file.
  identify when comparing the master key and
  the transaction key:
2.Master key < transaction key
3.Master key = transaction key
4.Master key > transaction key



                  Prepared by Perla P. Cosme                               9
Something to Ponder
    If this is the type of transaction that we have as
depicted in Algorithm #1, that means we can only do
one transaction per account per day.
    But this is not a realistic situation – because we
never want to be restricted on having only one
deposit or one withdrawal on your ATM account per
day.
Question:
So, how do we modify the algorithm in order to
resolve the problem?

                   Prepared by Perla P. Cosme        10
Solution:

            Proceed to Algorithm #2




                  Prepared by Perla P. Cosme   11

More Related Content

Similar to Algorithm #1 Explained

Algorithm 2
Algorithm  2Algorithm  2
Algorithm 2gwsy93
 
Algorithm 3
Algorithm  3Algorithm  3
Algorithm 3gwsy93
 
Algorithm 3
Algorithm  3Algorithm  3
Algorithm 3gwsy93
 

Similar to Algorithm #1 Explained (6)

Algorithm 2
Algorithm  2Algorithm  2
Algorithm 2
 
Algorithm 2
Algorithm  2Algorithm  2
Algorithm 2
 
Algorithm 3
Algorithm  3Algorithm  3
Algorithm 3
 
Algorithm 3
Algorithm  3Algorithm  3
Algorithm 3
 
Algorithm 3
Algorithm  3Algorithm  3
Algorithm 3
 
Algorithm 4
Algorithm  4Algorithm  4
Algorithm 4
 

Recently uploaded

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 

Recently uploaded (20)

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 

Algorithm #1 Explained

  • 1. Algorithm #1 CHANGE transaction; one transaction per master record
  • 2. Assumptions • Let the sentinel value be equal to 999 • Let there be a function Get_Next_Master defined as follows: if eof(master) master_key = sentinel else input next master record • Let there be a function Get_Next_Trans defined as follows: if eof(trans) trans_key = sentinel else input next trans record Prepared by Perla P. Cosme 2
  • 3. Let’s simulate the SFO using Algorithm #1 We shall use the same example as what we presented previously. Prepared by Perla P. Cosme 3
  • 4. The First Algorithm CHANGE transaction; one transaction per record MF 3 6 10 11 TF 1 3 4 11 17 C C C C C Prepared by Perla P. Cosme 4
  • 5. Get_Next_Master Get_Next_Trans While NOT (master_key==sentinel AND trans_key==sentinel) if (master_key < trans_key) { output master record to new master file Get_Next_master } else if (master_key == trans_key) { make a change in the master record output master record to new master file Get_Next_Trans Get_Next_Master } else { print “no matching record in the master file” Get_Next_Trans } Prepared by Perla P. Cosme 5
  • 6. Analysis There are three (3) possible case that we can identify when comparing the master key and the transaction key: 2.Master key < transaction key 3.Master key = transaction key 4.Master key > transaction key Prepared by Perla P. Cosme 6
  • 7. There is no transaction Analysis for the master record, hence, it will just be copied or written to the new master file. There are three (3) possible case that we can identify when comparing the master key and the transaction key: 2.Master key < transaction key 3.Master key = transaction key 4.Master key > transaction key Prepared by Perla P. Cosme 7
  • 8. When master key is equal Analysis to transaction key, that means that the record exists, and hence, we can implement the CHANGE There are three (3) possible cases that we can transaction. identify when comparing the master key and the transaction key: 2. Master key < transaction key 3. Master key = transaction key 4. Master key > transaction key Note: Among the 3 cases above, it is only in case #2 above where we are allowed to change. Why? Prepared by Perla P. Cosme 8
  • 9. When this condition Analysis holds true, that means that the transaction is invalid because you cannot change a record if the record does not exist There are three (3) possible case that we can in the master file. identify when comparing the master key and the transaction key: 2.Master key < transaction key 3.Master key = transaction key 4.Master key > transaction key Prepared by Perla P. Cosme 9
  • 10. Something to Ponder If this is the type of transaction that we have as depicted in Algorithm #1, that means we can only do one transaction per account per day. But this is not a realistic situation – because we never want to be restricted on having only one deposit or one withdrawal on your ATM account per day. Question: So, how do we modify the algorithm in order to resolve the problem? Prepared by Perla P. Cosme 10
  • 11. Solution: Proceed to Algorithm #2 Prepared by Perla P. Cosme 11