This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| *************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. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ******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. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ***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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ***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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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. | |
| *******Algorithm********: | |
| 1. [Initialize] Set K:=1 and LOC :=0 | |
| 2. Tepeat Steps 3 and 4 while LOC =0 and K<=N. | |
| 3. IF ITEM = DATA[K],then :Set LOC :=K. | |
| 4. Set K:= K+1.[Increments counter.] | |
| [End of Step 2 loop.] | |
| 5. [Successful?] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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]. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |