Blog Computer science (lessons, class hours)

Solving algorithmic problems. Execution of a fragment of programs (10th grade)

Please.log or register Do it.
Barsukova Marina Andreevna
computerist
MBOU SOSH No. 76, Ulyanovsk

Lesson form:problem solving.
Goals:

  • to consolidate knowledge of command systems and designs of executing algorithms;
  • Create an operational style of thinking.

Tasks:
Trainers:

  • Systematization of students’ knowledge on the topic: “Algorithmization and basics of programming in the Pascal environment”.

Developing:

  • development of cognitive interest, memory, attention;
  • teach a rational way to build an algorithm;
  • Develop logical thinking.

Educational:

  • education of purposeful, competitive personality of students;
  • cultivating a respectful attitude to their work and the work of others.

Requirements for knowledge and skills:

Students should know:
What is called interpretation;
The difference between mod and div operators.
Students should be able to:
Determine the values of variables after passing the flowchart;
Determine the values of variables after passing a fragment of an algorithm written in Pascal;
- Work with the team executor of the program.

Software and didactics:

  • video projector;
  • laptop;
  • task cards.

Lesson plan

1. Organizational moment.
2. Update of knowledge on the topic: “Algorithmization and basics of programming in the Pascal environment”.
3. Studying new material.
4. Consolidation of learning.
5. Lesson review.
6. Homework.

Class progress

1. Organizational moment.
2. Update of knowledge on the topic “Algorithmization and basics of programming in the environment of Turbo Pascal”.
Frontline survey
У. Guys! We have already started to study the topic “Algorithmization and the basics of programming”, and now we will recall it a little.
1. What is the name of a clear, understandable series of commands, which allows you to perform this task.
(Algorithm)
2. What is the name of an algorithm whose actions are performed in strict order?
(Linear algorithm)
3. What is the name of an algorithm in which actions are performed depending on the fulfillment or non-fulfillment of a certain condition?
(Branching algorithm or branching)
4. What is the name of an algorithm that is performed several times?
(Cyclical algorithm or cycle)
5. What is the name of a set of instructions for a computer aimed at solving a specific task?
(Computer program)
6. What is the name of a set of values combined by a set of permissible operations?
(Data type)
7. What is the name of a sentence of a programming language that gives a complete description of an action to be performed?
(Operator)
8. How can we run a program we write in a TR environment?
(using the RanàRan command menu or the CTRL+F9 key combination)
9. Name the main forms of representation of the algorithm
(Verbal, tabular, graphic (block diagram))
10. Name the properties of the algorithm

  • discreteness (execution of the algorithm is divided into a sequence of completed actions-steps);
  • determinism (the method of solving the problem is clearly defined in the form of a sequence of steps);
  • understandability (the algorithm should not contain prescriptions, the meaning of which can be perceived ambiguously);
  • efficiency (with accurate execution of algorithm commands, the process should stop in a finite number of steps, and an answer to the problem question should be obtained);
  • mass (the algorithm works correctly on some set of initial data, which is called the domain of application of the algorithm).

11. What is the alphabet of the TP language?
(Letters of the Latin alphabet, numbers from 0 to 9, symbols)
12. Describe the main elements of programming
(Input, data, operations, output, conditional execution, subprogrammes)

Working in pairs
Ugh.Well done! Now let’s take a look at the table:
Implementation of elements of the algorithm block diagram in Pascal.
Your task is to add empty table cells to the desired operators, schemes or actions.
The implementation of block elements is an algorithm diagram in Pascal.(see annexes for the table)

Answer.
The implementation of block elements is an algorithm diagram in Pascal.(see annexes for the table)

Ugh.Now, the group that first filled out the card correctly will fill it out on the board, and you guys check your tables.
У. Which of the following descriptions can be considered algorithms and why?

  • The procedure for the safe passage of the roadway on an unregulated pedestrian crossing.
  • Traffic rules in general.
  • The method of translating decimal numbers into another number system.
  • Proof of the Pythagoras theorem.
  • The rule of spelling combinations - live and -shi - in Russian.
  • A way to solve the Rubik’s Cube puzzle.
  • Catalog of goods available for sale in the store.
  • Instructions for unpacking, installing, connecting and setting up the TV.

(1, 3, 6, 8)
3. Studying new material.
У. Now open the notebooks, write down the number, class work and the topic of our lesson.
“Solution of algorithmic problems. Implementation of the programme fragment.”
У. Let's set an example with you.
Example 1. Determine the value of the integer variable x after executing the following program fragment:

Ugh. In the flowchart there is a cycle, i.e. the same commands are repeated many times. In order not to make a mistake when executing a flowchart, it is convenient to make a table in which the values of the variables and the results of checking the conditions at each step are recorded. The sign means unequal.
Oh. Each single execution of a body cycle is called an interaction.

So, the variable x after executing this fragment of the program took the value of 5.
Answer: 5
У. Guys, think about what algorithm this flowchart corresponds to?
This block diagram corresponds to the well-known Euclidean algorithm for finding two numbers. Therefore, the answer can be obtained without formal execution of the algorithm, using, for example, the following chain of reasoning: “55 is divided entirely by 5 (on the basis of divisibility by 5); 55 = 5*11; 75 is completely by 11 is not divided, but also divided by 5, therefore, the GNR of the numbers 55 and 75 is 5.
If the appearance of the flowchart is not easy to understand which algorithm it implements, then for solving such problems should be used in a common way - step-by-step execution of the flowchart with filling in the table.

Working in groups

The children join in groups, and the teacher distributes cards with the task.

Card 1. Determine the value of the variableсAfter executing a fragment of the algorithm:

Card 2. Determine the value of the variable a after executing the algorithm fragment:

Card 3. Determine the value of the variable B after the next fragment of the algorithm is executed.

Card 4. Determine the value of variable A after performing the following algorithm:

Card 5. Determine the value of the variable s after executing the following fragment of the algorithm:

У. Let's solve the following examples. But first, let's note thatmod is a standard operation that calculates the remainder of dividing the entire first argument by the second, and div is a standard operation that calculates the result of dividing the entire first argument by the second.
Example 2. Determine the value of integer variables after executing the program fragment:

Solution. Let's make a table and fill it out.

Answer: x=2, y=5, t=5

Working in groups

Card 1. Determine the value of integer variables after executing the program fragment:
a:=42;
b:=14;
a:=a div b;
b:=a*b;
a:=b div a;

Card 2. Determine the value of integer variables after executing the program fragment:
a:=2468;
b:=(a mod 1000)*10;
a:=a div 1000+b;

Card 3. Determine the value of integer variables after executing the program fragment:

x:=4;
y:=16;
t:=x;
x:=y mod x;
y:=t+1;
Card 4. Determine the value of integer variables after executing the program fragment:

a:=37;
b:=a mod 10;
c:=a div 10;

Card 5. Determine the value of integer variables after executing the program fragment:

a:=20;
b:=7;
a:=a div b;
b:=a*b;
a:=b div a;

Ugh. Well done! You've all done your job. Now let’s remember how the team performer works and solve the following examples.

Example 3. What will the Snail draw after completing the following program?

PROGRAMME
transfer to point (2.0)
transfer to point (2,-4)
transfer to point (-2,-4)
transfer to point (-2.0)
Transfer to point (0.0).
pick up the feather
transpose
drop down
transpose
transfer to point (-1,-3)
transpose
transpose
pick up the feather
transfer to point (-2.0)
drop down
transfer to point (0.2)
transfer to point (2.0)
THE END

Example 4. A chain of three beads is formed according to the following rule:
In the first place in the chain is one of the beads A, B, B. In the second - one of the beads B, B, G. In the third place - one of the beads A, B, G, not standing in the chain in the first or second place. Which of the following chains is created according to this rule:
1) AGB 2) WAS 3) BSH 4
Solution.
In the first place in the chain is one of the beads A, B, B.
After the second condition is met, options remain:
AB, AV, AG,
BB, BB, BG,
WB, VB, VG
In the third step, the chains are formed:
ABV, ABG, AVG, AGV,
BBB, BBB, BBB, BBB, BBB, BBB, BGB, BGB, BGB
WBA, WBG, VBA, VVG, VGA
A total of 16 chains, of the four proposed, only BBG is suitable

5. Summary of the lesson
The teacher evaluates the work of the class and names the students who distinguished themselves in the lesson.

6. Homework.
Repeat the topic: "Algorithmization and basics of programming in the Turbo Pascal environment", solve problems:
1. Performer Turtle moves on the screen, leaving a trace in the form of a line. At each specific moment, the position of the performer and the direction of his movement are known. The performer has two commands:
Forward n, where n is an integer that causes the turtle to move n steps in the direction of movement.
To the right, m, where m is an integer that causes a change in direction by m degrees clockwise.
Repeat 4 [Command1Command2] means that the sequence of instructions in brackets will be repeated 4 times.
The turtle was given the following algorithm for execution:
Repeat 4 [Go 10 Right 120].
What figure will appear on the screen?

2. Determine the value of integer variables a and b after executing the program fragment:
a:= 1819;
b:= (a div 100)*10+9;
a:= (10*b–a) mod 100;

3. Determine the value of the variable a after executing the algorithm fragment.

Solving algorithmic problems

Solving algorithmic problems

Solving algorithmic problems

The presentation contains 14 slides.
In the archive lesson summary with illustrations and tables (doc) and presentation (ppt), volume of 252 Kb

download

Travel to the Land of Road Signs
Word exercises

Reactions

0
0
0
0
0
0
Already reacted for this post.

Your email address will not be published. Mandatory fields marked*