Fundamentals of Computer Programming and Algorithm Design

Computer science3.04 KB

Program Structure

Program: Legible instructions for the computer, sorted sequentially to perform a particular job or solve a problem, using a language understood by the machine. The program represents a man-machine relationship, while the algorithm represents a relationship between man and man.

Types of Programs

  • Linear Programs: The development of the program is done in the same sequential order in which instructions are written.
  • Cyclic: They contain a group of statements to be repeated a number of times and therefore must contain branch instructions or supervision.
  • Alternatives: There are those who can go through different paths depending on the values that make certain variables.

Glossary

Why is the program run in sequence?

Because it is the computer control unit that takes into account the location of the next instruction to be executed.

When does a program not have a resolution?

When the computer encounters an instruction that, due to failure or error by the programmer, could not run.

How many cycles can a program have?

A program must have a finite number of cycles, since the computer otherwise would never stop.

Routine: A set of instructions that fulfills a specific task in a program that normally runs once.

Subroutine: Identical to a routine but can be run an unlimited number of times.

Flow Diagrams

Symbols are used to show, in a graphic and easily recognizable way, the steps followed in a computational process that solves a problem.

Programming Logic Analysis

  • Ask if there are orders.
  • Read part codes and quantity ordered.
  • Validate the code (1).
  • Read the file inventory stock.
  • "Is there enough stock?" (2).
  • Other parts of the stock (if any).
  • Make order and invoice.
  • (1) Present code error message.
  • (2) Present lack of stock message.

Algorithm Features

An algorithm is a list of instructions in a logical and sequential order to solve a problem or make a process.

  • Non-ambiguous: Specific instructions that are clear and precise.
  • Finite: Must run on a number of simple instructions given.
  • General: An algorithm should be applicable to more than a specific problem; i.e., the same algorithm can solve similar problems.
  • Efficient: It must express the least number of instructions, with maximum detail as possible, and accomplish what is asked in a minimum of time.

Pseudocode

The algorithm incorporates basic structures such as the Condition (which can be simple or compound) and a Cycle.

Basic Algorithm Components

Variables, Operators, and Expressions; Assignments; Input and Output; Control Structures.

Download

PDF Word HTML