Showing posts with label Data Structure And Algorithm. Show all posts
Showing posts with label Data Structure And Algorithm. Show all posts

Monday, 24 June 2019

Binary Search


Binary Search

Step1: Start
Step2: Initialize [BEG, END, ITEM, LOC, DATA]
Step3: BEG=LB
             END=UB
             MID= int ((BEG+END)/2) set
Step4: if BEG≤END And
            DATA[MID]≠ITEM then 5& 6 Looping
Step5: if ITEM< DATA [MID] then
          END=MID-1 set
          Else:
          BEG=MID+1 set
Step6: MID= int ((BEG+END)/2) set
Step7: DATA[MID]=ITEM then
                   LOC=MID set
                   Else:
                   LOC=Null set
Step8: Algorithm End

Search Largest Element (Location & Value) in data Array


Search Largest Element (Location & Value) in data Array
Step1: Start
Step2: Set k =1, LOC =1 & MAX = DATA [1]
Step3: Set K = K+1
Step4: if K>N, then print LOC, MAX and Exit;
Step5: if MAX<DATA[K], then Set
          LOC=K &MAX =DATA[K]
Step6: go to Loop step-3
Step7: End

Smaller Element(Location & Value) in data Array


Smaller Element in data Array

Step1: Start
Step2: Set k =1, LOC =1 & MIN = DATA [1]
Step3: Set K = K+1
Step4: if K>N, then print LOC, MIN and Exit;
Step5: if MIN> DATA[K], then Set
          LOC=K &MIN =DATA[K]
Step6: go to Loop step-3
Step7: End

Traversing a Linked List


                     Traversing a Linked List

Step1: Start
Step2: Set PTR= START
Step3: while PRT=NULL, then Loop step 4 & 5
Step4: Process: INFO[PTR]
Step5: Set PTR = Link[PTR]
Step6: End

Deleting Node from Linked List


                             Deleting Node from Linked List

Step1: Start
Step2: if LOCP = NULL then, set
          START = LINK[START]
          Else, Set LINK[LOCP]: LINK[LOC]
Step3: Set LINK[LOC] = AVAIL & AVAIL = LOC
Step4: Return

Inserting node at the begging of linked list


Inserting node at the begging of linked list

Step1: Start
Step2: if AVAIL =NULL then,
                   Print “Overflow”
Step3: Set New = AVAIL & AVAIL = LINK [AVAIL]
Step4: Set info[NEW]=item
Step5: LINK [New]= START
Step6: Set START = NEW
Step7: End

Insertion Sort


Insertion Sort

Step1: Start
Step2: Set A (0)=-----------------∞
Step3: K=2,3…………………N, Loop Step 4 to 6
Step4: Set, Temp= A[K] & PTR=K-1
Step5: while Temp<A[PTR], then Looping- set,
a)    A[PTR+1] = A[PTR]
b)   PTR=PTR-1
Step6: Set A [PTR+1] = Temp
Step7: Return

Saturday, 22 June 2019

Quick Sort

Quick Sort
Step1: Start
Step2: Top=Null
Step3: if N>1 then set, Top=Top+1
                    Lower [1] = 1&Upper [1] =N
Step4: while Top≠ Null, Loop Step 5 & 8
Step5: Set, beg=Lower[Top], end=Upper[Top] &
Top=Top-1
Step6: call: Quick (A, N, beg, end, Loc )
Step7: if beg<Loc-1 then, Top=Top+1,
                   Lower[Top]= beg & Upper[Top]=Loc-1
Step8: if end>Loc+1 then, Top=Top+1,
                   Lower[Top]=Top+1 & Upper[Top]=end
Step9: End

Bobble Sort

Bobble Sort

Step1: Start
Step2: K=1 to N-1 while Loop Step 3 & 4
Step3: Set PTR=1
Stpe4: while PTR≤N-K, Looping
Step5: if DATA [PTR]>DATA[PTR+1] then,
                   Swapping DATA[PTR] & DATA[PTR+1]
Step6: PTR=PTR+1
Step7: End

Friday, 21 June 2019

Linear Searching


Linear Searching



Step1: Start
Step2: Set DATA[N+1] = item
Step3: Set Loc =1
Step4: while DATA[Loc] item then
                   Set Loc=Loc+1
Step5: If Loc=N+1 then
                   Set Loc=0
Step6: End

Factorial number use Recursion function


Factorial number use Recursion function



Step1: Start
Step2: if N=0 then
                   Set Fact=1 and Return
Step3: Call: Factorial (Fact, N-1)
Step4: Set Fact=N*Fact
Step5: End

Deleting Data in Queue

Deleting Data in Queue



Step1: Start
Step2: If Front=Null then
                   Print “underflow”
Step3: set Q[Front]=item
Step4: If Front=Rear then
                   Set Front =Null & Rear=Null
                   Else-If Front= N then
                   Front=Front+1
Step5: End

Thursday, 13 June 2019

Inserting item into a Queue

Inserting item into a Queue


Step1: Start
Step2: if Front=1&Rear=N then            
           Print “Overflow”

Matrix Multiplication Algorithm

Matrix Multiplication Algorithm:

Step1: Start
Step2: i=1 to M, loop step 3 to 5
Step3: j= 1 to N, loop step 4 to 5

Traversing a linear Array

Traversing a linear Array


Step1: Start
Step2: set K=LB
Step3: while K<= UB, then loop step 4&5
Step4: Process: LA[K]
Step5: End


Deleting item from a Stack algorithm


Deleting item from a Stack algorithm



Step1: Start
Step2: if Top=MAX STACK then
                  Print “Overflow”
Step3: set Top=Top+1
Step4: set STACK [Top]=item
Step5: Return

Inserting item into a stack algorithm

Inserting item into a stack algorithm



Step1: Start
Step2: if Top=MAX STACK then
                  Print “Overflow”
Step3: set Top=Top+1
Step4: set STACK [Top]=item
Step5: Return

Deleting item from Linear Array Algorithm

Deleting item from Linear Array Algorithm:

Step1: Start
Step2: set item=LA[K]
Step3: Loop J=K to N-1
Step4: set LA[J]=LA[J+1]
Step5: set N=N+1
Step6: End

Data Inserting into linear Array Data Structure Algorithm

Data Inserting into linear Array Data Structure Algorithm:

  • Step1: Start
  • Step2:   set   J=N
  • Step3: while J>=K, Loop step 4 & 5