Primeiro Algoritmo - Curso de Algoritmos #02 - Gustavo Guanabara

Primeiro Algoritmo - Curso de Algoritmos #02 - Gustavo Guanabara

Understanding Computational Algorithms

Introduction to Algorithms

  • Gustavo Guanabara introduces the second class of the algorithm course, focusing on computational algorithms after discussing logic problems in the previous lesson.
  • The distinction between general algorithms and computational algorithms is explained; while all routines can be considered algorithms, computational algorithms specifically relate to computer processing.

Definition and Components of Computational Algorithms

  • Guanabara defines computational algorithms as "steps to be followed by a processor module and their users," emphasizing the importance of executing these steps in the correct order for task completion.
  • Key terms highlighted include:
  • Processor Module: Any device capable of processing information (e.g., computers, tablets, smartphones).
  • Users: Individuals who utilize these programs or systems.
  • Task: The specific problem that needs solving through algorithm execution.

Real-world Applications of Computational Algorithms

  • Examples of everyday applications are provided, such as management systems for stores and pharmacies, which rely on computational algorithms for inventory control.
  • Accessing banking services (like viewing balances or making transfers), social media interactions, video streaming, and gaming are all driven by complex computational algorithms.

Starting with Logic Programming

  • Guanabara explains that creating computational algorithms begins with developing logical reasoning. This foundational skill is crucial before transitioning into actual programming languages.
  • The initial focus will be on building good logic skills before writing this logic in any programming language (e.g., Java, PHP).

Tools for Representing Programming Logic

  • Various tools exist for representing programming logic; traditional methods include flowcharts and Nassi-Shneiderman diagrams. However, these are becoming less common in modern education.
  • The course will emphasize using Pseudo or Portugol—a way to represent programming logic in a native language—before moving onto actual programming languages.

Introduction to Programming Logic and Tools

Importance of Learning Algorithms

  • The speaker emphasizes the necessity of understanding programming logic before diving into specific languages like PHP or Java, highlighting that many requests for courses stem from a lack of foundational knowledge.
  • A solid grasp of algorithms and pseudocode is deemed essential for IT professionals, marking it as a critical first step in programming education.

Historical Context and Learning Tools

  • The speaker reflects on traditional learning methods, noting that older programmers often learned through tools like Portugol and Flowcharts without practical application, relying solely on theoretical instruction.
  • Introduction of modern tools: Visualg is presented as an effective tool for learning programming logic and algorithms, bridging the gap between theory and practice.

Overview of Visualg

  • Visualg was developed by Claudio Morgado with support from other educators in Brazil. It aims to facilitate algorithm learning among students, showcasing its significance in technology education.
  • The tool is available for free download at www.cursoemvideo.com under the Algorithms course section. Users must register with their email to access the package containing exercises and handouts.

Getting Started with Visualg

  • Upon opening Visualg, users are introduced to its interface which includes areas for code input, memory representation, and output display. Basic commands can be executed using simple keyboard shortcuts.
  • The structure of an algorithm in Visualg consists of defined sections: variable declarations (var), starting point ("start"), and ending point ("fimalgoritimo"). Understanding these components is crucial for writing effective algorithms.

First Program: "Hello World"

  • The speaker introduces the concept of creating a "Hello World" program as a rite of passage in learning any new programming language or technology. This serves as an initial exercise to familiarize learners with coding syntax.
  • Emphasizing the importance of this exercise, the speaker humorously notes that failing to complete it may hinder future learning opportunities in programming languages such as PHP or Java.

Writing Output Commands

  • To display text on screen using Visualg, learners will use the "Type" command followed by quotation marks around their message. This highlights how strings are treated within algorithms.
  • An example command is provided: Type("Hello World"), demonstrating how to format output correctly while also addressing potential compatibility issues with accents in text display across different systems.

Running Your Program

Introduction to Basic Programming Concepts

First Steps in Programming

  • The program execution begins with the output "Hello, World!" and concludes with "End of execution." Users can close the window by clicking "X" or pressing "ESC."
  • Students often find initial programming environments like Guanabara unattractive, but these are essential for learning foundational skills before creating aesthetically pleasing applications.

Learning Curve in Algorithm Development

  • Beginners will initially create simple, practical algorithms that may not be visually appealing. This process is akin to a child's first wobbly steps.
  • Focus should be on learning rather than creating beautiful applications; the goal is to understand the fundamentals of algorithm creation.

Output Commands in Programming

  • To display messages, one can use the command "Write," which outputs text without line breaks.
  • When using two "Write" commands, both messages appear next to each other. A different command called "Escreval" allows for writing messages with line breaks.

Understanding Variables

  • The distinction between commands: "Type" writes inline while "Escreval" writes and moves to a new line.
  • An area labeled 'Var' exists within code where variables are defined but initially remains empty until values are assigned.

Conceptualizing Variables

  • Variables are likened to a closet filled with spaces (memory), where each space can hold specific values identified by labels.
  • Each variable must have a unique identifier (label), similar to placing items in designated areas within a closet.

Rules for Naming Identifiers

Identifier Naming Rules in Programming

Key Rules for Identifiers

  • The second rule states that identifiers can consist of letters or numbers, starting with a letter followed by more letters or numbers.
  • The fourth rule prohibits the use of blanks in identifiers, while the fifth rule disallows accented characters. Reserved words cannot be used as identifiers either.
  • In VisuAlg, reserved words are typically underlined or displayed in blue. Examples include "algorithm," "Var," and "Start."

Validity of Identifier Examples

  • The identifier "Note 1" is valid as it adheres to all six rules: starts with a letter, contains no symbols or spaces, has no accents, and is not a reserved word.
  • The identifier "Gross Salary" is invalid due to containing a space and an accented character. It could be corrected by removing the accent and using an underscore instead.
  • The identifier "9dade" is invalid because it begins with a number, violating the first naming rule.

More Identifier Examples

  • While "algorithm" follows most rules, it is invalid as it is a reserved word.
  • Conversely, "Inicio_Algoritmo" is valid since it combines two non-reserved words while adhering to all naming conventions.

Primitive Data Types in VisuAlg

Overview of Primitive Types

  • There are four primitive types in VisuAlg: Integer (Full), Real (Real), Character (Caracter), and Logical (Logico).

Understanding Each Type

  • Integer type stores whole numbers without fractions; examples include -5, 0, and 198.
  • Real type includes fractional numbers represented with points rather than commas; examples are 5.0 and -77.3.

Character Type Details

  • Character type encompasses any sequence within quotation marks; for instance, "Hello World" or even numeric strings like "123".

Logical Type Explanation

  • Logical type only holds two values: TRUE and FALSE. This concludes the overview of primitive types available in VisuAlg.

Creating Variables in VisuAlg

Variable Declaration Process

  • To declare variables in VisuAlg, you must specify the variable name followed by a colon and its data type; for example: VAR MSG : CHARACTER.

Understanding Variable Assignment in Programming

Introduction to Variables and Memory

  • The concept of variable assignment is introduced, likening computer memory to a cupboard filled with empty containers. A variable named MSG is created to store character-type messages.

Assigning Values to Variables

  • When assigning a value, the system labels the memory space for MSG, indicating it will hold character data. An example message "HELLO, WORLD!" can be directly assigned to this variable.

The Assignment Process Explained

  • The assignment process involves using the symbol <- (less than followed by minus), which acts like an arrow pointing from the right side (the value) to the left side (the variable).
  • This representation indicates that MSG will receive the string "Hello, World!", effectively placing this message into the MSG variable.

Using Variables in Output Commands

  • After assigning "Hello, World!" to MSG, instead of writing out the string again, one can simply use WRITE MSG to display its content.
  • A common mistake occurs when users write WRITE "MSG"; this outputs the literal text "MSG" rather than its stored value.

Correcting Output Issues

  • To correctly display the message stored in MSG, one must use parentheses: WRITE(MSG) which successfully shows "Hello, World!" on screen.

Understanding Variable Content and Initialization

  • It’s emphasized that after initialization, MSG contains "Hello, World!". Users are reminded of how variables should be declared and initialized before use.

Multiple Outputs with WRITE Command

  • Different output scenarios are discussed:
  • Writing "MSG" outputs exactly that text.
  • Writing just MSG displays its content.
  • Combining both with a comma allows displaying multiple items: e.g., "message", MSG.
  • An example demonstrates how combining strings and variables works seamlessly within output commands.

Conclusion and Next Steps in Learning Algorithms

  • The importance of understanding basic programming structures such as variables and types is highlighted as foundational knowledge for future lessons involving user interaction.
  • Future classes will focus on creating interactive programs where user input is processed—an essential skill for developing algorithms.

Final Thoughts from Instructor

  • Gustavo Guanabara expresses gratitude towards students for their participation in learning algorithms and emphasizes practice as key to mastering programming logic over time.

Course Overview and Access

How to Receive Notifications and Access Classes

  • Users can receive email notifications for new classes by entering their email in the channel settings, ensuring they are alerted before others.
  • The course structure includes multiple classes (third, fourth, etc.) designed to facilitate easy understanding of algorithms.

Free Course Availability

  • The algorithm course is available for free on the website www.cursoemvideo.com, which hosts all previously created courses including a comprehensive HTML5 course with 36 lessons.
  • Additional resources include access to the YouTube channel at YOUTUBE.COM/CURSOSEMVIDEO and Facebook page at FACEBOOK.COM/CURSOSEMVIDEO for updates and content sharing.

Engagement and Learning Strategy

  • The Facebook page features studio photos and behind-the-scenes content related to video production, enhancing community engagement.
Video description

Aula do Curso de Algoritmos criado pelo professor Gustavo Guanabara para o portal CursoemVideo.com. Download de pacotes e curso com certificado GRÁTIS: http://cursoemvideo.com/course/curso-de-algoritmos/ Curso em Vídeo Site: http://www.cursoemvideo.com YouTube: http://www.youtube.com/cursosemvideo Facebook: http://www.facebook.com/cursosemvideo Twitter: http://twitter.com/cursosemvideo Google+: http://plus.google.com/112666558837414979080 Patrocínio HOSTNET: http://www.hostnet.com.br