Skip to content

Instantly share code, notes, and snippets.

View shimucse's full-sized avatar
🎯
Focusing

Rabia shimucse

🎯
Focusing
View GitHub Profile
@shimucse
shimucse / ALGORITHM: : :This algorithm replace every occurrence of P in T by Q
Created October 11, 2016 17:20
A text T and patterns P and Q are in memory. This algorithm replace every occurrence of P in T by Q
*************Algorithm 3.2:**********
1. [Find index of P.] Set K:= INDEX(T,P)
2. Repeat while K!=0:
(a) [Replace P by Q] Set T := REPLACE(T,P,Q).
(b) [Update index.] Set K := INDEX(T,p).
[End of loop.]
3. Write:T.
4. Exit.
@shimucse
shimucse / ALGORITHM String : : : Delete every occurrence of P in T.
Created October 11, 2016 13:43
A text T and a pattern P are in memory.This algorithm deletes every occurrence of P in T.
******Algorithm:**********
1. [Find index of P.]Set K:= INDEX(T,P).
2. Repeat while K!=0 { in java if no index found then it return -1,so we will use -1 instead of 0}
(a) [Delete P from T]
Set T:= DELETE(T, INDEX(T,P), LENGTH(P))
(b) [Update index.] Set K:= INDEX(T,P).
[End of loop.]
3. Write:T.
4. Exit.
SUBSTRING:
SUBSTRING('TO BE OR NOT TO BE',4 , 7) = 'BE OR N'
SUBSTRING('THE END',4,4) = ' END'
INDEX:
T = 'HIS FATHER IS THE PROFFSSOR'
INDEX(T, 'THE')=
INDEX(text,pattern)
CONCATENATION:
@shimucse
shimucse / ALGORITHM:::SUBALGORITHM::- The following procedure SWITCH interchanges the values of AAA and BBB
Created October 11, 2016 10:25
The following procedure SWITCH interchanges the values of AAA and BBB
***Algorithm 2.6: ***
SWITCH(AAA, BBB)
1. Set TEMP := AAA, AAA := BBB and BBB :=TEMP.
2. Return.
The procedure is invoked by means of a call statement. For example, the Call statement
Call SWITCH(BEG, AUX)
***CODE***
package algorithmicnotation;
@shimucse
shimucse / ALGORITHM::: SUBALGORITHM::: subalgorithm MEAN finds the average AVE of the threee numbers.
Last active October 11, 2016 10:11
Subalgorithm MEAN finds the average AVE of the threee numbers A, B and C .
***Algorithm 2.5:**
1. MEAN(A, B,C)
2. Set AVE:= (A+B+C)/3.
3. Return(AVE).
The subalgorithm MEAN is invoked by an algorithm in the same way as a function subprogram is invoked by
a calling program.For example, suppose an algorithm contains the statement
Set TEST := MEAN(T1, T2,T3)
@shimucse
shimucse / ALGORITHM::: Linear Search
Created October 11, 2016 09:25
(Linear Search) A linear array DATA with N elements and a specific ITEM of information are given. This algorithm finds the location LOC of ITEM in the array DATA or sets LOC=0.
@shimucse
shimucse / ALGORITHM : : :The solution of the quadratic equation
Created October 11, 2016 07:04
The solution of the quadratic equation ax^2 +bx +c, where != 0, are given by the quadratic formula x = (-b +-√(b*b -4*ac))/2a
Algorithm 2.2:(Quadratic Equation) This algorithm inputs the coefficients A,B,C of a
quadratic equation and outputs the real solutions , if any.
Step 1. Read A,B,C.
Step 2. Set D:= B*B - 4AC.
Step 3. If D>0, then:
(a) Set X1 := (-B +√D)/2A and X2:=(-B - √D)/2A.
(b) Write:X1, X2.
Else if D=0, then:
(a) Set X:= -B/2A.
@shimucse
shimucse / ALGORITHM::: Find Max number and its position from data array
Last active October 11, 2016 07:05
An array DATA of numerical values is in memory.We want to find the location LOC and the value MAX of the largest element of DATA.Given no other information about DATA, one way to solve the problem is as follows:-
Algorithm:
(Largest Element in Array)A nonempty array DATA with N numerical values is given.
This algorithm finds the location LOC and the value MAX of the largest element of DATA.The variable K is used as a counter.
Step 1. [Initialize] Set k:=1, LOC:=1 and MAX:= DATA[1].
Step 2. [Increment cunter] Set K:=:K+1.
Step 3. [Test counter.] IF K>N, then:
Write:LOC, MAX, and Exit.
Step 4. [Compare and update.]If MAX<DATA[k], then:
Set LOC:=K and MAX:= DATA[K].
@shimucse
shimucse / package jmultipleimageload;
Last active July 21, 2016 09:41
Displaying Multiple Image Using MediaTracker and Using ImageIcon
package jmultipleimageload;
import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JPanel;
@shimucse
shimucse / package jimageload
Created July 21, 2016 06:29
Displaying an single using ImageIcon
package jimageload;
import java.awt.BorderLayout;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;