Software Design and Development

Home > Software Design and Development > Core > Software Development Cycle > Standard Algorithms: Searching

Answers

Standard search algorithms used in software solutions

Activity 1: Linear search

  1. Trace table LINEARSEARCH

    lastindex

    index

    element(index)

    foundit

    12

    1

    11

    F

    12

    2

    3

    F

    12

    3

    12

    F

    12

    4

    5

    T

    12

    5

    13

    T

    12

    6

    4

    T

    12

    7

    6

    T

    12

    8

    14

    T

    12

    9

    7

    T

    12

    10

    8

    T

    12

    11

    15

    T

    12

    12

    1

    T


  2. Remove the test foundit = false in the WHILE loop.
Back to Standard search algorithms used in software solutions

Activity 2: Binary search

  1. Trace table BINARYSEARCH

    index

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    element

    3

    5

    12

    17

    25

    33

    53

    64

    72

    77

    84

    86

    89

    90

    99

    Chop 1

    low







    mid







    hi

    Chop 2

    low



    mid




    hi








    Chop 3

    low

    mid


    hi












Back to Standard search algorithms used in software solutions

Neals logo | Copyright | Disclaimer | Contact Us | Help