Unit 2 :Introduction to Algorithm Flashcards

(42 cards)

1
Q

Pseudocode

A

Pseudocode is an artificial and informal language that helps programmers develop algorithms.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Basic Elements of the algorithm?

A

The basic elements of an algorithm are sequence, selection, and iteration.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Sequence?

A

the order in which behaviors and commands are combined in a project in order to produce the desired result.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Selection?

A

is the use of conditional statements in a project. Conditional statements such as [If then], or [If then else] affect the project flow of a VEXcode VR project.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Iteration?

A

algorithms often use repetition to execute steps a certain number of times, or until a certain condition is met. This is also known as “looping.” Iteration can change the project flow by repeating a behavior a specified number of times or until a condition is met.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Input?

A

a function that allows us to ask a user to enter some data and returns a reference to the data in the form of a string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Output?

A

The output values are the solution to the problem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

process statements?

A

There are three basic constructs in an algorithm: Linear Sequence: is the progression of tasks or statements that follow one after the other. Conditional: IF-THEN-ELSE is a decision that is made between two courses of action. Loop: WHILE and FOR are sequences of statements that are repeated a number of times.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Problems?

A

a problem is a task to be performed.
It is best thought of in terms of inputs and matching outputs. A problem definition should not include any constraints on how the problem is to be solved.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

INPUT STATEMENT PSUDOCODE?

A

The INPUT statement describes the arrangement of values in an input record.
EX. infile inclass; input name $ sex $ age height weight; These statements tell IML the following: There are five variables: NAME, SEX, AGE, HEIGHT and WEIGHT.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Assignment statement?

A

Assigning a value to a variable is indicated in pseudocode using an arrow symbol (←). The arrow points from the value being assigned to the variable it is being assigned to.
Also, use = to assign

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Output Statement?

A

indicates that an output will appear on the screen

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

IPO CHART/PROCESS TABLES?

A

The IPO (Input, Processing & Output) chart can be used to analyze a problem. This is a table with three columns, which represent three components: input, output, and processing. The storage component is not shown.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

INDENTATION PROCEDURES?

A

All statements showing “dependency” are to be indented. These include while, do, for, if, and switch.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

NAMING CONVENTIONS?

A

Variable names are capitalized, and function names are written in all capital letters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

CAMEL CASING?

A

In the camel case, you start a name with a LOWERCASE letter. If the name has multiple words, the later words will start with a capital letter:
EX.iPod” and “GaGa.”
startTheProgram

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

PASCAL CASE?

A

PascalCase is a naming convention in which the first letter of each word in a compound word is capitalized.
EX.FirstName
LastName

18
Q

Flowline symbol

19
Q

Terminal Symbol:

20
Q

On-page Connector Symbol

21
Q

Input / Output Symbol:

A

PARALLELOGRAM

22
Q

Process SYMBOL

23
Q

Decision Symbol:

24
Q

Off-page Connector Symbol

A

PART SQUARE AND TRIANGLE

25
PREPARATION/DECLARATION
parallelogon LONG DIAMOND
26
ARE YOU ABLE TO CONVERT FROM PSEUDOCODE TO FLOWCHART?
YES
27
FLOWCHART TO PSEUDOCODE?
YES MISS SAID TO DO IT EXACTLY AS IT IS SHOWN ONLY USE WHAT IS SHOWN
27
FLOWCHART TO PSEUDOCODE?
YES MISS SAID TO DO IT EXACTLY AS IT IS SHOWN ONLY USE WHAT IS SHOWN
28
IF-THEN-ELSE
IF condition THEN sequence 1 ELSE sequence 2 ENDIF
29
WHILE(loop)
WHILE condition sequence ENDWHILE
30
CASE
A CASE construct indicates a multiway branch based on conditions that are mutually exclusive. Four keywords, CASE, OF, OTHERS, and ENDCASE, and conditions are used to indicate the various alternatives.
31
CASE FORMAT
CASE expression OF condition 1 : sequence 1 condition 2 : sequence 2 ... condition n : sequence n OTHERS: default sequence ENDCASE
32
CASE EXAMPLE
CASE grade OF A : points = 4 B : points = 3 C : points = 2 D : points = 1 F : points = 0 ENDCASE
33
REPEAT-UNTIL
REPEAT-UNTIL This loop is similar to the WHILE loop except that the test is performed at the bottom of the loop instead of at the top. Two keywords, REPEAT, and UNTIL are used.
34
REPEAT-UNTIL
REPEAT sequence UNTIL condition
35
FOR
This loop is a specialized construct for iterating a specific number of times, often called a "counting" loop. Two keywords, FOR and ENDFOR are used.
36
FOR FORMAT
FOR iteration bounds sequence ENDFOR
37
FOR EXAMPLE
FOR each month of the year (good) FOR month = 1 to 12 (ok) FOR each employee in the list (good) FOR empno = 1 to listsize (ok)
38
IS THE ALGORITHM EASY?
IF YOU PRACTICE
39
) Write a psedocode algorithm to read a set of positive integers (terminated by 0) and print their average as well as the largest of the set.
40
) Write a Pseudocode algorithm to read the names and ages of ten (10) people and print the name of the oldest person. Assume that there are no persons of the same age. Data is supplied in the following form: name, age, name age etc.
41
Write a Pseudocode algorithm to print a conversion table from miles to kilometers. The table ranges from 5 to 100 miles in steps (1 mile = 1.61 kilometers).