SlideShare uma empresa Scribd logo
1 de 17
Baixar para ler offline
Data Structures and Algorithms




      Processing
      Arrays

Arrays
   @     Often advantageous for a user to store several
         values for the same variable in the internal
         memory of the computer because it decreases
         processing time.
   @     This multiple storage means there has to be
         more than one memory location in the
         computer for each variable name.
   @     When more than one memory location is
         designated for a single variable, it is called
         an array.

Static Arrays
   @     This means that once the computer is told
         how many locations to save, that number
         cannot be changed unless the instruction is
         changed.
Processing Arrays                                      *Property of STI
                                                          Page 1 of 17
Data Structures and Algorithms




        Processing
        Arrays

Dynamic Arrays
 @     When using dynamic arrays, the programmer
       designates the number of array locations as a
       variable, which can be expanded or contracted
       during the execution of the solution.

Base-Zero System
 @     Because computers are zero-based, for
       counting purposes, many programming
       languages are also zero-based.
 @     This means that the first array element is
       numbered zero and not one.

Base-One System
 @     Base one is easier for the programmer to
       understand since the first element will have
       an index of 1.
Processing Arrays                                    *Property of STI
                                                        Page 2 of 17
Data Structures and Algorithms




        Processing
        Arrays

Base-Zero Versus Base-One Arrays




Processing Arrays                                 *Property of STI
                                                     Page 3 of 17
Data Structures and Algorithms




        Processing
        Arrays


One-Dimensional Arrays




Processing Arrays                       *Property of STI
                                           Page 4 of 17
Data Structures and Algorithms




        Processing
        Arrays


Parallel Arrays




Processing Arrays                   *Property of STI
                                       Page 5 of 17
Data Structures and Algorithms




        Processing
        Arrays

Entering Data into an Array

               Algorithm            Flowchart

                                            A




       LOOP:R = 1 TO N STEP 1
                                            R
                                      1           N
          ENTER A(R)
                                            1

       LOOP-END:R

                                          ENTER
                                           A(R)




        R = Counter
                                            R
        N = Number of elements in
               the array

        A(R) = Element R                    B
               in the A array

Processing Arrays                                              *Property of STI
                                                                  Page 6 of 17
Data Structures and Algorithms




        Processing
        Arrays
                    Algorithm         Flowchart
                                                 A




                                                R=0
         1. R = 0
         2. REPEAT                                   REPEAT



                     R = R+1                  R=R+1

                     ENTER A(R)

                    UNTIL A(R) = -1           ENTER
                                               A(R)


         *3. N = R-1
                                      F        UNTIL
                                              A(R) = -1



                                                      T

                                          *
                                              N=R-1




                                                 B

Processing Arrays                                                *Property of STI
                                                                    Page 7 of 17
Data Structures and Algorithms




        Processing
        Arrays
                    Algorithm     Flowchart
                                            A




           1. R = 1                       R=1

           2. ENTER A(R)
           3. WHILE A(R) <> -1
                                         ENTER
                                          A(R)
                     R = R+1
                     ENTER A(R)
                                         WHILE       F
                                        A(R) <> -1
                    WHILE - END

           *4. N = R-1
                                        R=R+1




                                         ENTER
                                          A(R)




                                    *
                                        N=R+1




                                            B




Processing Arrays                                         *Property of STI
                                                             Page 8 of 17
Data Structures and Algorithms




        Processing
        Arrays

Printing an Array
                    Algorithm   Flowchart


                                      A

     LOOP: R=1 TO N STEP 1
       PRINT A(R)                     R
                                 1           N
                                       1
     LOOP-END: R


                                     PRINT
     R = Element number               A(R)


     N = Total number
          of elements
                                      R

     A(R) = Rth element of
           the A array
                                      B




Processing Arrays                                *Property of STI
                                                    Page 9 of 17
Data Structures and Algorithms




        Processing
        Arrays

Accumulating the Elements of an Array
                    Algorithm                  Flowchart
                                                       A
         LOOP:R = 1 TO N STEP 1
           SUM = SUM + A(R)
                                                       R
                                                 1          N
         LOOP-END: R                                   1




         N = Number of elements                  SUM = SUM
                                                   + A(R)
         R = Element number
         SUM = Sum of the                              R
               elements of A
         A(R) = Rth element of the
                array                                  B


               TEST:                    R       SUM
                         A
                     1   2            1 2 3     2 6 12
                                     4 5 6 7   20 30 42
                     2   4
                     3   6
                     4   8              N
                     5   10
                                        6
                     6   12



Processing Arrays                                                   *Property of STI
                                                                      Page 10 of 17
Data Structures and Algorithms




        Processing
        Arrays

Two-Dimensional Arrays
  @ A two-dimensional array is a block of memory
       locations associated with a single memory variable
       name and designated by row and column numbers.




Processing Arrays                                       *Property of STI
                                                          Page 11 of 17
Data Structures and Algorithms




        Processing
        Arrays

Loading a Two-Dimensional Array

                                     Row by Row

@ You load a two-       Data Block
                                            A


  dimensional array        1
                                                                     Array

  with nested loops.       2                R            A
                           3          1             3
  The data are
                                                             C
                                                                 1     2   3    4
                           4                1           R

  normally loaded          5                                 1   1     2   3    4
                           6                                 2   5     6   7    8
  row by row. When         7                C                3   9    10 11 12

  you load the data        8
                           9
                                      1
                                            1
                                                    4
                                                             The row remains
  row by row, the          10                                 constant as the
                                                              column varies.
                           11
  outer         loop       12
                                          ENTER
  represents the row,                     A(R, C)

  and the inner loop
  represents the
                                            C
  column.                                                        C = Column




                                            R                         R = Row




                                            B




Processing Arrays                                                    *Property of STI
                                                                       Page 12 of 17
Data Structures and Algorithms




        Processing
        Arrays

 Printing a Two-Dimensional Array
                                      A




                                     PRINT
                                    COLUMN
                                   HEADINGS




                                      R
                               1          NR
                                      1




                               PRINT ROW
                               HEADING (R)




                                      C
                               1          NC
                                      1



                               PRINT A(R,C)
                               W/O CURSOR

      R = Row                    RETURN




      NR = Number of rows             C




      C = Column                   RETURN
                                   CURSOR




      NC = Number of columns          R




                                      B


Processing Arrays                                             *Property of STI
                                                                Page 13 of 17
Data Structures and Algorithms




        Processing
        Arrays

Accumulating the Rows and Columns of a Two-
Dimensional Array




     @ Column 5 holds the sum of each of the rows
     @ Row 4 holds the sum of each of the columns
     @ A (4,5) holds the grand total



Processing Arrays                                    *Property of STI
                                                       Page 14 of 17
Data Structures and Algorithms




        Processing
        Arrays

                    Algorithm      Flowchart
                                           A




     LOOP:R = 1 TO NR STEP 1               R
                                     1         NR
                                           1
     LOOP: C = 1 TO NC STEP 1
       A(R,NC + 1) = A(R,NC + 1)           C
                                     1         NC
           + A(R,C)                        1
       A(NR + 1,C) = A(NR + 1,C)
           + A(R,C)                   A(R, NC + 1) =
                                      A(R, NC + 1) +
                                         A(R,C)
     LOOP-END: C

                                      A(NR + 1,C)=
     A(NR + 1,NC + 1) =               A(NR + 1,C) +
                                         A(R,C)
      A(NR + 1, NC + 1)
          +A(R, NC + 1)
                                          C
     LOOP-END: R
                                     A(NR + 1,NC + 1)
                                    =A(NR + 1, NC + 1)
                                      +A(R, NC + 1)




                                           R




                                           B



Processing Arrays                                      *Property of STI
                                                         Page 15 of 17
Data Structures and Algorithms




        Processing
        Arrays

Multidimensional Arrays
In some cases there is a need for arrays with a third or
even a fourth dimension. These arrays are called
multidimensional arrays.


Advantages :
     @ Facilitate   an
       understanding
       of the data
     @ Improve     the
       readability of
       algorithms
     @ Facilitate
       processing




Processing Arrays                                      *Property of STI
                                                         Page 16 of 17
Data Structures and Algorithms




        Processing
        Arrays
Table Look-up Technique
 @ A common application for arrays is using a value to look up another
   value in a table. A one-dimensional array would be used if the
   element number can be utilized as the given value. A two-
   dimensional array with two columns would be used if the element
   number cannot be utilized.

              element   DAYS     Algorithm                FLOWCHART:


                1        31    1. ENTER MONTH
                               2. DAYS_OF_THE_MONTH =          START
                               DAYS(MONTH)
                2        28
                               3. PRINT DAYS_OF_MONTH
                               4. END
                3        31
                                                               ENTER
                4        30                                    MONTH


                5        31

                6        30                                DAYS_OF_THE_
                                                              MONTH =
                                                            DAYS(MONTH)
                7        31

                8        31
                                                               PRINT
                                                             DAYS_OF_
                9        30                                   MONTH


                10       31

                11       30
                                                                END

                12       31


Processing Arrays                                                       *Property of STI
                                                                          Page 17 of 17

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Sql ppt
Sql pptSql ppt
Sql ppt
 
Types of keys in dbms
Types of keys in dbmsTypes of keys in dbms
Types of keys in dbms
 
SQL
SQLSQL
SQL
 
Presentation on Data Structure
Presentation on Data StructurePresentation on Data Structure
Presentation on Data Structure
 
Introduction to data structure
Introduction to data structure Introduction to data structure
Introduction to data structure
 
Data structure ppt
Data structure pptData structure ppt
Data structure ppt
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
17. Trees and Graphs
17. Trees and Graphs17. Trees and Graphs
17. Trees and Graphs
 
SQL Joins.pptx
SQL Joins.pptxSQL Joins.pptx
SQL Joins.pptx
 
Tail Recursion in data structure
Tail Recursion in data structureTail Recursion in data structure
Tail Recursion in data structure
 
Algorithm Design Presentation
Algorithm Design PresentationAlgorithm Design Presentation
Algorithm Design Presentation
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 
STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data Structure
 
Decomposition methods in DBMS
Decomposition methods in DBMSDecomposition methods in DBMS
Decomposition methods in DBMS
 
Linguaggio R, principi e concetti
Linguaggio R, principi e concettiLinguaggio R, principi e concetti
Linguaggio R, principi e concetti
 
Presentation on Relational Schema (Database)
Presentation on Relational Schema (Database)Presentation on Relational Schema (Database)
Presentation on Relational Schema (Database)
 
Linear Search Presentation
Linear Search PresentationLinear Search Presentation
Linear Search Presentation
 
Oops in java
Oops in javaOops in java
Oops in java
 
SQL: Structured Query Language
SQL: Structured Query LanguageSQL: Structured Query Language
SQL: Structured Query Language
 
SQL
SQL SQL
SQL
 

Semelhante a 9 processing arrays

Instruction set of 8051.ppt
Instruction set of 8051.pptInstruction set of 8051.ppt
Instruction set of 8051.pptChandiniChinni2
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To LispLISP Content
 
Dot Call interface
Dot Call interfaceDot Call interface
Dot Call interfaceHao Chai
 
microcontroller_instruction_set for ENGINEERING STUDENTS
microcontroller_instruction_set for  ENGINEERING STUDENTSmicrocontroller_instruction_set for  ENGINEERING STUDENTS
microcontroller_instruction_set for ENGINEERING STUDENTSssuser2b759d
 
Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence) Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence) wahab khan
 
compiler design.pdf
compiler design.pdfcompiler design.pdf
compiler design.pdfRijuMandal11
 
Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)Chia-Chi Chang
 
Unit ii microcontrollers final
Unit ii microcontrollers finalUnit ii microcontrollers final
Unit ii microcontrollers finalSARITHA REDDY
 
Lec3 instructions branch carl hamcher
Lec3 instructions branch carl hamcher Lec3 instructions branch carl hamcher
Lec3 instructions branch carl hamcher Venkata Krishnakanth P
 
Please I want a detailed complete answers for each part.Then make.pdf
Please I want a detailed complete answers for each part.Then make.pdfPlease I want a detailed complete answers for each part.Then make.pdf
Please I want a detailed complete answers for each part.Then make.pdfsiennatimbok52331
 
Microcontroller instruction set
Microcontroller instruction setMicrocontroller instruction set
Microcontroller instruction setShail Modi
 

Semelhante a 9 processing arrays (20)

Instruction set of 8051.ppt
Instruction set of 8051.pptInstruction set of 8051.ppt
Instruction set of 8051.ppt
 
LISP: Introduction to lisp
LISP: Introduction to lispLISP: Introduction to lisp
LISP: Introduction to lisp
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
 
Dot Call interface
Dot Call interfaceDot Call interface
Dot Call interface
 
microcontroller_instruction_set for ENGINEERING STUDENTS
microcontroller_instruction_set for  ENGINEERING STUDENTSmicrocontroller_instruction_set for  ENGINEERING STUDENTS
microcontroller_instruction_set for ENGINEERING STUDENTS
 
Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence) Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence)
 
Ch2
Ch2Ch2
Ch2
 
(Ai lisp)
(Ai lisp)(Ai lisp)
(Ai lisp)
 
Introduction to R for beginners
Introduction to R for beginnersIntroduction to R for beginners
Introduction to R for beginners
 
compiler design.pdf
compiler design.pdfcompiler design.pdf
compiler design.pdf
 
Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)Learning notes of r for python programmer (Temp1)
Learning notes of r for python programmer (Temp1)
 
Unit ii microcontrollers final
Unit ii microcontrollers finalUnit ii microcontrollers final
Unit ii microcontrollers final
 
Numpy
NumpyNumpy
Numpy
 
Lec3 instructions branch carl hamcher
Lec3 instructions branch carl hamcher Lec3 instructions branch carl hamcher
Lec3 instructions branch carl hamcher
 
Avr instruction set
Avr instruction setAvr instruction set
Avr instruction set
 
DBMS CS3
DBMS CS3DBMS CS3
DBMS CS3
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
Please I want a detailed complete answers for each part.Then make.pdf
Please I want a detailed complete answers for each part.Then make.pdfPlease I want a detailed complete answers for each part.Then make.pdf
Please I want a detailed complete answers for each part.Then make.pdf
 
Microcontroller instruction set
Microcontroller instruction setMicrocontroller instruction set
Microcontroller instruction set
 

Mais de Rheigh Henley Calderon

8 problem solving with the case logic structure
8 problem solving with the case logic structure8 problem solving with the case logic structure
8 problem solving with the case logic structureRheigh Henley Calderon
 
5 problem solving with the sequential logic structure
5 problem solving with the sequential logic structure5 problem solving with the sequential logic structure
5 problem solving with the sequential logic structureRheigh Henley Calderon
 
4 introduction to programming structure
4 introduction to programming structure4 introduction to programming structure
4 introduction to programming structureRheigh Henley Calderon
 
2 beginning problem solving concepts for the computer
2 beginning problem solving concepts for the computer2 beginning problem solving concepts for the computer
2 beginning problem solving concepts for the computerRheigh Henley Calderon
 
1 introduction to problem solving and programming
1 introduction to problem solving and programming1 introduction to problem solving and programming
1 introduction to problem solving and programmingRheigh Henley Calderon
 

Mais de Rheigh Henley Calderon (20)

10 data structures
10 data structures10 data structures
10 data structures
 
8 problem solving with the case logic structure
8 problem solving with the case logic structure8 problem solving with the case logic structure
8 problem solving with the case logic structure
 
7 problem solving with loops
7 problem solving with loops7 problem solving with loops
7 problem solving with loops
 
6 problem solving with decisions
6 problem solving with decisions6 problem solving with decisions
6 problem solving with decisions
 
5 problem solving with the sequential logic structure
5 problem solving with the sequential logic structure5 problem solving with the sequential logic structure
5 problem solving with the sequential logic structure
 
4 introduction to programming structure
4 introduction to programming structure4 introduction to programming structure
4 introduction to programming structure
 
3 programming concepts
3 programming concepts3 programming concepts
3 programming concepts
 
2 beginning problem solving concepts for the computer
2 beginning problem solving concepts for the computer2 beginning problem solving concepts for the computer
2 beginning problem solving concepts for the computer
 
1 introduction to problem solving and programming
1 introduction to problem solving and programming1 introduction to problem solving and programming
1 introduction to problem solving and programming
 
9 technical support
9 technical support9 technical support
9 technical support
 
8 customer service
8 customer service8 customer service
8 customer service
 
7 laptop repair
7 laptop repair7 laptop repair
7 laptop repair
 
6 laptop basics
6 laptop basics6 laptop basics
6 laptop basics
 
5 pc maintenance
5 pc maintenance5 pc maintenance
5 pc maintenance
 
4 pc repair
4 pc repair4 pc repair
4 pc repair
 
3 pc upgrade
3 pc upgrade3 pc upgrade
3 pc upgrade
 
2 pc assembly
2 pc assembly2 pc assembly
2 pc assembly
 
1 hardware fundamentals
1 hardware fundamentals1 hardware fundamentals
1 hardware fundamentals
 
8 cyber crimes
8 cyber crimes8 cyber crimes
8 cyber crimes
 
7 computer ethics
7 computer ethics7 computer ethics
7 computer ethics
 

Último

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Último (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

9 processing arrays

  • 1. Data Structures and Algorithms Processing Arrays Arrays @ Often advantageous for a user to store several values for the same variable in the internal memory of the computer because it decreases processing time. @ This multiple storage means there has to be more than one memory location in the computer for each variable name. @ When more than one memory location is designated for a single variable, it is called an array. Static Arrays @ This means that once the computer is told how many locations to save, that number cannot be changed unless the instruction is changed. Processing Arrays *Property of STI Page 1 of 17
  • 2. Data Structures and Algorithms Processing Arrays Dynamic Arrays @ When using dynamic arrays, the programmer designates the number of array locations as a variable, which can be expanded or contracted during the execution of the solution. Base-Zero System @ Because computers are zero-based, for counting purposes, many programming languages are also zero-based. @ This means that the first array element is numbered zero and not one. Base-One System @ Base one is easier for the programmer to understand since the first element will have an index of 1. Processing Arrays *Property of STI Page 2 of 17
  • 3. Data Structures and Algorithms Processing Arrays Base-Zero Versus Base-One Arrays Processing Arrays *Property of STI Page 3 of 17
  • 4. Data Structures and Algorithms Processing Arrays One-Dimensional Arrays Processing Arrays *Property of STI Page 4 of 17
  • 5. Data Structures and Algorithms Processing Arrays Parallel Arrays Processing Arrays *Property of STI Page 5 of 17
  • 6. Data Structures and Algorithms Processing Arrays Entering Data into an Array Algorithm Flowchart A LOOP:R = 1 TO N STEP 1 R 1 N ENTER A(R) 1 LOOP-END:R ENTER A(R) R = Counter R N = Number of elements in the array A(R) = Element R B in the A array Processing Arrays *Property of STI Page 6 of 17
  • 7. Data Structures and Algorithms Processing Arrays Algorithm Flowchart A R=0 1. R = 0 2. REPEAT REPEAT R = R+1 R=R+1 ENTER A(R) UNTIL A(R) = -1 ENTER A(R) *3. N = R-1 F UNTIL A(R) = -1 T * N=R-1 B Processing Arrays *Property of STI Page 7 of 17
  • 8. Data Structures and Algorithms Processing Arrays Algorithm Flowchart A 1. R = 1 R=1 2. ENTER A(R) 3. WHILE A(R) <> -1 ENTER A(R) R = R+1 ENTER A(R) WHILE F A(R) <> -1 WHILE - END *4. N = R-1 R=R+1 ENTER A(R) * N=R+1 B Processing Arrays *Property of STI Page 8 of 17
  • 9. Data Structures and Algorithms Processing Arrays Printing an Array Algorithm Flowchart A LOOP: R=1 TO N STEP 1 PRINT A(R) R 1 N 1 LOOP-END: R PRINT R = Element number A(R) N = Total number of elements R A(R) = Rth element of the A array B Processing Arrays *Property of STI Page 9 of 17
  • 10. Data Structures and Algorithms Processing Arrays Accumulating the Elements of an Array Algorithm Flowchart A LOOP:R = 1 TO N STEP 1 SUM = SUM + A(R) R 1 N LOOP-END: R 1 N = Number of elements SUM = SUM + A(R) R = Element number SUM = Sum of the R elements of A A(R) = Rth element of the array B TEST: R SUM A 1 2 1 2 3 2 6 12 4 5 6 7 20 30 42 2 4 3 6 4 8 N 5 10 6 6 12 Processing Arrays *Property of STI Page 10 of 17
  • 11. Data Structures and Algorithms Processing Arrays Two-Dimensional Arrays @ A two-dimensional array is a block of memory locations associated with a single memory variable name and designated by row and column numbers. Processing Arrays *Property of STI Page 11 of 17
  • 12. Data Structures and Algorithms Processing Arrays Loading a Two-Dimensional Array Row by Row @ You load a two- Data Block A dimensional array 1 Array with nested loops. 2 R A 3 1 3 The data are C 1 2 3 4 4 1 R normally loaded 5 1 1 2 3 4 6 2 5 6 7 8 row by row. When 7 C 3 9 10 11 12 you load the data 8 9 1 1 4 The row remains row by row, the 10 constant as the column varies. 11 outer loop 12 ENTER represents the row, A(R, C) and the inner loop represents the C column. C = Column R R = Row B Processing Arrays *Property of STI Page 12 of 17
  • 13. Data Structures and Algorithms Processing Arrays Printing a Two-Dimensional Array A PRINT COLUMN HEADINGS R 1 NR 1 PRINT ROW HEADING (R) C 1 NC 1 PRINT A(R,C) W/O CURSOR R = Row RETURN NR = Number of rows C C = Column RETURN CURSOR NC = Number of columns R B Processing Arrays *Property of STI Page 13 of 17
  • 14. Data Structures and Algorithms Processing Arrays Accumulating the Rows and Columns of a Two- Dimensional Array @ Column 5 holds the sum of each of the rows @ Row 4 holds the sum of each of the columns @ A (4,5) holds the grand total Processing Arrays *Property of STI Page 14 of 17
  • 15. Data Structures and Algorithms Processing Arrays Algorithm Flowchart A LOOP:R = 1 TO NR STEP 1 R 1 NR 1 LOOP: C = 1 TO NC STEP 1 A(R,NC + 1) = A(R,NC + 1) C 1 NC + A(R,C) 1 A(NR + 1,C) = A(NR + 1,C) + A(R,C) A(R, NC + 1) = A(R, NC + 1) + A(R,C) LOOP-END: C A(NR + 1,C)= A(NR + 1,NC + 1) = A(NR + 1,C) + A(R,C) A(NR + 1, NC + 1) +A(R, NC + 1) C LOOP-END: R A(NR + 1,NC + 1) =A(NR + 1, NC + 1) +A(R, NC + 1) R B Processing Arrays *Property of STI Page 15 of 17
  • 16. Data Structures and Algorithms Processing Arrays Multidimensional Arrays In some cases there is a need for arrays with a third or even a fourth dimension. These arrays are called multidimensional arrays. Advantages : @ Facilitate an understanding of the data @ Improve the readability of algorithms @ Facilitate processing Processing Arrays *Property of STI Page 16 of 17
  • 17. Data Structures and Algorithms Processing Arrays Table Look-up Technique @ A common application for arrays is using a value to look up another value in a table. A one-dimensional array would be used if the element number can be utilized as the given value. A two- dimensional array with two columns would be used if the element number cannot be utilized. element DAYS Algorithm FLOWCHART: 1 31 1. ENTER MONTH 2. DAYS_OF_THE_MONTH = START DAYS(MONTH) 2 28 3. PRINT DAYS_OF_MONTH 4. END 3 31 ENTER 4 30 MONTH 5 31 6 30 DAYS_OF_THE_ MONTH = DAYS(MONTH) 7 31 8 31 PRINT DAYS_OF_ 9 30 MONTH 10 31 11 30 END 12 31 Processing Arrays *Property of STI Page 17 of 17