Data structure

Day-1 16/6(Introduction)

  • It is used in designing

  • It is abstract data type

  • It has some set of rules that we cannot change

  • We uses DS for abstract data type

  • What is data structure? Defination -> working -> real life example

  • In computer terms a ds is a specific way to store and organize data in computers memory so that these data can be used efficiently later

  • It belong to structuring the data

  • Need of Data Structure

    • Effiency

    • Reusability

    • Abstraction

  • There is two types of DS

    • Linear

    • Non-Linearas

  • Linear

    • Array

    • Queue

    • Stack

    • Linked list

  • Non Linear

    • Graph

    • Tree



Day-2 17/6(Array,Linkedlist)

Array

array

Linked List

  • It is Linear Data Structure

  • It connected via links

  • Disadventage of Array

    • Slow searching in array so linked list come

    • Inseration and deletion is slow in array

    • fixed size in array

    • memory weastage in array

  • Because of this disadvantages of array linked list is come in picture

  • In other hand linked list able to grow in size as needed

  • Does not required the shifting of items during inseration or deletion.

  • Each data value is linked with address of next value

  • Each element is called node

  • Data values need not be stored in adjacent memory cell

linkedList
linkedList
  • Structure of Linked List

  • Linked list real program

  • link = next;

linkedList
linkedList
  • Inseration in linked list

linkedList
  • Steps for creating Linked List

    • Ask user number of nodes to insert

    • Create node first

    • First check whether the linklist is empty or not, if linklist is empty this node will be first node so assign this node as head

    • Otherwise travel the linkedlist till the end and attach node at end.

    • Repeat these steps till number of nodes user entered

Assignments and code for Array and LinkedList



Day3 18/6(Operations on Linkedlist)

Operations on Linkedlist

  • Add begining linkedList

  • Add mid

linkedList
linkedList
  • Delete first node

  • Note Head is 200 in below img linkedList

  • Delete Mid Node linkedList

  • Delete last node

linkedList


Day 4 19/6(Searching algorithms)

  • Searching algorithms

    • Linear Search

    • Binary Search



Day 5 21/6(Sorting LinkedList,Doubly LinkedList)

Sorting LinkedList

linkedList
linkedList

Doubly LinkedList

linkedList


Day 6 22/6(Stack,Dynamaic Stack,Reverse String using Stack)

Stack

  • Some functions in stact

  • peak()

  • isFull()

  • push

  • pop

  • push()

  1. Check stack is full.

  2. if the stack is full produce an error and exit

  3. is the stack is not full increment top to point next empty space

  4. adds data element to the stack locationwhere top is pointing

  5. return success

linkedList
  • pop()

  1. Checks if the stack is empty

  2. if the stack is empty produce error and exit

  3. if the stack is not empty access the data element at which top is pointing

  4. decrease the value of top by 1

  5. return success

  • Push take parameter

  • pop return parameter

  • so pop always return something

Dynamaic Stack (LikeList stack)

  • Create Node class

    • data and next

    • default constructor

    • para constructor

    • getter setter

    • toString/display()

  • Create MyClass

    • having top as Node data type

    • default Constructor-assign null to top

    • implement is empty method which will return status whether stack is empty or not if top is null then stack is empty

    • push method will take data as parameter

    • pop()

    • check is stack is not empty

    • mark first node as del

    • move top to next node

    • get del.data into data

    • assign del is null if empty stack return 99999

    • display()

    • assign move=top

    • displaymove.data

    • increment or shift move to next node.

    • repeat till move !=null;

Reverse String using Stack



Day 7 23/6(C2 Stack,Queue )

C2 Stack

Queue

  • there is two element i.e front and rear

  • there is enqueue=insert and dequeue=retrive

  • Insert element

    • check whether queue is full or not

    • increment rear and insert data rear position

  • delete element

    • check whether queue is empty or not

    • increment front and return data avalible at front location

  • isEMPTY()

  • isFull() ''' public boolean isFull() { if(rear=size-1) return true; }



Day 8 24/6(Queue,Dynamic Queue,Circular Queue )

Queue

linkedList

class MyClassMyQueue {

  • rear(to insert data)

  • front (to print exit)

  • size(size of queue())

  • array }

public void enQueue(int data) {

  • check queue is not full

    • increment rear and add data at rear position

  • print queue is full }

public int deQueue() {

  • check queue is not empty

    • increment front and return data avalible at front position -return -9999 }

public int isFull() {

  • ifrear reach to size-1 }

public int isEmpty() {

  • when front and rear pointing to same index

}

public void display() {

  • from front+1 to rear display all array elements }

Dynamic Queue

queue

Circular Queue

Enqueue in circular Queue

  • check queue is not full -- if it is first element in queue increment rear and front by one add data ar rear position --- change rear and add element in array at rear position rear=(rear+1)%size; -- Print Queue is full

DeQueue element from queue --- check queue is not empty --return value at front position -- change front to next index.

Display circular Queue

-- for(int i=front; i!=rear ; i= (i+1)%size) print arr[i] print last element

front =2 rear=1

i=2 30 i=3 40 i=4 50 i=0 60 i=1 X

queue


Day 9 25/6(Dqueue)

Dqueue

pushBack() }

  • check queue is not full

  • if rear =-1

  • increament the rear and add element }

pushFront() {

  • check queue is not full

}



Day 10 26/6

Day 11 28/6(tree,AVL Tree,Binary tree types)

tree

Tree
  • Binary tree has max 2 node

  • General tree has as many node as you want

  • In binary search tree left must be less than root and right is greater than root

AVL Tree

  • Balanced Tree

Binary tree types

Full Binary tree

  • All Internal node have must 0 or 2 nodes Complete binary tree

  • Nodes are left to right only

  • Complesary need left node Perfect binary

  • All the nodes at the same level

  • Every perfect tree is complete

  • Implement binary tree

  • Create Node Class

    • data

    • left

    • right

  • class BinaryTree { root void addNode(int data) { - create node with data - check if root is null - root is newnode - assign move as root - ask where you want to attach node -left = Check if left is avalible(null) attach at left of move break; - if left is not empty - check if right pointer is null - attach node at right of move - break;

    } }

Day 12 29/6(Inorder,Preorder,Postorder,Search Element from tree,Graph)

  • Print Tree Recrusion function

Inorder (LEFT,ROOT,RIGHT)

Traversal

Preorder(ROOT,LEFT,RIGHT)

Traversal

Postorder(LEFT,RIGHT,ROOT)

Traversal
  • Recursion function saves values in stack so it print stack wise.

  • In order gives data in sorted manner

Search Element from tree

Delete Node from tree

Tree

Graph

  • Vertex

  • Edge

  • Path

  • Adjacent Node

  • in degree o0ut degree

  • sink node/Source node

Day 13 30/6(Graph,unDirectedGraph,Graph Traversa,Adjency List)

Graph

unDirectedGraph

Graph Traversa

  • DFS-depth

  • BFS-level

Adjency List

Day 14 1/7(Hash,time complixity,kruskal Algorithm,Prime's Algo,AVL Tree Balanced Factor)

Hash

time complixity

kruskal Algorithm

Prime's Algo

AVL Tree Balanced Factor

Sort



Sorting

Buebble Sort

Selection Sort

Merge Sort

Shell sort



Concept
What
Why
Where
Comment
Referance

Data Structure

A data structure is a particular way of organizing data in a computer so that it can be used effectively.

Data structures are used as a framework for organizing and storing information in virtual memory forms.

In evey application

-

-

Array

An array is a collection of items stored at contiguous memory locations.

For Storing data

in heap

-

Linked List

Linked list is linear data structure where each element is dynamically allocated. Each node contain two parts, namely the data and the reference

to overcome disadvantage of array

Data Structure(Ralilway)

-


Compiled by Shreeshail Vitkar

Feel free to fork @ C-dac Notes


Last updated

Was this helpful?