Algorithms
According to Donald Knuth, a renowned computer scientist and mathematician, an algorithm is a Definite, Effective, and Finite Process that receives input and produces output.
Let's delve deeper into these terms:
Definite: Meaning the steps are clear, concise, and unambiguous.
Effective: Meaning you can perform each operation precisely to solve the problem.
Finite: Meaning the algorithm stops after a finite number of steps.
We may also add Correctness, meaning an algorithm should always produce the same output for a given input, and this output should be the correct answer to the problem the algorithm solves.
Key Terms:
Run Time: The amount of time it takes for the algorithm to complete its execution, typically measured in terms of the number of basic operations or steps performed by the algorithm.
Size of the problem: The variable n in an equation that describes the number of steps in an algorithm.
Constant Time Complexity: An algorithm is said to have constant time complexity if the value of the complexity is bounded by a value that does not depend on the size of the input. i.e., the algorithm requires the same number of steps regardless of the problem’s size.
Time Complexity: The time required by the algorithm to solve a given problem.
Best Case: The function that performs the minimum number of steps on input data of n elements.
Worst Case: The function that performs the maximum number of steps on input data of size n.
Average Case: The function that performs an average number of steps on input data of n elements.
Data Structures
Data structures are different ways of organizing, processing, retrieving, and storing data. They essentially provide a structure for data to make it easier for users to access and work with the information they need in appropriate ways.
Data structures can be broadly categorized into two main types: primitive and non-primitive.
Primitive Data Structures: These are the basic building blocks provided directly by the programming language. Examples include integers, floats, characters, strings, and booleans.
Non-Primitive Data Structures: These are more complex structures derived by combining multiple primitive data structures. They can be further classified into:
Linear Data Structures: A type of data structure that stores the data linearly or sequentially. These can be further categorized as:
Static: The size of these data structures is fixed at compile time.
Dynamic: These data structures can grow or shrink in size during the execution of a program.
Non-Linear Data Structures: Data is not stored sequentially, but rather organized in a hierarchical or interconnected manner, allowing for more complex relationships between elements. Examples include trees and graphs.