Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

DATA STRUCTURE

BIG-O CARES about only worst possible result/complexity

1.Array; Static and dynamic array and source code

2.Linked Lists;

Head= first node , Tail= last node , node= containers

Singly linked list = Only contains pointer to next linked node.

Uses less memory and cant access previous elements, O(n)

Doubly linked list= Contains pointer front and back ways.

Takes 2x memory .......... , O(n)


PRIORITY QUEUES AND HEAPS

HIGHER priority/smallest number comes out first

poll() means removing Highest priority and Add(2) means adding 2

HEAP ; in max heap hieghest priority goes to highest numb


UNION FIND

(Disjoint set)

Find-given an elemtn figures to which set it belongs and Union-merges two


groups together

are operations used

int[] array = {0,1,2,3,4,5,6};

union(2,5) means index 5 will become 2


Bi nary search tree

others are child nodes and at most


bottom are leaf nodes

BINARY TREE -Evert node should have most 2 children nodes(not more
than that) n uses child/parent convention

BINARY SEARCH TREE –left subtree has smaller elements and right
subtree has larger elements and subtree/tree convention

OPERATIONS

Insert

Remove
HASH TABLES

Key/value

Operation

Insert

BIG O – Timw taken to do process with given inputs


B(1) CONSTANT TIME

B(n) LINEAR TIME

1<LOGn<n<nLOGn<n^2<n^3<2^n......

Int[] array = {2,3,5,6,7}

BEST CASE ex.O(1) simplest or shortest time

WORST CASE ex.O(n) highest time

AVERAGE CASE O(sum of all possible runtimes/total possibilities)

(breaking down 8) 8421 this is (base 2) log8=3

Solving questions

1) Drop non dominating terms


2) Drop the constant terms
3) Break the code in fragements

You might also like