DA110 WEEK 1

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/106

flashcard set

Earn XP

Description and Tags

WEEK 1

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

107 Terms

1
New cards

Algorithm

A

well-defined list of

finite

unambiguous steps

for solving a problem.

2
New cards

Data Structure

Defines a data collection of

data values,

logical relationship among them, and the

operations that can be applied on the data.

3
New cards

Scenario I characteristic

<p></p>
4
New cards

Scenario II characteristic

<p></p>
5
New cards

Scenario III characteristic

<p></p>
6
New cards

Scenario II

Last-in, First-out

7
New cards

Scenario III

First-in, First-out

8
New cards

Scenario IV

Hierarchical structure used to organize information based on levels of

importance or authority.

<p>Hierarchical structure used to organize information based on levels of</p><p> <span style="color: #12ff00">importance</span> or <span style="color: red">authority.</span></p>
9
New cards

Scenario V

Network Form : A type of organizational structure characterized by a decentralized network of interconnected organizations or individuals that collaborate to achieve common goals.

<p>Network Form : A type of <span style="color: yellow">organizational structure </span>characterized by a decentralized network of <span style="color: #00fff8">interconnected organizations </span>or <span style="color: #06ffeb">individuals </span>that collaborate to achieve <span style="color: red">common goals. </span></p>
10
New cards

Data Structure

Organization + Operations + Algorithm

11
New cards

Program

Data Structure + Algorithm

12
New cards

Data

Collection of raw facts

13
New cards

Data element

It is a logical unit adding up to a data.

14
New cards

Data type

It specifies the type of value or values of data elements forming a data.

15
New cards

Contiguous Memory Allocation

Pattern where the data elements of a data structure will be stored at contiguous (next or together in sequence.) memory locations in memory

<p>Pattern where the data elements of a data structure will be stored at <span style="color: yellow">contiguous (</span><span style="color: yellow">next or together in sequence.</span><span style="color: yellow">) </span>memory locations in memory</p>
16
New cards

Non-Contiguous Memory Allocation

Pattern where the data elements of a data structure will be stored at non-contiguous arbitrary locations in memory.This method allows for efficient use of memory by allocating space as needed without requiring contiguous blocks.

<p>Pattern where the data elements of a data structure will be stored at non-contiguous arbitrary locations in memory.This method allows for <span style="color: yellow">efficient use of memor</span>y by allocating space as needed without requiring contiguous blocks. </p>
17
New cards

Contiguous Memory Allocation advantages

Advantages include

ordering,

Random Access Memory, and

no additional memory needed for management,

leading to efficient CPU usage and faster access times.

18
New cards

Contiguous Memory Allocation disadvantages

Disadvantages include

Static Allocation,

OS Defragmentation,

Un-used Memory and

Large RAM requirement

19
New cards

Non-contiguous Memory Allocation Advantages

Advantages include better memory utilization, reduced fragmentation, and flexibility in allocating memory blocks.

20
New cards

Non-contiguous Memory Allocation Disadvantages

Disadvantages include Additional memory is needed and Data Access may need to traverse through the other data elements.

21
New cards

Creation

Create an empty instance of a data structure.

22
New cards

Insertion

Insert a data element into an instance of a data structure.

23
New cards

Deletion

Delete a data element from an instance of a data structure.

24
New cards

Updation

Change the value of a data element

25
New cards

Searching

Search for the existence or non-existence of a data element.

26
New cards

Traversal

Visits every data element in an instance of a data structure.

27
New cards

Sorting

Order the data elements either in ascending or descending order.

28
New cards

Merging

Combines data elements of two or more data structures to one.

29
New cards

Input Specified

Input to an algorithm should be clearly specified. An algorithm can have zero or more inputs.

30
New cards

Output Specified

Output of an algorithm should be clearly specified. An algorithm has one or more outputs.

31
New cards

Definiteness

Every step of an algorithm should be unambiguous.

32
New cards

Finiteness

Every algorithm should terminate after a finite number of steps.

33
New cards

Effectiveness

The steps of an algorithm should be sufficiently basic and doable by a person in a finite time with pencil and paper.

34
New cards

Complexity of Algorithm

Includes Time Complexity and Space Complexity.

35
New cards

Classification of Data Structure

Includes Primitive vs Non-primitives, Linear vs Nonlinear, Homogeneous vs Heterogeneous, and Static vs Dynamics.

36
New cards

Non-primitives data structures

Array, Linked List, Stack and Queues, Tree/Binary tree, Hash, Graph

37
New cards

Array

A collection of a finite number of homogeneous data elements stored at contiguous memory locations.

38
New cards

INDEX

Defines the location and ordering of the data elements in an array.

39
New cards

LOWER BOUND

Defines the location of the first element in an array.

40
New cards

UPPER BOUND

Defines the location of the last element in an array.

41
New cards

SIZE (of an array)

UPPER BOUND – LOWER BOUND +1

42
New cards

Types of Array

One-Dimensional, Multi-Dimensional

43
New cards

2(two)-Dimensional array

An array of one dimensional arrays.

44
New cards

3(three)-Dimensional array

An array of two dimensional arrays.

45
New cards

Number of 1D arrays

Number of rows in a 2D array.

46
New cards

Number of Columns

The number of elements in each 1D array

47
New cards

Size of 2D arrays

|Columns| x |Rows|

48
New cards

Size of 3D array

|Plates| x |Columns| x |Rows|

49
New cards

BASE address

The address of the first element in memory

50
New cards

𝐸𝑓𝑓𝑒𝑐𝑡𝑖𝑣𝑒 𝐴𝑑𝑑𝑟𝑒𝑠𝑠 𝑜𝑓 𝐴 𝑖 for 1D arrays

A = 𝑏𝑎𝑠𝑒 𝑎𝑑𝑑𝑟𝑒𝑠𝑠 + (𝑖 − 𝐿𝐵) × 𝑘

51
New cards

Row major order

Arranging the elements in memory row-wise.

52
New cards

Column major order

Arranging the elements in memory column-wise.

53
New cards

Address of 𝐴 𝑖 𝑗 for 2D arrays in Row major order

𝐴𝑑𝑑𝑟𝑒𝑠𝑠 𝑜𝑓 𝐴 𝑖 𝑗 = 𝐵𝑎𝑠𝑒 𝑎𝑑𝑑𝑟𝑒𝑠𝑠 + 𝑖 − 𝐿𝐵𝑅 × 𝐶𝑜𝑙 + 𝑗 − 𝐿𝐵𝐶 𝑘

54
New cards

Address of 𝐴 𝑖 𝑗 for 2D arrays in Column major order

𝐴𝑑𝑑𝑟𝑒𝑠𝑠 𝑜𝑓 𝐴 𝑖 𝑗 = 𝐵𝑎𝑠𝑒 𝑎𝑑𝑑𝑟𝑒𝑠𝑠 + 𝑗 − 𝐿𝐵𝐶 × 𝑅𝑜𝑤 + 𝑖 − 𝐿𝐵𝑅 𝑘

55
New cards

Operations on Array Data Structure

Create, Display/Traverse, Search, Deletion, Modification/Update, Insertion

56
New cards

Create Operation

It creates an empty Array, allocates the required memory in RAM

57
New cards

Two ways to create an array in C

Static memory allocation during compile time or dynamic memory allocation during run time.

58
New cards

Compile time

The memory is reserved at compile time.

59
New cards

Run time

Created using a function called malloc.

60
New cards

Display/Traversal Operation

Visit all the elements in the array

61
New cards

Search Operation

Given an element, check if it is present in the array

62
New cards

Time Complexity

Worst Case: The element is not found or found at the last index. Time complexity is 𝜃(𝑛)

63
New cards

Insertion Operation

Insert an element at an arbitrary index 𝑖 ≥ 0.

64
New cards

Deletion Operation

Delete an element from an arbitrary index 𝑖 ≥ 0.

65
New cards

Update Operation

Replace the value at 𝑖 ≥ 0 by another value.

66
New cards

Sparse Matrix

A special type of matrix with a relatively high proportion of zero elements.

67
New cards

Some Special Sparse Matrix

Triangular Matrices, Diagonal and Tri-diagonal Matrices

68
New cards

Task for Left Lower Triangular Matrix

Store only the non-zero elements in memory

69
New cards

𝐴 of A[ i ][ j ] for the Left Lower Triangular Matrix

𝑖 𝑗 = 𝑏𝑎𝑠𝑒 𝑎𝑑𝑑𝑟𝑒𝑠𝑠 + ቇ 𝑖 − 𝐿𝐵𝑅)(𝑖 − 𝐿𝐵𝑅 + 1 2 + (𝑗 − 𝐿𝐵𝐶 × 𝑘

70
New cards

Right Lower Triangular Matrix

𝑖 𝑗 = 𝑏𝑎𝑠𝑒 𝑎𝑑𝑑𝑟𝑒𝑠𝑠 + 𝑖 − 𝐿𝐵𝑅)(𝑖 − 𝐿𝐵𝑅 + 1 2 + 𝑗 − 𝐿𝐵𝐶 − (𝑈𝐵 𝑅 − 𝑖 × 𝑘

71
New cards

Diagonal Matrix

A[i][i] = base address + (i − LBR) × k

72
New cards

𝑨 for Tri-Diagonal Matrix

𝑖 𝑗 = 𝑏𝑎𝑠𝑒 𝑎𝑑𝑑𝑟𝑒𝑠𝑠 + 𝑖 − 𝐿𝐵𝑅 − 1 × 3 + 2 + (𝑗 − 𝑖 + 1) × 𝑘

73
New cards

Abstract Data Type (ADT)

Abstract data type is a way of separating the implementation of a data structure, from its usage.

74
New cards

Abstract Data Type

Is a way of separating the implementation of a data structure from its usage.

75
New cards

Abstract Data Type

Members include member data and member functions. Access specifiers include private and public.

76
New cards

Abstract Data Type Advantages

Client uses ADT without knowing internal implementation details. Implementer can update the ADT without affecting the client program.

77
New cards

Non-primitive Data Structures

Array, Linked List, Stack and Queues, Tree/Binary tree, Hash, Graph

78
New cards

Compile Time Array Creation

Static memory allocation

79
New cards

Run Time Array Creation

Dynamic memory allocation

80
New cards

Benefits of Using Abstract Data Types

Data Hiding, Inheritance and Encapsulation

81
New cards

Formula to Determine Size of 2D Arrays

Number of Columns x Number of Rows

82
New cards

Formula to Determine Size of 3D Arrays

Number of Plates x Number of Columns x Number of Rows

83
New cards

Arrays are generally _, as datatypes are the same.

Homogenous

84
New cards

Data Structures may be classified as _

Heterogenous or Homogenous

85
New cards

Arrays are since their data elements are of the same type.

Homogenous

86
New cards

Arrays are considered a data structure

Linear

87
New cards

Data Structures are classified as

Linear or Non-Linear

88
New cards

Function is uses to create Dynamic Arrays in C.

malloc()

89
New cards

Two main methods of allocating arrays in C

Compile and Run Time

90
New cards

Different Array Operations

Insert, Delete, Search, Display/Traversal, Create, Update

91
New cards

Array Search - Best Case Time Complexity

0(1)

92
New cards

Array Search - Avverage Case Time Complexity

0(n)

93
New cards

Main Purpose of an Array Search Function

Check if Element is Present and if Not Present

94
New cards

Condition for Insertion into Array

i >= 0

95
New cards

Different Steps of Array Insertion Algorithm

Free the index, Store Element, Update the # of Elements

96
New cards

Best Case Insertion Scenario Represents a _ Time Complexity

Constant

97
New cards

Last Step of Array Deletion Algorithm

Reduce UB by One -- UB = UB - 1

98
New cards

Number of Movements of Array Elements in Worst-Case Deletion Scenario

n-1 Elements Involved

99
New cards

Matrix of Relatively High Proportion of Zero Elements

Sparse Matrix

100
New cards

Two Ways to Represent and Store a Sparse Matrix in Memory

Store All Elements Including Zeroes or store only non-zero elements