CHAPTER 4 - COMPUTATIONAL THINKING Flashcards

1
Q

Algorithm

A

a series of unambiguous instructions designed in order to solve a problem and achieve a certain goal in a finite number of steps

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

Explain how data is sorted by the selection sort

A

Selection sort is a sorting algorithm that sorts data by dividing the array into two sub-arrays: the first one containing already sorted data and the second contains the unsorted elements of the array. At the start, the sub array containing the list of sorted elements is empty while the sub array containing the unsorted data refers to the entire array. The algorithm continues by finding the smallest/largest element in the array and exchanges it with the leftmost unsorted element, to put it in a sorted order. The algorithm then moves the first sub array borders one element to the right and repeatedly does this until the whole array is sorted

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

Outline one difference between a bubble sort algorithm and a selection sort algorithm

A

Bubble sort algorithm is a sorting algorithm that repeatedly steps through the array from the left to the right, exchanging adjacent data elements, to sort it from ascending or descending order. On the other hand, selection sort is a sorting algorithm that works by dividing the array of data into two separate sub arrays, and then exchanging the data element which is the smallest/largest with the leftmost data of the array, to sort it into either ascending/descending order.

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

Outline why a sub-program is considered an example of abstraction

A

A sub program is an example of abstraction as it breaks down the whole computer program into separate smaller programs which hides unnecessary details of specific objects within the program and speeds up the program development process. Maintaining and operating these sub programs will also be easier as they are smaller in size and can be repeatedly used throughout the entire program.

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

Evaluate the use of designing and developing different parts of software products concurrently.

A

The process of designing and developing different parts of a program concurrently means creating program modules all at the same time by multiple processors to achieve the fastest development progress. This helps reduce development time and time to release the program, bringing improved productivity and lower costs. Additionally, any concerns/errors regarding the program can be solved instantly during the design process.

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

Outline one way in which users can be informed of software updates.

A

Users can be reminded by software updates through email or SMS messages online. The program’s support team can remind users of software updates (e.g. bug fixes) by contacting their email addresses or sending messages through their phone numbers, in case they add the information in their account details.

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

For an identified application, explain why a binary search would be preferred to a linear search.

A

Binary search refers to a searching algorithm which relies on the divide and conquer strategy to accomplish its purpose whereas, linear search relies on brute force strategy and does not require the use of ordered elements (sorted arrays). Linear search is fairly simple compared to binary search, however for large data sets, it operates far slower compared to binary search. This is because linear search finds an element in the list by searching it subsequently until it is found in the list while binary search uses the middle value in the list repeatedly until the middle element is matched with a searched element.

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

Properties of an algorithm

A
  • Finiteness: must always terminate after a series of steps
  • Definiteness: every step of the algorithm must be precisely defined
  • Input: quantities which are given to it initially before the algorithm begins
  • Output: quantities which have a specified relation to the inputs
  • Effectiveness: all operations performed must be sufficiently basic that they can be done exactly in a finite number of time by pen and paper
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Explain about variables

A

A variable is used to store a data element of a program. The stored value can be changed during the program execution. It also has a name (or identifier) and a type.

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

Thematic map

A

A thematic map is an abstraction of reality that shows the spatial distribution and emphasizes a particular theme, such as the average distribution of income in a specific geographic area.

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

Topographic map

A

Topographic maps show abstractions of selected physical features of the three dimensional real world at a reduced scale in two-dimensions, paper or a screen

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

Political maps

A

Political maps are designed to show data such as the boundaries of countries, states and the location of major cities.

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

Explain about object-oriented programming

A

Object-oriented programming uses abstraction, and is based on the principle that all everyday tasks can be considered as entities. These entities are either objects or events.

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

Define abstract thinking

A

Abstract thinking means reflecting on events, ideas, attributes and relationships in a general manner that hides all unnecessary details of specific objects. For example, a concrete thinker may identify and count two cats and two cars, while an abstract thinker may identify their common relationship which is the number two.

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

Define collections

A

A collection is an object that assembles and contains a lot of elements in a single structure.

For example, queues and stacks. It is also used to add, store, manage, retrieve, manipulate, and communicate the data using predefined methods.

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

Sequential/linear search

A

A sequential/linear search algorithm is a very simple method to find a particular element in an array. The implementation of this algorithm does not require the use of ordered elements (sorted arrays). It relies on brute force strategy to accomplish its purpose.

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

Binary search

A

Binary search/half interval search algorithm is a searching method used only in sorted arrays. It relies on divide and conquer strategy to accomplish its purpose.

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

Define bubble sort

A

Bubble sort is a simple sorting algorithm that repeatedly steps through the array to be sorted. It compares adjacent items (pairs of adjacent array elements) and exchanges them if they are not in the correct order (ascending or descending). The algorithm makes multiple passes until no swaps are necessary and the elements of the array are sorted.

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

Define selection sort

A

Selection sort is a very simple and inefficient sorting algorithm that divides the array into two sub-arrays: the first sub-array contains the already sorted elements, and the second sub-array contains the unsorted elements and occupies the rest of the array. The algorithm continues by finding the smallest/largest element in the sub-array that contains the unsorted elements, exchanging it with the leftmost unsorted element (located in the lowest index position) and putting it in sorted order. The algorithm then moves the first sub-array borders one element to the right.

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

Define an array and give one example of an array

A

An array can hold multiple data elements of the same type (integers, strings, boolean etc). It has a name, a size that cannot be changed during program execution (in most cases is a static data structure) and a data type that describes the type of data that it can store. For example: int array [10] = { 32, 33, 34, 35, 49, 19, 21, 58, 20, 42 }

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

Explain why abstraction is required in the design of algorithms

A

Abstraction refers to reflecting on ideas, events or attributes in a general manner that hides all unnecessary details of specific objects. This is required as it speeds up the designing process and helps programmers have a general idea of the problem. This would help them further develop proper solutions/algorithms to the problem.

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

Explain the importance of using coding style and naming conventions when programming

A

Coding style helps programmers make source codes that are organized and easily readable. It also helps programmers focus on sources of errors that may appear throughout their code. Additionally, naming conventions help programmers easily identify functions or attributes in the source code and differentiate between the types of variables and parameters in their code.

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

Ways to express an algorithm

A
  • simple english
  • flow chart
  • pseudocode
  • programming language
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Sub procedure

A

a series of commands that perform a task

25
Q

Identifier

A

a name used by programmer to uniquely identify a variable, class, object, sub procedure etc

26
Q

Pseudocode

A

Pseudocode is used to help programmers develop computer programs. It is written for humans as the syntax used is not as strict as the one used in computer languages.

27
Q

Explain the importance of sub-procedures

A

A good approach for confronting a complex problem is to develop a method of breaking up the problem into smaller sub-problems. This method is very efficient because it is much easier to attack a number of sub-problem instead of a big complex problem. The resulting sub-problems can be further divided into smaller and smaller subproblems until finally they can be dealt with individually.

28
Q

Conditional statement

A

performs different instructions depending on a Boolean test; e.g. if-then-else statement

29
Q

Describe two advantages of using libraries of classes

A
  • The availability of libraries allows for the reuse of code; most software applications have the same essential functionalities. For example, the programmer may reuse the libraries of objects to allow an application to connect to a database
  • The usage of libraries also reduces the need for programmers to sort and search various collections of objects, thus reducing their time spent coding standard functionalities. Through libraries, they are able to spend more time on the parts of their applications that have to be unique
30
Q

Explain one advantage of the OOP feature “inheritance”

A

Inheritance allows new classes to be derived from an existing class, meaning that the derived classes inherit the data and actions of the existing class. When parent class actions need to be upgraded, all child classes that inherit from the parent class will automatically use the new upgraded version of these actions. This reduces maintenance overheads as an action needs only to be changed once and all the dependent child classes will use it.

31
Q

Distinguish between a class and an instantiation. You must make reference to the UML provided.

A

Classes are abstract object entities. On the other hand, the instantiation of a class refers to the process of creating an object from the class using a constructor such as “new”. For instance, class can be Cart and the instantiation of the class can be creating object: Cart obj = newCart();

32
Q

Gantt chart

A

type of bar chart named after Henry Gantt, widely used for project schedule and project management, as a way of showing activities, tasks, and events against time

33
Q

Concurrent processing

A

the execution of different instructions simultaneously by multiple processors so as to acheive the best performance

34
Q

Sequential processing

A

the execution of different instructions one at a time by a single processor

35
Q

Prefetching

A

getting data from memory into cache before they are actually needed

36
Q

Explain why an object is an example of abstraction

A

An object can be created and used for many different purposes, for instance, a program that simulates driving experience of a car or a program for car sales purposes. It is an example of abstraction as the programmer hides unnecessary details and concentrates only on properties and behaviors that are important to the object’s implementation.

37
Q

What are the features of an algorithm

A

Efficiency: amount of computer resources required to perform functions

Correctness: the extent to which the algorithm satisfies its specification and is free from faults

Reliability: capability of an algorithm to maintain predefined level of performance

Flexibility: effort required to modify the algorithm for other purposes than what has been initially developed

38
Q

What is a constant

A
  • Non modifiable variables
  • Things and quantities that don’t change during execution of the program
39
Q

What is an operator

A

Manipulate operands; “+”, “*” etc

40
Q

What is an object

A

Comprised of data and actions
Entities used to represent real life objects and its behaviors

41
Q

What is a compiler

A
  • “compile”
  • Translator that executes the translation process only once
  • Translates the whole source program into the object program
  • Object program is saved and the programmer would not need to recompile again
42
Q

What is an interpreter

A

“Interpret”
- Execute translation process each time the program is run
- Reading each line of the source program and, Analyzing it and translating it into the corresponding object program and executing the line

43
Q

Difference between fundamental operations and compound operations

A

Fundamental operations do not require the processor to go through a large number of sub operations to reach a result. For example, adding two numbers.

Compound operations involve a number of stages/other operations to form an operation. For example, finding the maximum value of four numbers

44
Q

Advantages of breaking a program into subprograms

A

Distributing a very large programming problem among various programmers all over the world
Enable code reuse across multiple programs
Breaking down complex programming jobs into simple jobs

45
Q

Advantages of using collections

A

Predefined algorithms that programmer can immediately use
Performance is increased by data management capabilities provided by the collection
Software reuse is facilitated because the use of methods is based on common language and standard interface

46
Q

Decomposing a problem

A

into several related objects and then decomposing those objects again into even simpler related objects allows for the reduction of the complexity of a problem and as such makes it easier to deal with.

47
Q

Association

A

A Company object employs one or more Person objects.

48
Q

Dependency

A

“Uses” relationship
One object is dependent on one or more objects in order to function
If one object ceases to exist, the other cannot function

49
Q

Aggregation

A

“Has a” relationship
One object belongs to another object and none other
If one object ceases to exist, the other object still can function/exist

50
Q

Inheritance

A

“Is a” relationship
One object is a specialized form of another object (child class and parent class)
sub/child class inherit the data and actions of the super/parent class

51
Q

What is a parameter

A

Name of the information that is used in a method, function or procedure
E.g. public void customer(String name, String location, int age) -> the bracket is parameter

52
Q

What is an argument

A

Value that is passed into a method, function or procedure
E.g. a.customer(name:”Lisa, location: “Jakarta”, age:”18”); -> were a is object name and customer is class

53
Q

What is polymorphism

A

The same object or class or function can have different functionalities/behave differently in different scenarios

54
Q

Advantages of polymorphism

A

Subclasses can have their own unique actions and be able to override or improve parent actions

Code reusability: inherit all parent data and actions without rewriting code; can alter actions deem necessary

55
Q

What is encapsulation

A

Inclusion of data and actions into a single component
Their structure is hidden in class and can only be accessible externally through specific methods

56
Q

Advantages of encapsulation

A

Data in class can only be made read or write only
Class restrict the way that its data and actions can be altered or called
Easier to maintain as changes to data and actions can take place without being apparent on the outside as long as still accessible

57
Q

Advantages of inheritance

A

Extensibility: after inheriting data and actions, child classes may add new functionalities extending the parent’s actions and data

Reusability: inheriting child classes will not need to be altered incase the inherited action/data needs to be upgraded; when parent class actions are upgraded, all child classes inherit from the parent class will automatically use the new upgraded version of these actions (reduce maintenance overheads)

58
Q
A