Podcast
Questions and Answers
Earthquakes always happen with just one shock wave.
Earthquakes always happen with just one shock wave.
False (B)
Foreshocks are the first tremors people might notice.
Foreshocks are the first tremors people might notice.
True (A)
The weakest shock wave is known as the main shock.
The weakest shock wave is known as the main shock.
False (B)
Aftershocks precede the main shock.
Aftershocks precede the main shock.
Earthquakes can cause a lot of damage.
Earthquakes can cause a lot of damage.
New, strong buildings are the most vulnerable during an earthquake.
New, strong buildings are the most vulnerable during an earthquake.
Earthquakes can sometimes cause flooding in coastal areas.
Earthquakes can sometimes cause flooding in coastal areas.
Landslides and avalanches can occur after earthquakes.
Landslides and avalanches can occur after earthquakes.
Fires cannot occur after earthquakes.
Fires cannot occur after earthquakes.
Tsunamis can be triggered by powerful earthquakes.
Tsunamis can be triggered by powerful earthquakes.
Seismic waves are only felt within a few feet of the epicenter.
Seismic waves are only felt within a few feet of the epicenter.
Shock waves are divided into five categories.
Shock waves are divided into five categories.
The main shock records the highest score on the Richter scale.
The main shock records the highest score on the Richter scale.
Aftershocks are never as strong as the main shock.
Aftershocks are never as strong as the main shock.
Earthquakes never cause damage to roads.
Earthquakes never cause damage to roads.
Earthquakes can sweep houses, cars, and people away.
Earthquakes can sweep houses, cars, and people away.
Avalanches only occur in tropical regions.
Avalanches only occur in tropical regions.
Fires after earthquakes are often caused by frozen water pipes.
Fires after earthquakes are often caused by frozen water pipes.
Tsunamis cause minor disturbances as they wash ashore.
Tsunamis cause minor disturbances as they wash ashore.
A tsunami's wave decreases in height as it approaches the shore.
A tsunami's wave decreases in height as it approaches the shore.
Flashcards
What are foreshocks?
What are foreshocks?
The first tremors people may notice before a main earthquake.
What is a main shock?
What is a main shock?
The strongest shock wave of an earthquake, recording the highest score on the Richter scale.
What are aftershocks?
What are aftershocks?
Shock waves that follow the main shock and can be as strong as the main shock.
What are tsunamis?
What are tsunamis?
Signup and view all the flashcards
What are earthquake induced fires?
What are earthquake induced fires?
Signup and view all the flashcards
What are landslides and avalanches?
What are landslides and avalanches?
Signup and view all the flashcards
What are earthquakes?
What are earthquakes?
Signup and view all the flashcards
What is earthquake damage?
What is earthquake damage?
Signup and view all the flashcards
Study Notes
- Algorithmic complexity measures the resources an algorithm needs based on input size.
- Big O notation is used to express the upper bound of resource usage growth rate.
Time Complexity
- Time complexity measures the time an algorithm takes as a function of input size.
- Measured by the number of elementary operations.
- Common complexities:
- O(1): Constant time.
- Same time regardless of input size.
- O(log n): Logarithmic time.
- Time increases logarithmically with input size.
- O(n): Linear time.
- Time increases linearly with input size.
- O(n log n): Linearithmic time.
- Time increases linearly with input size, multiplied by a logarithmic factor.
- O(n^2 ): Quadratic time.
- Time increases quadratically with input size.
- O(2^n ): Exponential time.
- Time increases exponentially with input size.
- O(n!): Factorial time.
- Time increases factorially with input size.
- O(1): Constant time.
Space Complexity
- Space complexity measures the memory an algorithm needs as a function of input size.
- Measured by number of variables or data structures used.
- Common complexities:
- O(1): Constant space.
- Same memory regardless of input size.
- O(log n): Logarithmic space.
- Memory increases logarithmically with input size.
- O(n): Linear space.
- Memory increases linearly with input size.
- O(n^2 ): Quadratic space.
- Memory increases quadratically with input size.
- O(1): Constant space.
Big O Notation
- This is a mathematical notation describing a function's limiting behavior.
- It is used to classify algorithms by running time or space requirement growth as input size grows.
- Formal Definition:
- f(n) ≤ c·g(n) for all n ≥ n0
- f(n) is O(g(n)) if f(n) grows no faster than g(n) as n approaches infinity.
- Example:
- Expression 4n^2 + 6n - 5 is O(n^2)
Best, Average, and Worst-Case Complexity
- Best-Case: Algorithm complexity with most favorable input.
- Average-Case: Algorithm complexity averaged over inputs.
- Worst-Case: Algorithm complexity with least favorable input, provides an upper bound on resource usage and most commonly used.
Analyzing Algorithm Complexity
- Steps:
- Identify elementary operations.
- Determine how many times each is executed as a function of input size.
- Express total operations using Big O notation.
Examples
Linear Search
- Searches for a value in an unsorted array.
- Time Complexity: O(n) in the worst case.
- Space Complexity: O(1).
Binary Search
- Searches for a value in a sorted array.
- Time Complexity: O(log n).
- Space Complexity: O(1).
Bubble Sort
- Sorts an array by repeatedly comparing and swapping adjacent elements.
- Time Complexity: O(n^2).
- Space Complexity: O(1).
Conclusion
- Understanding algorithmic complexity is essential for designing efficient algorithms.
- Analyze time and space complexity to make informed decisions for best performance.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.