Unit 1 Fundamentals of Programming Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is an algorithm?

A

A sequence of steps that can be followed to complete a task

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

What is abstraction?

A

Abstraction involves removing unnecessary detail from a problem so that you can focus on the essentials.

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

What is decomposition?

A

Breaking a problem down into smaller sub-problems, making the overall problem easier to solve

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

Advantages of decomposition

A
  • The problem becomes easier to solve when it consists of a number of smaller subtasks or modules
  • Some modules may be reusable in other programs, saving development time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Processing

A

Any operations carried out by a computer system

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

What is a variable?

A

A variable is a location in memory in which you can temporarily store text or numbers

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

Data types

A
  • Integer
  • Real
  • Boolean
  • Character
  • String
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Integer

A

A whole number

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

Real

A

A number with a decimal point

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

Boolean

A

Can only be TRUE or FALSE

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

String

A

One or more characters enclosed in quote marks

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

Sequence

A

The statements are executed in the order they are written

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

Selection

A
  • An IF statement is a selection statement
  • The next statement to be executed depends on whether the condition being tested is true or false
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Iteration

A
  • Iteration means repetition
  • A set of statements are repeated a fixed number of times, or until a condition is met
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Three types of iteration statements

A
  • FOR…ENDFOR
  • WHILE…ENDWHILE
  • REPEAT…UNTIL
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

FOR…ENDFOR loop

A

Used when you want to execute the loop a specific number of times

17
Q

WHILE…ENDWHILE

A
  • Used when you want to execute the loop while a certain condition is true
  • The condition is tested at the beginning of the loop
18
Q

REPEAT…UNTIL

A
  • Used when you want to execute the loop until a certain condition is true
  • The condition is tested at the the end of the loop, it is always executed at least once
  • So an IF statement is needed as well as the Repeat loop
19
Q

Describe the process of a binary search

A
  • Examine the middle item of the list first and determine whether the correct data item has been found
  • If not, check whether it is before or after the current item in the data set
  • Discard the half of the data set that does not contain the item
  • Repeat the algorithm until the data item is found or it is not in the data set
  • Only works if the data items are in sequence
20
Q

Describe the process of a linear search

A
  • If the list to be searched is not sorted, it is not possible to do a binary search. A linear search may be carried out instead
  • Examine each item in turn until the item is found or the end of the data structure/file is reached
21
Q

Comparison of searches

A
  • Linear search the list can be ordered or unordered, but for a binary search the list must be ordered
  • A binary search is much more efficient than a linear search because with every iteration of the algorithm, the size of the range of items that needs to be searched decreases by half
22
Q

Explain the process of bubble sorting

A
  • Each item in a list is compared to the one next to it, and if it is greater, they swap places
  • At the end of one pass through the list, the largest item is at the end of the list
  • This is repeated until all the items are sorted
23
Q

Explain the process of a merge sorting algorithm

A
  • Divide the unsorted list into n sublists, each containing one element
  • Repeatedly merge two sublists at a time to produce new sorted sublists until there is only one sublist remaining. This is the sorted list
24
Q

Comparing merge sort to bubble sort

A
  • The merge sort requires more memory to store the sublists, and with a very large number of items this can be a disadvantage
  • Merge sort is much more efficient than the bubble sort, the bubble sort is slow and inefficient for more than a few items