Introduction Flashcards

1
Q

What are variables?

A

A way to hold data.

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

What are data types?

A

A set of data with predefined values. Examples of data types are: integer, floating point, unit number, character, string, etc.

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

At the top level, there are two types of data types. Describe them.

A
  • System-defined data types => Data types that are defined by system are called primitive data types. The primitive data types provided by many programming languages are: int, float, char, double, bool, etc. The number of bits allocated for each primitive data type depends on the programming languages, the compiler and the operating system. For the same primitive data type, different languages may use different sizes. Depending on the size of the data types, the total available values (domain) will also change.
  • User defined data types => If the system-defined data types are not enough, then most programming languages allow the users to define their own data types.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are data structures?

A

Data structure is a particular way of storing and
organizing data in a computer so that it can be used efficiently. General data structure types include arrays, files, linked
lists, stacks, queues, trees, graphs and so on.

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

Data structures are classified into two types:

A

Linear and non-linear data structures.

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

Explain linear data structures.

A

Elements are accessed in a sequential order but it is not
compulsory to store all elements sequentially. Examples: Linked Lists, Stacks and
Queues.

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

Explain non-linear data structures.

A

Elements of this data structure are stored/accessed in a
non-linear order. Examples: Trees and graphs

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

To simplify the process of solving problems, we combine the data structures with their operations and we call this ________ .

A

Abstract Data Types (ADTs).

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

An ADT consists of two parts. What are they?

A

I. Declaration of data
II. Declaration of operations

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

What is an algorithm?

A

An algorithm is the step-by-step unambiguous instructions to solve a given problem.

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

What are the two main criteria for judging the merits of
algorithms?

A

correctness and efficiency.

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

Why the analysis of algorithms?

A

Algorithm analysis helps us to determine which algorithm is
most efficient in terms of time and space consumed.

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

What is running time analysis?

A

It is the process of determining how processing time increases as the size of the problem (input
size) increases.
The following are the common types of inputs:
- Size of an array
- Polynomial degree
- Number of elements in a matrix
- Number of bits in the binary representation of the input
- Vertices and edges in a graph

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

What is rate of growth?

A

The rate at which the running time increases as a function of input.

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

Name a few commonly used rates of growth.

A

O(1) - Constant => Adding an element to the front of a linked list
O(log n) - Logarithmic => Finding an element in a sorted array
O(n) - Linear => Finding an element in an unsorted array
O(n log n) - Linear Logarithmic => Sorting n items by ‘divide and conquer’
O(n^2) - Quadratic => Shortest path between two nodes in a graph
O(n^3) - Cubic => Matrix multiplication
O(2^n) - Exponential => The Towers of Hanoi problem

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

What are the three different types of algorithm analysis?

A

Worst case, best case, and average case complexity.

17
Q

What is worst case complexity?

A

Defines the input for which the algorithm takes a long time (slowest
time to complete).

18
Q

What is best case complexity?

A

Defines the input for which the algorithm takes the least time (fastest
time to complete).

19
Q

What is average case complexity?

A

Run the algorithm many times, using many different inputs that come
from some distribution that generates these inputs, compute the total
running time (by adding the individual times), and divide by the
number of trials.

20
Q
A