Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ffab19e

Browse files
Update README.md
1 parent df80e97 commit ffab19e

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

‎README.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ An **array** is a fundamental data structure used for storing a **sequence** of
2525

2626
### Time Complexity of Basic Operations
2727

28-
- **Access**: \(O(1)\)
29-
- **Search**: \(O(1)\), \(O(n)\) assuming unsorted array
30-
- **Insertion**: \(O(1)\)for the end, \(O(n)\) for beginning/middle
31-
- **Deletion**: \(O(1)\)for the end, \(O(n)\) for beginning/middle
32-
- **Append**: \(O(1)\)amortized, \(O(n)\) during resizing
28+
- **Access**: $O(1)$
29+
- **Search**: $O(1),ドル $O(n)$ assuming unsorted array
30+
- **Insertion**: $O(1)$ for the end, $O(n)$ for beginning/middle
31+
- **Deletion**: $O(1)$ for the end, $O(n)$ for beginning/middle
32+
- **Append**: $O(1)$ amortized, $O(n)$ during resizing
3333

3434
### Code Example: Basic Array Operations
3535

@@ -66,15 +66,15 @@ public class ArrayExample {
6666

6767
### Advantages
6868

69-
- **Speed**: Arrays provide \(O(1)\) access and append operations when appending at a known index (like the end).
69+
- **Speed**: Arrays provide $O(1)$ access and append operations when appending at a known index (like the end).
7070

7171
- **Cache Performance**: Arrays, with their contiguous memory layout, are efficient for tasks involving sequential data access.
7272

7373
### Disadvantages
7474

7575
- **Size Limitations**: Arrays have a fixed size after allocation. Resizing means creating a new array, leading to potential memory overhead or data transfer costs.
7676

77-
- **Mid-Array Changes**: Operations like insertions or deletions are \(O(n)\) due to necessary element shifting.
77+
- **Mid-Array Changes**: Operations like insertions or deletions are $O(n)$ due to necessary element shifting.
7878

7979
### Considerations
8080

@@ -89,7 +89,7 @@ public class ArrayExample {
8989

9090
### Answer
9191

92-
**Indexing** refers to accessing specific elements in an array using unique indices, which range from 0 to \(n-1\) for an array of \(n\) elements.
92+
**Indexing** refers to accessing specific elements in an array using unique indices, which range from 0 to $n-1$ for an array of $n$ elements.
9393

9494
### Key Concepts
9595

@@ -99,13 +99,13 @@ Arrays occupy adjacent memory locations, facilitating fast random access. All el
9999

100100
#### Memory Address Calculation
101101

102-
The memory address of the \(i\)-th element is computed as:
102+
The memory address of the $i$-th element is computed as:
103103

104-
\[
104+
$$
105105
\text{Memory Address}_{i} = P + (\text{Element Size}) \times i
106-
\]
106+
$$
107107

108-
Here, \(P\) represents the pointer to the array's first element.
108+
Here, $P$ represents the pointer to the array's first element.
109109

110110
### Code Example: Accessing Memory Address
111111

@@ -141,15 +141,15 @@ This ordering provides various benefits, such as **optimized search operations**
141141

142142
### Advantages
143143

144-
- **Efficient Searches**: Sorted arrays are optimized for search operations, especially when using algorithms like Binary Search, which has a \(O(\log n)\) time complexity.
144+
- **Efficient Searches**: Sorted arrays are optimized for search operations, especially when using algorithms like Binary Search, which has a $O(\log n)$ time complexity.
145145

146146
- **Additional Query Types**: They support other specialized queries, like bisection to find the closest element and range queries to identify elements within a specified range.
147147

148148
- **Cache Efficiency**: The contiguous memory layout improves cache utilization, which can lead to faster performance.
149149

150150
### Disadvantages
151151

152-
- **Slow Updates**: Insertions and deletions generally require shifting elements, leading to \(O(n)\) time complexity for these operations.
152+
- **Slow Updates**: Insertions and deletions generally require shifting elements, leading to $O(n)$ time complexity for these operations.
153153

154154
- **Memory Overhead**: The need to maintain the sorted structure can require extra memory, especially during updates.
155155

@@ -163,11 +163,11 @@ This ordering provides various benefits, such as **optimized search operations**
163163

164164
### Time Complexity of Basic Operations
165165

166-
- **Access**: \(O(1)\).
167-
- **Search**: \(O(1)\)for exact matches, \(O(\log n)\) with binary search for others.
168-
- **Insertion**: \(O(1)\)for the end, but usually \(O(n)\) to maintain order.
169-
- **Deletion**: \(O(1)\)for the end, but usually \(O(n)\) to maintain order.
170-
- **Append**: \(O(1)\)if appending a larger value, but can spike to \(O(n)\) if resizing or inserting in order.
166+
- **Access**: $O(1)$.
167+
- **Search**: $O(1)$ for exact matches, $O(\log n)$ with binary search for others.
168+
- **Insertion**: $O(1)$ for the end, but usually $O(n)$ to maintain order.
169+
- **Deletion**: $O(1)$ for the end, but usually $O(n)$ to maintain order.
170+
- **Append**: $O(1)$ if appending a larger value, but can spike to $O(n)$ if resizing or inserting in order.
171171

172172
---
173173

@@ -182,15 +182,15 @@ This ordering provides various benefits, such as **optimized search operations**
182182

183183
- **Adaptive Sizing**: Dynamic arrays adjust their size based on the number of elements, unlike fixed-size arrays.
184184
- **Contiguous Memory**: Dynamic arrays, like basic arrays, keep elements in adjacent memory locations for efficient indexed access.
185-
- **Amortized Appending**: Append operations are typically constant time. However, occasional resizing might take longer, but averaged over multiple operations, it's still \(O(1)\) amortized.
185+
- **Amortized Appending**: Append operations are typically constant time. However, occasional resizing might take longer, but averaged over multiple operations, it's still $O(1)$ amortized.
186186

187187
### Time Complexity of Basic Operations
188188

189-
- **Access**: \(O(1)\)
190-
- **Search**: \(O(1)\)for exact matches, \(O(n)\) linearly for others
191-
- **Insertion**: \(O(1)\)amortized, \(O(n)\) during resizing
192-
- **Deletion**: \(O(1)\)amortized, \(O(n)\) during shifting or resizing
193-
- **Append**: \(O(1)\)amortized, \(O(n)\) during resizing
189+
- **Access**: $O(1)$
190+
- **Search**: $O(1)$ for exact matches, $O(n)$ linearly for others
191+
- **Insertion**: $O(1)$ amortized, $O(n)$ during resizing
192+
- **Deletion**: $O(1)$ amortized, $O(n)$ during shifting or resizing
193+
- **Append**: $O(1)$ amortized, $O(n)$ during resizing
194194

195195
### Code Example: Java's 'ArrayList': Simplified Implementation
196196

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /