Theory aspects Flashcards

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

What does an identifier table contain ?

A
  • It contains a list of variable names
  • Their data types
  • Descriptions of what they are used for
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is abstraction ?

A

Abstraction is the process of filtering out any information which isn’t relevant to the solution and only focusing on information which is essential to the solution.

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

What are the benefits of abstraction ?

A
  • It makes the solution easier to design/implement/solve
  • So the solution can be designed/implemented faster
  • The system is tailored to the need of the user
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a run-time error ?

A

When an invalid operation is performed like dividing by zero, entering an infinite loop or stopping unexpectedly

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

What is decomposition ?

A

It is the process of breaking down a complex problem into smaller parts till each sub-task can be implemented as a program module. This makes the program easier to understand and solve.

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

What are the benefits of decomposition ?

A
  • It makes the problem easier to understand and solve
  • It makes the program easier to program/test and debug
  • It makes the time taken to produce the code decrease since the sub-tasks can be given to different teams so the problem can be solved module by module separately.
  • It helps identify program modules, sub-routines and repeated elements.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is step-wise refinement ?

A

Also called the Top-Down Design, it is the process of breaking down a task to a level of sufficient detail. By splitting the large task into smaller sub-tasks which can be implemented as program modules, the level of detail of the design is increased and so the individual tasks are easier to solve and the code is produced.

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

What are the benefits of step-wise refinement ?

A
  • It makes the program easier to understand and solve
  • It makes the program more manageable
  • The time taken to produce the code reduces
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is an algorithm ?

A

It is a solution to a problem expressed as a sequence of defined steps

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

What are the four basic constructs ?

A
  • Sequence
  • Selection
  • Iteration
  • Assignment
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is sequence ?

A

It is the execution of instructions in a fixed order.

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

What is selection ?

A

It is testing a condition to determine the sequence of execution.

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

How does an efficient bubble sort algorithm help ?

A

It reduces the number of unnecessary comparisons between elements.

  • It achieves this by reducing the number of items to be checked by one after each pass
  • It uses a flag variable to stop the outer loop when no more swaps are made on a single pass of the inner loop
  • It resets the flag before the inner loop starts and sets it whenever a swap is performed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is iteration ?

A

It is when a group of statements is executed repeatedly based on a condition.

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

What is assignment ?

A

It is when a value is given to a variable

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

What are the three main stages of an algorithm

A
  • Input
  • Process
  • Output
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is the purpose of a record ?

A

It can store a set of related data of different data types under one identifier.

It makes it easier to read and understand the code
It makes it easier to access and extract an element

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

What are the advantages of using records ?

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

Why is a file needed ?

A
  • So that the data can be permanently stored
  • The data is saved after the program is run so even when the computer is switched off the data is still stored
  • So the data can be accessed next time the program is run
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Why should an array be used to store data ?

A
  • All the data can be stored under a single identifier so less declaration statements are needed
  • It is easier to understand/maintain/modify the data
  • It makes the program easier to test/debug
  • It is easier to access the individual elements
  • It is easier to search and sort the data as you can iterate through it
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is the index ?

A

A numerical indicator of a data item’s position in an array.

22
Q

What is the upper bound ?

A

The maximum value of the index in an array.
The index of the last element in an array .

23
Q

What is the lower bound ?

A

The minimum value of the index in an artray.
The index of the first element in an array.

24
Q

How does IDE help debug a program and find errors ?

A

The programmer could set multiple breakpoints throughout the code to stop the program at that point and then check the report window for any unexpected or incorrect variable values. Once the area where the fault is occurring is determined by the programmer he can use single stepping to run the program line by line and again check the report window to determine what is causing the function to return an unexpected value.

25
Q

What are the advantages of using built-in functions ?

A
  • Since they don’t have to be written by the programmer, it saves development time.
  • It is pre-compiled and pre-tested so it is more reliable and there are reduced chances of error
  • It is available to all programs
  • May perform a complex task that a programmer wouldn’t be able to write the code for by themselves
26
Q

Why should programs be constructed using modules ?

A
  • It makes the program easier to understand and manage
  • The subroutines can be independently tested and debugged
  • The program is easier to maintain
27
Q

When do you use post-condition loop ?

A

Whenever the block of code has to be executed at least once.

28
Q

How do you declare a constant in pseudocode ?

A

CONSTANT Name = “value”

29
Q

What are the pros of using constants ?

A
  • One change in the value , where it is initialized will reflect that change throughout the program
  • Since one change is reflected throughout the code, the same value does not have the be repeatedly written.
  • The value of the constant cannot be accidentally changed
  • This helps minimize programming errors.
30
Q

How do you minimize the risk of programming errors ?

A
  • Use tried and tested subroutines
  • Use modular programming techniques to break the problem down and make it easier to solve
  • Good programming practices like sensible variables names and comments.
  • IDE features like auto-complete and debugging methods
31
Q

What is a syntax error ?

A

A statement in the code which breaks the grammatical rules of the language

32
Q

What is a logic error ?

A

An error in the algorithm that causes the program to not behave as intended

33
Q

Why are parameters used with subroutines ?

A
  • To pass values to the subroutine
  • To allow recursion
  • To produce reusable code
  • To avoid global variables
34
Q

What is an ADT ?

A

An Abstract Data Type is a collection of data and a set of operations on those data.

35
Q

What is a stack ?

A

It is a list containing several items operating on the Last in, first out (LIFO) principle. The first item added to a stack is the last item to be removed from the stack.

36
Q

What are the features of a stack ?

A

In a stack,

  • Each stack element contains one data item
  • There is only one pointer which points to the end of the stack
  • Data is added at the back and removed from the back
  • It operates on a LIFO basis
37
Q

How is a stack implemented ?

A

The stack is implemented by,

  • Declaring a 1D array of type string
  • Here, the number of elements in the array corresponds to the size of the required stack
  • Declare a variable of type integer for the StackPointer.
  • Declare a variable of type integer for the MAX value of StackPointer
  • Use the StackPointer as an index to the array
  • Pointers and Variables are initialized to indicate an empty stack
  • Each stack item maps to one array element
  • Describe Push and Pop operations
  • The Push and Pop operations need to check for full or empty conditions before execution
38
Q

What is a queue ?

A

It is a list containing several items operating on the first in, first out (FIFO) principle. The first item added to a queue is the first item to be removed from the queue.

39
Q

What are the features of a queue ?

A

In a queue,

  • Each queue element contains one data item
  • One pointer points to the front/start of the queue
  • One pointer points to the back/End of the queue
  • Data is added at the back and removed from the front, it works on a FIFO basis
  • It may be circular and wrap around
40
Q

How is a queue implemented ?

A

The queue is implemented by,

  • Declaring a 1D array of type given
  • Declaring an integer variable for FrontPointer
  • Declaring an integer variable for EndPointer
  • Initializing FrontPointer and EndPointer to represent an empty queue
  • Declaring an integer variable for the size of the queue to limit the maximum numbers allowed and the wrap around
  • Initialize the size of the queue
41
Q

What is a linked list ?

A

It is a list containing several items in which each item in the list points to the next item in the list. In a linked list, a new item is always added to the start of the list.

42
Q

What are the features of a linked list ?

A

In a linked list,

  • Each node contains data and a pointer to the next node
  • A pointer to the start of the list
  • The last node in the list has a null pointer
  • Data is be added/removed by manipulating the pointers
  • Nodes are traversed in a specific sequence
  • The unused nodes are stored on a free list
43
Q

What does the null pointer mean ?

A

It means that there are no further nodes in the list

44
Q

How is a value added to a linked list ?

A

A value is added by,

  • Checking for a free node
  • Searching for the correct insertion point
  • Assigning the new value to the first node in the free list
  • Change the pointers from both ends and explain
  • The start pointer in the free list will be moved to the next free node
45
Q

What are the pros and cons of using linked lists ?

A

Pros

  • Since the pointers determine the ordering of data, only they have be changed when the data is changed
  • So it is easier to add/delete data to maintain the correct sequence in a linked list

Cons

  • You need to store the pointers as well as the data
  • It is more complex to setup and implement
46
Q

How is a linked list implemented ?

A

The linked list is implemented by,

  • Declaring two 1D arrays
  • One for the data and one for the pointers
  • Where elements from the same index represent one node
  • Declare a variable of type integer for the StartPointer
  • Declare a variable of type integer for NullPointer and give it the value of -1
  • Declare a variable of type integer for the FreeListPointer
  • Routines are needed to add/delete/search
47
Q

What are the features of pseudocode which make it easier to write and understand ?

A
  • Meaningful variable names
  • Indentation
  • Capitalization of keywords
  • Comments
  • Use of built-in functions
48
Q

Which syntax errors can’t be detected by examining a single line ?

A
  • Selection
  • Iteration
  • Incorrect block structure with missing keywords like missing END PROCEDURE
  • Data type errors
  • Using identifiers before they are declared
  • Incorrect parameter use
49
Q

What are good programming practices ?

A
  • Using meaningful variable names
  • Capitalization of keywords
  • Use of comments
  • Use of modular programming
  • Use of local variables
50
Q

What is passing a parameter by value ? (by default)

A

A copy of the data is passed and any local changes made are lost when the module is terminated/exited.

51
Q

What is passing a parameter by reference ?

A

If the value of the parameter is changed in the subroutine then this changes the original value. Basically, any changes in the subroutine are reflected outside of it as well.

52
Q
A