CC4 Midterms Flashcards
(112 cards)
- is a step-by-step unambiguous instruction used to solve a given problem.
o Example: A recipe that tells you exactly how to bake a cake, one step at a time.
Algorithm
o Example: A recipe that tells you exactly how to bake a cake, one step at a time.
Algorithm
- In programming, IT defines a set of values and the operations that can be performed on those values. Predefined values include integers, floats, and strings.
o Example: Integers (e.g., 1, 2, 3) are data types that represent whole numbers.
Data Types
o Example: Integers (e.g., 1, 2, 3) are data types that represent whole numbers.
Data Types
- is a way to organize and store data in a computer so that it can be accessed and modified efficiently.
o Example: Arrays, Linked Lists, Stacks, and Queues.
Data Structure
o Example: Arrays, Linked Lists, Stacks, and Queues.
Data Structure
- Refers to a type of data that is defined by its behavior (operations that can be performed on it), rather than its concrete implementation.
o Example: A stack can be represented with an array or linked list, but as an ADT, you only care about operations like push, pop, and peek.
4. Abstract Data Types (ADT)
o Example: A stack can be represented with an array or linked list, but as an ADT, you only care about operations like push, pop, and peek.
4. Abstract Data Types (ADT)
- : Data is arranged in a linear sequence (e.g., Arrays, Lists).
Linear Data Structure
- : Elements are arranged in a hierarchy or graph, such as Trees and Graphs.
Non-Linear Data Structure
- it measures how the running time of an algorithm grows with the input size. Common cases include:
o Best Case: Minimum time an algorithm takes to complete.
o Worst Case: Maximum time an algorithm takes to complete.
o Average Case: The expected running time across all possible inputs.
Time Complexity
ENUMERATE THE COMMON CASES IN TIME COMPLEXITY AND DIFFERENTIATE THEM
o Best Case: Minimum time an algorithm takes to complete.
o Worst Case: Maximum time an algorithm takes to complete.
o Average Case: The expected running time across all possible inputs.
- refers to the amount of memory an algorithm uses as it runs.
o Example: If an algorithm needs to store additional arrays or temporary variables, its space complexity increases.
Space Complexity
o Example: If an algorithm needs to store additional arrays or temporary variables, its space complexity increases.
Space Complexity
- are used to describe the performance of algorithms when the input size becomes very large. Common notations include:
o Big O (O): Describes the worst-case scenario.
o Omega (Ω): Describes the best-case scenario.
o Theta (Θ): Describes the average-case scenario.
Asymptotic Notation
ENUMERATE THE COMMON NOTATIONS AND DIFFERENTIATE THEM
o Big O (O): Describes the worst-case scenario.
o Omega (Ω): Describes the best-case scenario.
o Theta (Θ): Describes the average-case scenario.
- Data elements that are accessed one after the other in sequence (e.g., accessing elements in an array). However, it’s not always compulsory to store elements sequentially in memory.
Sequential Access
Accessing Elements in an Array
- Each element in an array can be accessed using an index. The index is a numerical value starting at 0 (for most programming languages) that represents the position of an element.
- Example:In the array arr[5] = [10, 20, 30, 40, 50], arr[2] refers to the third element, which is 30.
ADVANTAGES OF ARRAYS
- Arrays allow direct access to elements using their index, making retrieval very efficient.
- Example: Accessing the element at index 4 in an array is instantaneous and does not require searching through the rest of the array.
DISADVANTAGES OF ARRAYS
- Arrays have a fixed size and require contiguous memory space. Inserting or deleting elements can be slow because it may require shifting elements.
- Example: If you delete an element at the beginning of the array, all subsequent elements need to be shifted left.
- Arrays can have multiple dimensions, such as 2D or 3D arrays, allowing data to be stored in a matrix or grid form.
- Example: A 2D array can be visualized as a table with rows and columns (e.g., a chessboard layout).
Multidimensional Arrays
- Example: A 2D array can be visualized as a table with rows and columns (e.g., a chessboard layout).
Multidimensional Arrays
- Arrays are used to store a finite, ordered sequence of elements. This means every element in the array has a specific position or index, which allows for efficient data access based on index numbers.
Arrays as Lists
Relationship Between Values and Indexes
While arrays hold elements in an ordered sequence, there may or may not be any inherent relationship between the value of an element and its position in the array. This depends on how the array is being used.