0% found this document useful (0 votes)
118 views

Algorithm Book Saadany PDF

The document discusses how human innovation and problem solving has led to the development of computer programs and technology over time. It explains that whenever humans face challenges or needs, they think of creative solutions that were unknown to their ancestors. Some examples provided include the development of railroads to aid transportation, communication advancements like newspapers, radio, TV and internet, and warning systems after natural disasters. The document argues that this innate human ability to invent new solutions is part of human nature and has allowed civilization to progress since the beginning of humankind.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
118 views

Algorithm Book Saadany PDF

The document discusses how human innovation and problem solving has led to the development of computer programs and technology over time. It explains that whenever humans face challenges or needs, they think of creative solutions that were unknown to their ancestors. Some examples provided include the development of railroads to aid transportation, communication advancements like newspapers, radio, TV and internet, and warning systems after natural disasters. The document argues that this innate human ability to invent new solutions is part of human nature and has allowed civilization to progress since the beginning of humankind.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 91

:

""

anti-virus

microsoft word

: .

2013/10/16

4

:

.1

.2

.3

.4

.5

(:

) (...

7170

2 ................................................ ................................
5 ....................................................
5 ...................................................
5 ...........................................
6 ...........................
8 ................................................................ ................................
12 ...........................................................
13 .................... ................................................................
13 ..................................................

13 ...........RAM(Random Access Memory)

14 ............................... Central Processing Unit

15 ............................................................................ Devices

15 .................................. ................................

17 ................................................... ................................
20 .................... ................................................................
20 .............................................................................Bit

21 ........................................................................... Byte

21 ...............................................
23 ...............................................

8
23 ............................................... ................................

24 .............................................. ................................

27 .................... ................................................................
27 ................................
29 .................................
30 .............................................................................
32 .........................
33 .........................
33 ..........................
35 ..........................
36 ..........................
36 ..........................
38 ...............................................
41 ......................................
42 ...................... ................................
43 .................... ................................................................
44 .................... ................................................................
45 ................................................... ................................
48 .........................................................
49 ..................................... ................................
49 .................................. ................................

9
50 .............................................. ................................
50 .................................... ................................
52 ..................................... ................................
52 ....................................................................... Variables
54 ............................................................................
55 ...........................................................................
58 ................................................... ................................
59 ................................................... ................................
60 .............................................. ................................ /
60 ...........................Arithmetic operators

63 ....................... String Concatenation operators

64 ........... Increment and Decrement Operators

65 .............................................. Comparison operators

67 ................................................. Logical operators

70 ................................................. ................................
74 .......................................................................
76 ....................................................................... Loops
76 ......... ................................while

78 ............................................ for

81 ................................................. ................................ Arrays


85 ..................................... ................................

10
87 ............................................
88 .............................Copying Arrays
91 ............................................................. ................................

11

12

/

(...

Hardware

Software

.Hardware

):RAM(Random Access Memory

.Address

13
1

:Central Processing Unit

) (

14
:Devices

: ... . Input devices

:Output Devices ... .

:Storage Devices

... .

0 ) 1

" "2 "

"Binary Language

0 1

" "

0 1 .

15


) (
Binary encoding 0 1
Decimal encoding )
: 0 (9
.

16

) (9 8 7 6 5 4 3 2 1 0

3 :

10 2897 :

2 8 9 7

1000 = 10 * 100
2 * 1000 = 2 * 10 * 100
2000 = 2 * 1000

8 :

17
100 = 10 * 10

8 * 100 = 8 * 10 * 10

800 = 8 * 100

9 :

10 = 10 * 1

9 * 10 = 9 * 10 * 1

90 = 9 * 10

1=1*1

7*1=7*1*1

7=7*1

2897:

)2897 = (2 * 1000) + (8 * 100) + (9 * 10) + (7 * 1

2897 = (2 * 10 * 10 * 10) + (8 * 10 * 10) + (9 * 10) + 7

18
:

)2897 = (2 * 103) + (8 * 102) + (9 * 101) + (7 * 100

103 10*10*10=1000
102 10*10=100
101 10
100 1

19

Bit

Bit

0 .1

.1 : )(0 or 1

.2 22 : ) (0 and 0

) (0 and 1 ) (1 and 0 )(1 and 1

.3 (2*2*2*2) 24 : 16:

0000 0001 0010 0011


0100 0101 0110 0111
1000 1001 1010 1011
1100 1101 1110 1111

Byte 1 Byte = 8 Bits

28 256 .

2N . N )(bit

20
Byte

1 KiloByte (KB) = 210 Byte = 1024 Byte

1 MegaByte (MB) = 210 KiloByte = 1024 KiloByte

1 GegaByte (GB) = 210 MegaByte = 1024 MegaByte

1 TeraByte (GB) = 210 GegaByte = 1024 GegaByte

2 10110010 :

21
)10110010 = (1 * 27)+(0 * 26)+(1 * 25)+(1 * 24)+(0 * 23)+(0 * 22)+(1 * 21)+(0 * 20
:
)10110010 = (1 * 128)+(0 * 64)+(1 * 32)+(1 * 16)+(0 * 8)+(0 * 4)+(1 * 2)+(0 * 1
:
)10110010 = (128)+(0)+( 32)+( 16)+(0)+(0)+( 2)+(0
:
10110010 = 178

:
(10110010)8 = (178)10

101010 :

)(101010)2 = (1 * 25)+(0 * 24)+(1 * 23)+(0 * 22)+(1 * 21)+(0 * 20


)(101010)2 = (32)+(0)+(8)+(0)+(2)+(0
(101010)2 = (42)10

22

:

2 .

423 :
423 2
1 21 2
11 10 2
51 52 2
0 26 2
0 13 2
1 6 2
0 3 2
1 2
1
1
0

(423) 10 = (110100111) 2

23

57 2
1 28 2
0 14 2
0 7 2
1 3 2
1 1 2
1 0

(57)10 = (111001)2

20 1
21 2
22 4
23 8
24 16
25 32

24
26 64
27 128
28 256
29 512
210 1024

423

28 * 1 = 423
167 = 256 423
27 *1 = 167
39 = 128 167
26 * 0 = 39
25 * 1 = 39
7 = 32 39
24 * 0 = 7
23 * 0 = 7
22 * 1 = 7
3=47
21 * 1 = 3
1 = 2 - 3
2 0 * 1 =1

(423) 10 = (110100111) 2

25
26 :

24 * 1 = 26
10 = 16 - 26
23 *1 = 10
2 = 8 10
22 * 0 = 2
21 * 1 = 2
0=22
2 0 * 0 =0
:

(26)10 = (11010)2

26

Bits

Byte .1 Byte=8 Bits

16

) 2( "" Word

DWord Double Word

4 Bytes 32 .32 Bits

.7 6 5 4 3 2 1 0

(15)10 = 8 + 7

)(15)10 = (1 * 81)+(7 * 80

(15)10 = (17)8
27
:

)(153)10 = (128) + (24) + (1

)(153)10 = (2 * 82) + (3 * 81) + (1 * 80

(153)10 = (231)8

) 8(340 :

)(340)8 = (3 * 82) + (4 * 81) + (0 * 80

)(340)8 = (3 * 64) + (4 * 8) + (0 * 1

)(340)8 = (192) + (32) + (0

(340)8 = (224)10

28


0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111

1001110:

:
1001110 = 1 001 110

1 1 6

(1001110)2 = (116)8

29
:

= (100111001110)2 100 111 001 110

= (100111001110)2 4 7 1 6

(100111001110)2 = (4716)8

(234)8 = 010 011 100

(234)8 = (10 011 100)2

16

)(9 8 7 6 5 4 3 2 1 0

)( f e d c b a

.16 15 14 13 12 11:

30
16

(10011100)2 = (9C)16

(11110100011001011)2 = (1E8CB)16

(1100000101011111001110110)2 = (182BE76)16



1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 A
11 B
12 C
13 D
14 E
15 F

31

16

)23 = (1 * 161) + (7 * 160

(23)10 = (17)16

__________________________________

)145 = (9 * 161) + (1 * 160

(145)10 = (91)16

)367 = (1 * 162) + (6 * 161) + (15 * 160


15
2 1 0
) 367 = (1 * 16 ) + (6 * 16 ) + (15 * 16 ) F
)367 = (1 * 162) + (6 * 161) + (F * 160 (
(367)10 = (16F)16

32

:
)(54)16 = (5 * 161) + (4 * 160
)(54)16 = (80) + (4
(54)16 = (84)10
----------------------------------------
)(89)16 = (8 * 161) + (9 * 160
)(89)16 = (128) + (9
(89)16 = (137)10
----------------------------------
)(F3D)16 = (15 * 162)+(3 * 161) + (13 * 160
)(F3D)16 = (3840) + (48) + (13
(F3D)16 = (3901)10

0 0000 8 1000
1 0001 9 1001
2 0010 A 1010
3 0011 B 1011
4 0100 C 1100
5 0101 D 1101

33
6 0110 E 1110
7 0111 F 1111

= (100110111101)2 1001 1011 1101

9 B D

(100110111101)2 = (9BD)16

_________________________________________________________

(11101111000111000101001)2 = 111 0111 1000 1110 0010 1001

7 7 8 E 2 9

(11101111000111000101001)2 = (778E29)16

34

(3D)16 = (0011 1101)2


0011 D ) 1101 3
(

(6FE89A)16 = (0110 1111 1110 1000 1001 1010)2

(458ECB)16 = (10001011000111011001011)2

(12CFE8B74B)16 = (1001011001111111010001011011101001011)2

35

(12)8 = (001 110)2

(12)8 = (1110)2 001 1


) 2 110
(1110)2 = (E)16

(12)8 = (E)16 (20
__________________________________________________

(345)8 = (011 100 101)2

(345)8 = (11100101)2

(11100101)2 = (E5)16

(345)8 = (E5)16
_____________________________________

(2431)8 = (010 100 011 001)2

(2431)8 = (10100011001)2

(10100011001)2 = (519)16

(2431)8 = (519)16

36

(6EB)16 = (0110 1110 1011)2

(6EB)16 = (11011101011)2

25
(11011101011)2 = (3353)8

(6EB)16 = (3353)8

____________________________________________________

(EE56FD)16 = (1110 1110 0101 0110 1111 1101)2

(EE56FD)16 = (111011100101011011111101)2

(111011100101011011111101)2 = (73453375)8

(EE56FD)16 = (73453375)8

37

:1

.1 .
.2
.3
.4
.5
.6
.7

.
.8
. .9
.10
.

:2

:
1
75
12
1750
5680

38
:3
:
7
162
943
5872
761452

:4

:
100101
111100110110001
10011100000101010010
100100010011111001010010
10111001110001000000011101001011001

:5

:
56
123
6761
671512
39
13726552
:6

:
10101
1110111
1001000110
11111011101
1010101010101111010
:7
:
7
432
19827
1909725
5652414146

:8

:
99
12D
AAABBC
54F
11FFEE11D456
980FD

40



41

42

2=1+1

10=1+1

+ 0 1
0 0 1
1 1 10

1001011 1101110 10101


+1110010 + 10010 + 1001
________ ________ ______
10111101 10000000 11110
____________________________________________________________________________

11000101110101
+10100100101001
_______________
101101010011110

43

127 352

0 1 1 1

0 0

1 0 1 0

1 0 .1

44
1001 1010

) 0+1 (Bits 2 :

1 10

1 .2

1 ) 1 1 (

45
:

X 0 1

0 0 0

1 0 1

46
47

48

) (...

Pseudo Code

Comments

//

*/

*/

49

50
) (

51

//

BEGIN

//Program Instructions

END
Variables

Screen

(.

52

) (

...

53

) Runtime (

] [ _

; [DATA_TYPE] VariableName

] [ :

) ( )

( ) : ( ...

// _1 _1

// _1 _1

// _1 _1

// _ _

// __1 __1

54
; Int Number1 //Declare Integer Variable

; String Text1 //Declare String Variable

; Char Char1 //Declare Char Variable

; Date Date1 //Declare Date Variable

; Boolean Bool1 //Declare Boolean Variable

null

_ 1_ 2_ 3_4

; Int Number1, Number2, Number3, Number4


) (

55
// _ 156
_
// _ 48

; Int First_Number 156 //


; Int Second_Number
; Second_Number 48 //

_ 156

)" "( :

_ " " //

// ""

;" " String FullName //


; String Nationality
;"" Nationality //
:

56
_ 156
_
_ _

; Int First_Number 156


; Int Second_Number
; Second_Number First_Number
_ _

.156

_ _ _

_.

57

//

)" "(

//

" "

)(

//

; )" "(WRITE

//

;" " String FullName

; )WRITE(FullName

58

)" (" :

// ) _(

)" (" :

)_(

BEGIN

; String FullName

; )" "(WRITE

; )READ(FullName //

; )" WRITE(" :

; )WRITE(FullName

END

59

.:

( .

:Arithmetic operators


+
-
*
/
\
%
^

60

_ _
_ 25
_ 5

//

//
_ +_

//
_ -_

//
_ * _

//
_ /_

// Power
_ ^ _

// Modulo
_ %_

61
BEGIN
Int First_Number, Second_Number ;
First_Number 25 ;
Second_Number 5 ;

//

//
Int Sum First_Number + Second_Number ;

//
Int Substract First_Number - Second_Number ;

//
Int Multiplication First_Number * Second_Number ;

//
Int Division First_Number / Second_Number ;

// Power
Int Power First_Number ^ Second_Number ;

// Modulo
Int Modulo First_Number % Second_Number ;

END

_ _

.30 5 + 25 +

_ _

.20 5 - 25 -

62
_ _

* 5 * 25 .125

_ _

5 / 25 .5

_ _

255 .9765625

_ 25 5 .

:String Concatenation operators

+ :


_ _
_ " "
_ " "
_ +_
)(

63
BEGIN
; String Text1, Text2

; " " Text1

; " " Text2

String Concat ; Text1 + Text2

)WRITE(Concat

END

.+

:Increment and Decrement Operators


// 1

_ 25
_ _ 1+
// :
_ ++

// 1

_ 25
_ _ 1-
// :
_ --

64
BEGIN
//1

; Int First_Number 25
;First_Number First_Number + 1
//:
;First_Number++
//1

; Int Second_Number 25
;Second_Number Second_Number - 1
//:
;Second_Number--
END

:Comparison operators

(... boolean :

true false


>
<
=
><
=>
=<

65
:


// True 4 2

_ 4 > 2

// False 5 1

_ 5 < 1

// True 5 10

_ 10 <> 5

// True 20 6 .14

_ 20 = 14 + 6

BEGIN
4 True2 //

; Bool Expression1 4 > 2

5 False1 //

; Bool Expression2 5 < 1


5 True10 //

; Bool Expression3 10 <> 5

20 6 True.14 //

; Bool Expression4 20 = 14 + 6
END

66
:Logical operators

boolean : true false

AND )(

OR )(

67

// True 2 4 7 5

_ ) 2 < 4 (7 > 5

// False 3 5

_ ) 2 < 4 (3 = 5

*/

True

2 < 4

" "

*/

_ ) 2 < 4 (2 > 5

//

_ ) 2 > 4 (3 = 5

68
BEGIN
2 4 7 True5 //

; ) Bool Expression1 ( 2 < 4 AND 7 > 5

3 False5 //

; ) Bool Expression2 ( 2 < 4 AND 3 = 5

*/

True

2 < 4

" "

*/

; ) Bool Expression3 ( 2 > 5 OR 2 < 4

//

; ) Bool Expression4 ( 2 > 4 OR 3 = 5

END

69

Skype Messenger

Condition Flow

Control :

) // (

//

)// (

//


*/

*/ " "

70
BEGIN

IF ( /*Statement that can be either true or false*/) THEN


//Do Someting
ELSEIF (/* Other Condition */) THEN
//Do Someting
ELSE
//Do Someting
END IF

END

71


__ ""myUserName
__ ""MyPassword123
_
_

)" "(

)_(

)" "(

)_(

)_ = __ _ = __(
)" "(

)_ >< __ _ = __(
)" "(

)_ = __ _ >< __(
)" "(


)" "(

72
BEGIN
String SavedID " myUserName";
String SavedPWD " MyPassword123";
String ID ;
String Password ;

WRITE(";)"

READ(UserName);

WRITE(" ;)"

READ(UserName);

IF (ID = SavedID AND Password= SavedPWD) THEN

WRITE(" ;)"

ELSEIF (ID <> SavedID AND Password= SavedPWD) THEN

WRITE(" ;)"

ELSEIF (ID = SavedID AND Password<> SavedPWD) THEN

WRITE(" ;)"

ELSE (ID = SavedID AND Password<> SavedPWD)

WRITE(" ;)"

END IF
END

73

:

: .

" "JAVA " "PERL

: ) =

* (

74
.1 500 .

.2 500 1000 1 .

.3 1000 5 .

= * ) 1 (100 /

75
Loops

while

for

: :while

76
:


) */ *(/
//

BEGIN
)WHILE (Expression
//Statements
END WHILE
END


__

)" "(

)__(

)__ >< " "(


)" ! "(


)" ! (".

77
BEGIN

; String First_Khalifa

; )" "(WRITE

; )READ(First_Khalifa

" " >< WHILE First_Khalifa

; )" ! "(WRITE

END WHILE

)" ! WRITE(".

END

: :

: :for

78



1 1000
)" "(

BEGIN
; Int Count
FOR Count 1 TO 1000
; )" "( WRITE
END FOR
END

1 .

21 = 6 + 5 + 4 + 3 + 2 + 1

79


0
)" "(
)(
1
+

)" +" :(

BEGIN
; Int Number, Count
; Int Sum 0
; )" "( WRITE
; )READ(Number
FOR Count 1 TO Number
; Sum Sum + Number
END FOR
; )" + Sum WRITE(" :
END

: 1

:.


1 1 7

80
3=2+1 2 7
6=3+3 3 7
10=4+6 4 7
15=5+10 5 7
21=6+15 6 7
28=7+21 7 7

Arrays

1 2 3 4 5 6 7 8 910

;Int Num1, Num2, Num3, Num4, Num5, Num6, Num7, Num8, Num9, Num10

81

Arrays

:Value

:Index

82
Index

one-dimensional

array .


//
_ __ ][

// 7
_ __ ] [7

BEGIN
//
; ][Data_Type ArrayName

7//
; ]Data_Type ArrayName[7
END


//
__ ][

// 7
__ ] [7

83
BEGIN
//
; ][Int MarksArray

7//
; ]Int MarksArray[7
END


// 7
__ ] [7

//

// Index
__ ]" [0"
__ ]" [1"
__ ]" [2"
__ ]" [3"
__ ]" [4"
__ ]" [5"
__ ]" [6"

//
0 6
)" +" :__ ][(

84
BEGIN
7 //
; ]String WeekArray[7

//
; Int Count
//
;"WeekArray[0] " Sunday
;"WeekArray[1] " Monday
;"WeekArray[2] " Tuesday
;"WeekArray[3] " Wednesday
;"WeekArray[4] " Thursday
;"WeekArray[5] " Friday
;"WeekArray[6] " Saturday
//
For Count 0 TO 6
;)]WRITE("The Day Name Is: "+ WeekArray[Count
END FOR
END

) (

...

85
two-dimensional array

Columns :Rows

_ ] [5,4

;]Int Two_Dimensional_Array[4,5

)(0,0 )(0,1 )(0,2 )(0,3 )(0,4


)(1,0 )(1,1 )(1,2 )(1,3 )(1,4
)(2,0 )(2,1 )(2,2 )(2,3 )(2,4
)(3,0 )(3,1 )(3,2 )(3,3 )(3,4

: Index

86


//
_ ] [2,3

//
_ _

// Index
_ ]18 [0,0
_ ]14 [0,1
_ ]16 [0,2

_ ]11 [1,0
_ ]19 [1,1
_ ]20 [1,2

//
_ 0 2
_ 0 1
)" +" :_]_ _[(

87
BEGIN
//
;]Int Two_Dimensional_Array[3,2

//
; Int Count_Rows, Count_Columns

//
; Two_Dimensional_Array[0,0] 18
; Two_Dimensional_Array[0,1] 14
; Two_Dimensional_Array[0,2] 16

; Two_Dimensional_Array[1,0] 11
; Two_Dimensional_Array[1,1] 19
; Two_Dimensional_Array[1,2] 20

//
For Count_Columns 0 TO 2
For Count_Rows 0 TO 1
WRITE("The Element Is: "+
;)]Two_Dimensional_Array[Count_Columns, Count_Rows
END FOR
END FOR
END

Copying Arrays
Methods

( Clone

Clone .

88


//
__ ] [5
__ ] [5

//
__ ]100 [0
__ ]760 [1
__ ]324 [2
__ ]109 [3
__ ]221 [4

//
0 4
__ ][ __][

89
BEGIN
//
Int SourceNumericArray[5];
Int TargetNumericArray[5];

//
Int Count;

//
SourceNumericArray[0] 100 ;
SourceNumericArray[1] 760 ;
SourceNumericArray[2] 324 ;
SourceNumericArray[3] 109 ;
SourceNumericArray[4] 221 ;

//
For Count 0 TO 4
TargetNumericArray[Count] SourceNumericArray[Count];
END FOR
END

90

"

"

[email protected]

[email protected]

www.mobarmjoun.com

www.youtube.com/EssaadaniTV

www.facebook.com/EssaadaniPage

91

You might also like