College Board 3.11 3.13 - LindaLiu1202/lindaliu GitHub Wiki

College Board 3.11 Video Notes

  • Data must be in sorted order to use the binary search algorithm (in ascending or descending order)
  • Data lists can contain words sorted in alphabetical order.
  • Binary Search divides ranges by 2.
    • (First index number in range + last index #) / 2
  • The search using the sum of highest index and lowest index divided by two provides the index of the middle number.
  • Most of the time a Binary Search is more efficient than a Sequential Search(line up and pull one at a time and see if that’s the target).

College Board 3.12 Video Notes

  • A procedure is a named group of programming instructions that may have parameters and return values.

    • A group of program instructions with a purpose, and then we give a good descriptive name that tells us about that purpose. (ex. Help us organize our programming language)
  • Procedures are referred to by different names, such as method or function, depending on the programming language.

  • Parameters are input values of a procedure. Arguments specify the values of the parameters when a procedure is called.

  • A procedure call interrupts the sequential execution of statements. causing the program to execute the statements within the procedure before continuing. Once the last statement in the procedure (or a return statement) has been executed. flow of control is returned to the point immediately following where the procedure was called.

  • How to write statements to call procedures?

  • When we call a procedure, that call is going to depend on whether or not the procedure returns some data / value. If not, just a block of statements,, then you call that procedure by referring to the procedure name and the argument. If it does return some kind of value, then you will assign that value to a variable(result ← proName (arg1, arg2) )

  • Name of procedure should ld describe the purpose

  • When making procedure calls, especially if it has a return value, think about what am I going to pass through as an argument into that procedure call, and do I need to assign it to some variable.

  • When see return - immediately exit the procedure

College Board 3.13 Video Notes

  • How to develop procedural abstraction to manage complexity in a program by writing procedures?

    • Need to pick a name for the procedure that is descriptive.
    • Then think about do I need any parameters? What kind of data would I need to take in to accomplish my goal? What information do I need?
    • Write the procedure
    • Return the procedure if needed
  • Why is it important to write these procedures? How does it help me as a programmer? Benefits?

  • One common type of abstraction is procedural abstraction, which provides a name for a process and allows a procedure to be used only knowing what it does, not how it does it.

  • Procedural abstraction allows a solution to a large problem to be based on the solutions of smaller subproblems. This is accomplished by creating procedures to solve each of the subproblems.

  • The subdivision of a computer program into separate subprograms is called modularity.

  • A procedural abstraction may extract shared features to generalize functionality instead of duplicating code. This allows for program reuse. which helps manage complexity.

  • The procedure round(number) takes in a number and returns the rounded value.

    • We do not need to know how the procedure round(number) works, just what it does and how to call it.
  • Benefit: We can update the procedure as we go and make it better. And we never have to change how the procedure is called in our program code.

  • Benefit: Help in identifying bugs and errors and fixing those. Procedural abstraction really does help manage the complexity of the program.

  • Using parameters allows procedures to be generalized. enabling the procedures to be reused with a range of input values or arguments.

  • Using procedural abstraction helps improve code readability.

  • Using procedural abstraction in a program allows programmers to change the internals of the procedure (to make it faster, more efficient. use less storage, etc.) without needing to notify users of the change as long as what the procedure does is preserved.