Algorithm Theories Flashcards
Steps to solve programming problems
- Read the problem completely twice.
- Solve the problem manually with 3 sets of sample data.
- Optimize the manual steps.
- Write the manual steps as comments or pseudo-code.
- Replace the comments or pseudo-code with real code.
- Optimize the real code.
Solving Problems, Breaking it Down - Simple Programmer
What is an Algorithm?
Instructions (recipes) for completing a task.
Time Complexity of Select Sort
Best: O(n^2)
Average: O(n^2)
Worst: O(n^2)
Time Complexity of Quick Sort
Best: O(n log(n))
Average: O(n log(n))
Worst: O(n^2)
Time Complexity of Merge Sort
Best: O(n log(n))
Average: O(n log(n))
Worst: O(n log(n))
Time Complexity of Bubble Sort
Best: O(n)
Average: O(n^2)
Worst: O(n^2)
Space Complexity of Quick Sort
O(n)
Space Complexity of Merge Sort
O(n)
Space Complexity of Bubble Sort
O(1)
Space Complexity of Select Sort
O(1)
Space Complexity of Insertion Sort
O(1)
Time Complexity of Insertion Sort
Best: O(n)
Average: O(n^2)
Worst: O(n^2)
What is data structure?
A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data.
List out the areas in which data structures are applied extensively?
- Compiler Design,
- Operating System,
- Database Management System,
- Statistical analysis package,
- Numerical Analysis,
- Graphics,
- Artificial Intelligence,
- Simulation
What are the major data structures used in the following areas : RDBMS, Network data model and Hierarchical data model.
- RDBMS = Array (i.e. Array of structures)
- Network data model = Graph
- Hierarchical data model = Trees