3.1 Elementary Data Structures: Building Blocks Flashcards

1
Q

What is a data type?

A

A data type is a set of values and a collection of operations on those values.

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

What are the different basic data types available in C?

A

int, short int, long int
char
float, double

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

Give an example of an expression which uses both implicit and explicit type conversion.

A

if x and n are integers,
((float) x) / n.
x is converted to float explicitly and n is converted implicitly in order to make both the operands floats before the operation.

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

Give the formulas for calculating average (mu) and standard deviation (sigma) of a sequence x1, x2, x3…. xn.

A

average = https://getcalc.com/formula/math/average.png

standard deviation=
https://miro.medium.com/max/264/1*fWLk5NLbJ3X0farGthyxQw.png

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

How can we rewrite the formula for standard deviation to in order to calculate it in one pass through the data?

A

https://www.strchr.com/standard_deviation_in_one_pass

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

According to the principles of software development, what are the three files in which we should split our program?

A
  1. Interface - Where we define the data structure to be used and declare functions that are to be used to manipulate the data structure.
  2. Implementation - Where we define the functions declared in the interface, the actual implementation of the functions in the interface.
  3. Client - A program that uses the functions declared in the interface to work at a high level of abstraction.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to make use of the interface-implementation architecture from the client program?

A

We include the interface as a header file in the client program; and compile the implementation along with the client program before using it.

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

How can we use pointers to return multiple values?

A

Create the variables in which the return value is to be stored in the main function and pass them by reference to the given function. In the given function, store the values to be returned in these variables. Since, these values will reflect in the main function since these variables were passed by reference.

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

What is a Data Structure?

A

A Data Structure refers to a mechanism for organizing our information to provide convenient and efficient mechanisms for accessing and manipulating it.

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

Give a basic definition of arrays and lists; what is the difference between them with regards to the ease of access and manipulation?

A

Arrays are data structures in which we organize objects in a fixed sequential fashion that is more suitable for access than for manipulation.

Lists are data structures in which we organize objects in a logical sequential fashion that is more suitable for manipulation than for access.

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

What is “Numerical Tolerance”?

How to implement a comparison of floats with numerical tolerance of say upto 10^-4?

A

Numerical Tolerance means that error upto that value is acceptable.

(int) float1(10000) == (int) float2(10000)

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