Skip to content

Commit 723a790

Browse files
committed
Data Structures
1 parent b31cda4 commit 723a790

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

DataStructures.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Data Structures
2+
3+
In computer science, a data structure is a data organization, management, and storage format that is usually chosen for efficient access to data. More precisely, a data structure is a collection of data values, the relationships among them, and the functions or operations that can be applied to the data.
4+
5+
Each programming language has its own built-in data types. JavaScript, for example, has numbers, strings, booleans etc and some more obscure ones like undefined and null. And each language has data structures to organise these data types.
6+
7+
8+
There are many types of data structures, some common and many less common.
9+
10+
### Common Data Structures
11+
12+
- Arrays
13+
- Stacks
14+
- Queues
15+
- Linked Lists
16+
- Trees
17+
- Tries
18+
- Graphs
19+
- Hash Tables
20+
21+
### Algorithms
22+
23+
- Sorting
24+
- Dynamic Programming
25+
- BFS + DFS (Searching)
26+
- Recursion
27+
28+
### Operations on data structures
29+
30+
Each data structure has its trade offs. Some are suited to certain operations and others are suited to other operations.
31+
32+
- <b>Inserting</b> - Add an element in the given data structure
33+
- <b>Deleting</b> - Remove an element from the given data structure
34+
- <b>Traversing</b> - Loop through each element in the given data structure
35+
- <b>Searching</b> - Find a particular element in the given data structure
36+
- <b>Sorting</b> - Rearrange the elements in the given data structure
37+
38+
## Arrays
39+
40+
Arrays (sometimes called lists) organize items sequentially and have the smallest footprint of any data structure. If all you need is to store some data and iterate over it, arrays are the best choice.
41+
42+
### Array method performance
43+
44+
Different array methods take different amounts of time to complete their operations.
45+
46+
- O(1) = A single operation
47+
- O(n) = One operation per element in the array
48+
49+
| Method | Description | Time complexity |
50+
| ----------- | ----------- | ----------- |
51+
| arr.push() | Add items to the end | O(1) |
52+
| arr.pop() | Removes an item from the end | O(1) |
53+
| arr.unshift() | Add items to the start | O(n)
54+
| arr.shift() | Removes an item from the start | O(n)
55+
| arr.splice() | Inserts, removes or replaces items | O(n)

0 commit comments

Comments
 (0)