SlideShare a Scribd company logo
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
Ad

More Related Content

What's hot (20)

Computer registers
Computer registersComputer registers
Computer registers
Jatin Grover
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked List
ManishPrajapati78
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithms
Aakash deep Singhal
 
Computer organization memory
Computer organization memoryComputer organization memory
Computer organization memory
Deepak John
 
Step to program in tasm
Step to program in tasmStep to program in tasm
Step to program in tasm
Mohammad Shoeb Quraishi
 
design of accumlator
design of accumlatordesign of accumlator
design of accumlator
SangeethaSasi1
 
B+ tree intro,uses,insertion and deletion
B+ tree intro,uses,insertion and deletionB+ tree intro,uses,insertion and deletion
B+ tree intro,uses,insertion and deletion
HAMID-50
 
12 process control blocks
12 process control blocks12 process control blocks
12 process control blocks
myrajendra
 
Ascii adjust & decimal adjust
Ascii adjust & decimal adjustAscii adjust & decimal adjust
Ascii adjust & decimal adjust
Tech_MX
 
Linked lists a
Linked lists aLinked lists a
Linked lists a
Khuram Shahzad
 
REGISTER TRANSFER AND MICROOPERATIONS
REGISTER  TRANSFER  AND  MICROOPERATIONSREGISTER  TRANSFER  AND  MICROOPERATIONS
REGISTER TRANSFER AND MICROOPERATIONS
Dr. Ajay Kumar Singh
 
Operating system Memory management
Operating system Memory management Operating system Memory management
Operating system Memory management
Shashank Asthana
 
Memory management
Memory managementMemory management
Memory management
Vishal Singh
 
3 Pipelining
3 Pipelining3 Pipelining
3 Pipelining
fika sweety
 
Memory organization
Memory organizationMemory organization
Memory organization
ishapadhy
 
Assembly language 8086
Assembly language 8086Assembly language 8086
Assembly language 8086
John Cutajar
 
Single linked list
Single linked listSingle linked list
Single linked list
jasbirsingh chauhan
 
Computer organization-and-architecture-questions-and-answers
Computer organization-and-architecture-questions-and-answersComputer organization-and-architecture-questions-and-answers
Computer organization-and-architecture-questions-and-answers
appasami
 
What is CPU Register? Type of CPU Register.
What is CPU Register? Type of CPU Register.What is CPU Register? Type of CPU Register.
What is CPU Register? Type of CPU Register.
Kapil Dev Das
 
pipelining
pipeliningpipelining
pipelining
Siddique Ibrahim
 
Computer registers
Computer registersComputer registers
Computer registers
Jatin Grover
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked List
ManishPrajapati78
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithms
Aakash deep Singhal
 
Computer organization memory
Computer organization memoryComputer organization memory
Computer organization memory
Deepak John
 
B+ tree intro,uses,insertion and deletion
B+ tree intro,uses,insertion and deletionB+ tree intro,uses,insertion and deletion
B+ tree intro,uses,insertion and deletion
HAMID-50
 
12 process control blocks
12 process control blocks12 process control blocks
12 process control blocks
myrajendra
 
Ascii adjust & decimal adjust
Ascii adjust & decimal adjustAscii adjust & decimal adjust
Ascii adjust & decimal adjust
Tech_MX
 
REGISTER TRANSFER AND MICROOPERATIONS
REGISTER  TRANSFER  AND  MICROOPERATIONSREGISTER  TRANSFER  AND  MICROOPERATIONS
REGISTER TRANSFER AND MICROOPERATIONS
Dr. Ajay Kumar Singh
 
Operating system Memory management
Operating system Memory management Operating system Memory management
Operating system Memory management
Shashank Asthana
 
Memory organization
Memory organizationMemory organization
Memory organization
ishapadhy
 
Assembly language 8086
Assembly language 8086Assembly language 8086
Assembly language 8086
John Cutajar
 
Computer organization-and-architecture-questions-and-answers
Computer organization-and-architecture-questions-and-answersComputer organization-and-architecture-questions-and-answers
Computer organization-and-architecture-questions-and-answers
appasami
 
What is CPU Register? Type of CPU Register.
What is CPU Register? Type of CPU Register.What is CPU Register? Type of CPU Register.
What is CPU Register? Type of CPU Register.
Kapil Dev Das
 

Similar to 9 processing arrays (20)

Instruction set of 8051.ppt
Instruction set of 8051.pptInstruction set of 8051.ppt
Instruction set of 8051.ppt
ChandiniChinni2
 
instruction_set_8051_microcontroller.ppt
instruction_set_8051_microcontroller.pptinstruction_set_8051_microcontroller.ppt
instruction_set_8051_microcontroller.ppt
KhairulAlam98
 
LISP: Introduction to lisp
LISP: Introduction to lispLISP: Introduction to lisp
LISP: Introduction to lisp
DataminingTools Inc
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
LISP Content
 
Dot Call interface
Dot Call interfaceDot Call interface
Dot Call interface
Hao Chai
 
microcontroller_instruction_set for ENGINEERING STUDENTS
microcontroller_instruction_set for  ENGINEERING STUDENTSmicrocontroller_instruction_set for  ENGINEERING STUDENTS
microcontroller_instruction_set for ENGINEERING STUDENTS
ssuser2b759d
 
Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence) Advance LISP (Artificial Intelligence)
Advance LISP (Artificial Intelligence)
wahab khan
 
Ch2
Ch2Ch2
Ch2
Siddharth Sood
 
(Ai lisp)
(Ai lisp)(Ai lisp)
(Ai lisp)
Ravi Rao
 
Introduction to R for beginners
Introduction to R for beginnersIntroduction to R for beginners
Introduction to R for beginners
Abishek Purushothaman
 
compiler design.pdf
compiler design.pdfcompiler design.pdf
compiler design.pdf
RijuMandal11
 
5. Data Processing Instruction for embedded system.pptx
5. Data Processing Instruction for embedded system.pptx5. Data Processing Instruction for embedded system.pptx
5. Data Processing Instruction for embedded system.pptx
NivethithaV19PHD1192
 
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 final
SARITHA REDDY
 
Numpy
NumpyNumpy
Numpy
Jyoti shukla
 
Lec3 instructions branch carl hamcher
Lec3 instructions branch carl hamcher Lec3 instructions branch carl hamcher
Lec3 instructions branch carl hamcher
Venkata Krishnakanth P
 
Avr instruction set
Avr instruction setAvr instruction set
Avr instruction set
Kendar Donayre Manrique
 
AVR or ATmega32 Addressing modes and Instruction set description .pdf
AVR or ATmega32  Addressing modes and Instruction set description .pdfAVR or ATmega32  Addressing modes and Instruction set description .pdf
AVR or ATmega32 Addressing modes and Instruction set description .pdf
KSRaviKumarMVGREEE
 
DBMS CS3
DBMS CS3DBMS CS3
DBMS CS3
Infinity Tech Solutions
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
Nithin Santhosh
 
Instruction set of 8051.ppt
Instruction set of 8051.pptInstruction set of 8051.ppt
Instruction set of 8051.ppt
ChandiniChinni2
 
instruction_set_8051_microcontroller.ppt
instruction_set_8051_microcontroller.pptinstruction_set_8051_microcontroller.ppt
instruction_set_8051_microcontroller.ppt
KhairulAlam98
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
LISP Content
 
Dot Call interface
Dot Call interfaceDot Call interface
Dot Call interface
Hao Chai
 
microcontroller_instruction_set for ENGINEERING STUDENTS
microcontroller_instruction_set for  ENGINEERING STUDENTSmicrocontroller_instruction_set for  ENGINEERING STUDENTS
microcontroller_instruction_set for ENGINEERING STUDENTS
ssuser2b759d
 
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.pdf
RijuMandal11
 
5. Data Processing Instruction for embedded system.pptx
5. Data Processing Instruction for embedded system.pptx5. Data Processing Instruction for embedded system.pptx
5. Data Processing Instruction for embedded system.pptx
NivethithaV19PHD1192
 
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 final
SARITHA REDDY
 
Lec3 instructions branch carl hamcher
Lec3 instructions branch carl hamcher Lec3 instructions branch carl hamcher
Lec3 instructions branch carl hamcher
Venkata Krishnakanth P
 
AVR or ATmega32 Addressing modes and Instruction set description .pdf
AVR or ATmega32  Addressing modes and Instruction set description .pdfAVR or ATmega32  Addressing modes and Instruction set description .pdf
AVR or ATmega32 Addressing modes and Instruction set description .pdf
KSRaviKumarMVGREEE
 
Ad

More from Rheigh Henley Calderon (20)

10 data structures
10 data structures10 data structures
10 data structures
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 structure
Rheigh Henley Calderon
 
7 problem solving with loops
7 problem solving with loops7 problem solving with loops
7 problem solving with loops
Rheigh Henley Calderon
 
6 problem solving with decisions
6 problem solving with decisions6 problem solving with decisions
6 problem solving with decisions
Rheigh 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 structure
Rheigh Henley Calderon
 
4 introduction to programming structure
4 introduction to programming structure4 introduction to programming structure
4 introduction to programming structure
Rheigh Henley Calderon
 
3 programming concepts
3 programming concepts3 programming concepts
3 programming concepts
Rheigh 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 computer
Rheigh 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 programming
Rheigh Henley Calderon
 
9 technical support
9 technical support9 technical support
9 technical support
Rheigh Henley Calderon
 
8 customer service
8 customer service8 customer service
8 customer service
Rheigh Henley Calderon
 
7 laptop repair
7 laptop repair7 laptop repair
7 laptop repair
Rheigh Henley Calderon
 
6 laptop basics
6 laptop basics6 laptop basics
6 laptop basics
Rheigh Henley Calderon
 
5 pc maintenance
5 pc maintenance5 pc maintenance
5 pc maintenance
Rheigh Henley Calderon
 
4 pc repair
4 pc repair4 pc repair
4 pc repair
Rheigh Henley Calderon
 
3 pc upgrade
3 pc upgrade3 pc upgrade
3 pc upgrade
Rheigh Henley Calderon
 
2 pc assembly
2 pc assembly2 pc assembly
2 pc assembly
Rheigh Henley Calderon
 
1 hardware fundamentals
1 hardware fundamentals1 hardware fundamentals
1 hardware fundamentals
Rheigh Henley Calderon
 
8 cyber crimes
8 cyber crimes8 cyber crimes
8 cyber crimes
Rheigh Henley Calderon
 
7 computer ethics
7 computer ethics7 computer ethics
7 computer ethics
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 structure
Rheigh 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 structure
Rheigh Henley Calderon
 
4 introduction to programming structure
4 introduction to programming structure4 introduction to programming structure
4 introduction to programming structure
Rheigh 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 computer
Rheigh 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 programming
Rheigh Henley Calderon
 
Ad

Recently uploaded (20)

Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Web and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in RajpuraWeb and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in Rajpura
Erginous Technology
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Top 10 IT Help Desk Outsourcing Services
Top 10 IT Help Desk Outsourcing ServicesTop 10 IT Help Desk Outsourcing Services
Top 10 IT Help Desk Outsourcing Services
Infrassist Technologies Pvt. Ltd.
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Unlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive GuideUnlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive Guide
vikasascentbpo
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Vaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without HallucinationsVaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without Hallucinations
john409870
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdfAre Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Telecoms Supermarket
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Web and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in RajpuraWeb and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in Rajpura
Erginous Technology
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Unlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive GuideUnlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive Guide
vikasascentbpo
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Vaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without HallucinationsVaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without Hallucinations
john409870
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdfAre Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Telecoms Supermarket
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 

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