1.3 Algorithms Flashcards

1
Q

Describe what happens to a file when it is compressed and give two reasons why files are often compressed

A

When a file is compressed the file size is made smaller
· To send as an email attachment
· Upload to a web site
· Save storage (disc, solid state, optical, server) space

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

Fragmented meaning

A

Fragmented files are split up and stored on different parts of the disc

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

Fragmented file compared to the time it takes to access a file that is not fragmented

A

· It can take longer to access a fragmented file because there is more read/write head movement to locate all the file parts and this movement takes time.

· If a file is not fragmented then it will be stored in consecutive blocks with minimal read/write head movement.

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

Describe what happens to fragmented files when a hard disc drive is defragmented

A

When a hard disc is defragmented parts of files are physically moved closer together to reduce read/write head movement.

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

Give two reasons why it is good programming practice to use procedures (subprograms) when writing large programs.

A

It is good programming practice to use procedures when writing large programs because:
· Procedures can be re-used in other programs
· They can be tested independently before incorporating into program
· They can be used when solving problems using stepwise refinement
· They make the programs easier to read
· They make programs easier to debug

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

Explain the term recursive algorithm and briefly describe how quicksort operates

A

A recursive algorithm is one which calls itself.

It must also have a “base case” to allow it to terminate

Quicksort description:
· An item/pivot selected
· Produce two new lists of smaller and larger numbers
· Repeat above points on new sub lists (recursively) until sorted

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

A benefit, describe a situation where data compression

A

· To send as an email attachment as smaller files transfer quicker or may have maximum size of an attachment

· Upload to a web site as larger files take longer to upload or might be restrictions on maximum file size that can be uploaded

· Saving a file to disc if short on disc space or to save disc space

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

Explain how a sequential search is used to locate an element called SearchValue in an array sorted in ascending order called SearchArray

A

Starting at the beginning of the array and SearchValue is compared to every consecutive item
in SearchArray until either an item matches
SearchValue or the end of the array is reached
or an item in the array is found to be bigger than Searchvalue

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

Briefly describe what sub procedure ProcOne does.

A

Purpose of algorithm is to swap (consecutive) two elements of an array

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

Pseudo-code is often used to define algorithms. Name two other methods of defining algorithms

A

· structured English

· flowcharts

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

Describe how an insertion sort works.

A

· Items are copied/placed into a (new) array one at a time
· Each item is inserted in the correct place
· All succeeding items in the new array are moved up one place.

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

Give one reason why it is useful to standardise computer languages

A
  • program written in a certain language on one computer/environment is likely to run easily on a different computer/environment
  • programmer familiar with the language on one computer/environment is likely to be able to adapt easily to working on a different computer/environment
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Briefly describe an issue associated with standardising computer languages

A

• different manufacturers / developers approaching problem differently - may not be keen to share for commercial reasons

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

Describe the purpose and give a benefit of using subprogram libraries

A

Subprogram libraries contain utilities / common tasks, etc 1

and can be used by any user, avoiding re-writing

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

Describe the disadvantage of compiling the whole program in one operation

A
Any one of:
•   A module might be useful in another program. If it has been complied as part of a whole program, it will not be available in compiled form for the new program. 
•   If any errors are corrected /changes made, the whole program will have to be re-compiled.
•   It may be preferable to test each module before combining into the whole program / It is easier to find errors in smaller modules.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Describe what is meant by the term algorithm and name two methods of defining algorithms

A
An algorithm is a set of rules / instructions 
to solve a (specific) problem 
Any 2 of:
·   structured English 
·   flowchart
·   pseudo-code
17
Q

Explain lossy data compression techniques.

A

· Data compression reduces the file size
· When compressed files are decompressed they do not give back the original data, i.e. data is lost
· Because lossy compression cannot be decompressed to yield the exact original data, it is not a good method of compression for critical data, such as textual data
· It is most useful for digitally sampled analogue data, such as sound, video, graphics or images
· Some examples of lossy data compression algorithms are JPEG, MPEG, and MP3.
· Algorithms for lossy compression vary, but many use a threshold level truncation. / suitable lossy data compression example

18
Q

Define the term algorithm. Other than pseudo-code, state one method of expressing an algorithm.

A

An algorithm is an (unambiguous) set of instructions to solve a problem
An alternative method to pseudo code of expressing an algorithm is a flowchart / structured English

19
Q

Describe the main characteristics of a recursive algorithm

A

A recursive algorithm is one which calls itself (with a parameter which changes) and It must have a terminating condition (base case) to stop the calls

20
Q

Describe two disadvantages of using a recursive algorithm

A

· Memory overheads of stack use with many recursive procedural calls
· Difficult to program / dry run/debug if there is a fault
· Stack overflow
· Infinite loop

21
Q

Describe how bubble sort and insertion sort algorithms operate.

A

Bubble
· A number of passes is made until the data is in order.
· For each pass through the data, each value is compared with the following one and swapping them if necessary.

Insertion sort
· Items are copied one by one
· Each new item is inserted in the correct place in the output