Data Structures & Algorithms for Beginners - 1


A. Big O Notation

Use Big O Notation to describe the performance of an algorithm

1. O(n) /Linear/

 

2. O(n^2) /Quadratic/

 

3. O(log n) /Logarithmic/

Example: Binary Search

 

4. O(2^n) /Exponential/

 

 

5. O(x)

 

B. Arrays

Lookup O(1)

Insert O(n)

Delete O(n)

 

Exercise: Build a Dynamic Array from Strach

Array.java (insert, remove, print)

Main.java

 

C. Dynamic Array

 

 

D. Linked Lists

LookupInsertDelete
By Value O(n)At the End O(1)From the Beginning O(1)
By Index O(n)At the Beginning O(1)From the End O(n)
 In the Middle o(n)From the Middle O(n)

 

 

Exercise: Build a Linked List from Strach

Main.java

LinkedList.java (Add Last + Add First + IndexOf + Contains + Remove First + Remove Last)