Skip to content

Instantly share code, notes, and snippets.

View shimucse's full-sized avatar
🎯
Focusing

Rabia shimucse

🎯
Focusing
View GitHub Profile
package recursive;
import java.util.Scanner;
public class Recursive {
public int recur(int n)
{
if(n==1)
{
package stringreduction;
import java.util.Scanner;
public class StringReduction {
public void reductioin(StringBuffer str)
{
package stack;
import java.util.Stack;
public class STACK {
public void POP(Stack STACK, int TOP)
{
if(TOP==0)
@shimucse
shimucse / ALGORITHM:::Linear Search
Created October 12, 2016 10:55
(Linear Search) LINEAR(DATA, N,ITEM,LOC)
@shimucse
shimucse / ALGORITHM: : :Bubble Sort
Created October 12, 2016 09:07
(BUbble Sort) BUBBLE(DATA,N)
Here DATA is an array with N elements. This elements.This algorithm sorts the elements in DATA.
1. Repeat Steps 2 and 3 for K=1 to N-1.
2. Set PTR:=1.[Initializes pass pointer PTR.]
3. Repeat while PTR<=N-K:[Executes pass.]
(a) If DATA[PTR]>DATA[PTR] and DATA[PTR +1].
Interchange DATA[PTR] and DATA[PTR+1].
[End of IF structure.]
(b) Set PTR:=PTR+1.
[End of inner loop.]
[End of Step 1 outer loop.]
@shimucse
shimucse / ALGORITHM::::Deletes the Kth element from a linear array LA
Created October 12, 2016 08:11
Deletes the Kth element from a linear array LA and assigns it to a variable ITEM.
Algorithm 4.3::
(Deleting from a Linear Array) DELETE(LA,N,ITEM)
Here LA is a linear array with N elements and K is positive interger such that K<=N.This algorithm deletes the Kth element from LA.
1. Set ITEM:=LA[K].
2. Repeat for J=K to N-1:
[Move J+1st element upward.] Set LA[J]:= LA[J=1].
[End of loop.]
3. [Reset the number N of elements in LA.] Set N:=N-1;
4. Exit.
@shimucse
shimucse / ALGORITHM: : : Inserting into a Linear Array
Last active May 16, 2023 20:50
(Inserting into a Linear Array) INSERT(LA,N,K,ITEM).
Algorithm:::
Here LA is a Linear Array with N elements and K is a positive integer such that K<+N. This algorithm inserts an element ITEM into the Kth
position in LA.
1. [Initialize counter.] Set J:=N.
2. Repeat Steps 3 and 4 while J>=K.
3. [Move Jth element downward.] Set LA[J+1]:= LA[j].
4. [Decrease counter.]Set J:= J-1.
[End of Step 2 loop.]
5. [Insert element.] Set LA[K]:=ITEM.
@shimucse
shimucse / ALGORITHM::::TRAVERSING LINEAR ARRAYS
Created October 12, 2016 06:19
(Traversing a Linear Array) Here LA is a linear array with lower bound LB and upper bound UB.This algorithm traverses LA applying an operation PROCESS to each element of LA.
Algorithm::
1. [Initialize counter.] Set K:= LB.
2. Repeat Steps 3 and 4 while K<=UB.
3. [Visit element.] Apply PROCESS to LA[K].
4. [Increase counter.] Set K:=K+1.
[End of step 2 loop.]
5. Exit.
****CODE******
package algorithmicnotation;
@shimucse
shimucse / ALGORITHM::::PATTERN MATCHING
Created October 12, 2016 05:40
(Pattern Matching) P and T are strings with lengths R and S, respectively, and are stored as arrrays with one character per element. This algorithm finds the INDEX of P in T
Algorithm::
1. [Initialize] Set K:=1 and MAX:=S-R+1.
2. Repeat Steps 3 to 5 while K<=MAX:
3. Repeat for L=1 to R: [Tests each character of P.]
If P[L]!=T[K+L-1]. then: Go to Step 5.
[End of inner loop.]
4. [Success.] Set INDEX =K, and Exit.
5. Set K:= K+1.
[End of Step 2 outer loop.]
6. [Failure.] Set INDEX=0.