Data Structures Prelim Exam
Time complexity
- The running time or execution time of a data structure as a function of the length of the input. - It's a type of computation complexity that describe the time your algorithm needs to be executed. It should be as small as possible because the more time your data structure takes, it will decrease its efficiency. - It is measured by calculating the iteration of loops, number of comparisons etc.
Data Structures & Algorithms
- They are two of the most important aspects of computer science
Space Complexity
- When an algorithm or data structure runs on your computer, it needs some sort of space/memory. - The total memory space your data structure needs for its execution or to work properly. - It should be as small as possible for data structures because it's one of the important factors in efficiency.
File
- a collection of records of the entities in a given entity set.
Record
- is a collection of field values of a given entity.
Data value
- refers to single unit of values.
Attribute & Entity
- that which contains certain attributes or properties, which may be assigned values.
Data
- values or set of values.
Total correctness
-The algorithm receives valid inputs and gets terminated, and always returns the correct output. We can prove this formal reasoning or mathematically, for instance, by proof by induction.
Data Structure
- A systematic way to organize data in order to use it efficiently.
Why we need to study DSA
- DSA enables you to solve real-world problems - DSA helps in writing Optimized Code - DSA opens up the path to becoming a Computer Scientist - Improves Adaptability to Emerging Tech Stacks - Helps you crack the top tech companies
Group items
- Data items that are divided into sub items
Elementary items
- Data items that cannot be divided
Correctness
- Data structure implementation should implement its interface correctly. - This property is related to the algorithm of data structures. - It's important that the algorithm is correct. - It means that the algorithm always produces the expected output or follows the ground truth for the range of valid inputs, and eventually, it terminates. It is important because you're relying on it for the desired output.
Interface
- Each data structure has this. - It represents the set of operations that a data structure supports. - It only provides the list of supported operations, type of parameters they can accept and return type of these operations.
Entity Set
- Entities of similar attributes
Algorithm
- Is a step-by-step procedure, which defines a set of instructions to be executed in a certain order to get the desired output. - They are generally created independent of underlying languages, i.e. it can be implemented in more than one programming language.
Partial correctness
- The algorithm receives valid input and gets terminated. We can prove it through empirical analysis or by testing it on a few cases.
Correctness, Time Complexity, Space Complexity
3 Characteristics Of A Data Structure
Search, sort, insert, update, delete
5 important categories of algorithms
Unambiguous
Algorithm should be clear and unambiguous. Each of its steps (or phases), and their inputs/outputs should be clear and must lead to only one meaning.
Finiteness
Algorithms must terminate after a finite number of steps.
Input
An algorithm should have 0 or more well-defined inputs.
Output
An algorithm should have 1 or more well-defined outputs, and should match the desired output.
Independent
An algorithm should have step-by-step directions, which should be independent of any programming code
Time
It means the number of memory accesses performed, the number of comparisons between integers, the number of times some inner loop is executed, or some other natural unit related to the amount of real time the algorithm will take.
Feasibility
Should be feasible with the available resources.
Priori Analysis
This is a theoretical analysis of an algorithm. Efficiency of an algorithm is measured by assuming that all other factors, for example, processor speed, are constant and have no effect on the implementation.
Posterior Analysis
This is an empirical analysis of an algorithm. The selected algorithm is implemented using programming language. This is then executed on target computer machine. In this analysis, actual statistics like running time and space required, are collected.
Average Case
This is the scenario depicting the average execution time of an operation of a data structure. If an operation takes ƒ(n) time in execution, then m operations will take mƒ(n) time.
Best Case
This is the scenario depicting the least possible execution time of an operation of a data structure. If an operation takes ƒ(n) time in execution, then the actual operation may take time as the random number which would be maximum as ƒ(n).
Worst Case
This is the scenario where a particular data structure operation takes maximum time it can take. If an operation's worst case time is ƒ(n) then this operation will not take more than ƒ(n) time where ƒ(n) represents function of n.
Data Search, Processor Speed, Multiple Requests
common problems that applications face now-a-days
Auxiliary space
extra space occupied is also known as?
Implementation
provides the internal representation of a data structure. it also provides the definition of the algorithms used.
Field
− A single elementary unit of information representing an attribute of an entity.