You are on page 1of 51

:

1 / 51



:

.C
, 4 , :
Singly Linked List
Doubly Linked List
Stacks
Queues

:
Trees
Binary Trees
Hash tables
Graphs

2 / 51

:
:
:
1992 :
: ..
programming & Security :
: .
ahmed.ould_mohamed@yahoo.fr :

All rights reserved

02/02/2013

3 / 51

,
.


Linked List

) (

) (
.
.
.

4 / 51

,

.


NSS memory ,1955-1956
Allen Newell, Cliff Shaw Herbert Simon .RAND Corporation
(IPL) Information Processing Language
IPL ,

Logic Theory Machine,

General Problem Solver ) Chess (.


IRE Transactions on Information Theory
1956 ) .1957 1959 (1 )
( 1957
).Programming the Logic Theory Machine (2
1975

Allen Newell Herbert Simon

Turing

(1) Proceedings of the Western Joint Computer Conference en 1957 et 1958 et Information Processing en 1959
)(premire runion de l'International Conference on Information Processing de l'UNESCO
(2) Programming the Logic Theory Machine de Allen Newell et Cliff Shaw, Proceedings of the 1957 Western Joint
Computer Conference, fvrier 1957.

5 / 51

Linked List

,
:
Seymour Lipschutz )" : The data structures (Courses and problems
".
John Rast Hubbard Java Data Structures "
, : ".
Alain-Bernard Fontaine The C++ Standard Template Library "
) (
".
Thomas Cormen, Charles Leiserson Ronald Rivest

Introduction to Algorithms

"
, "

,
,:

:

6 / 51

i X size-i size
.
.

)( )(.

.

Dynamic Data Structures


malloc.

7 / 51

,
:
.
,
.
, .
.

.NULL
, .

) (Singly Linked List ,
.
, ).(Doubly Linked List

8 / 51

,
, ,
.

.
:
A .Z
) @ ( .
:

singlyLinkedList 4 ,
.
,
:

) (
:

9 / 51

:
P )( x y .P.x Or P.y
Q ,P .Q->x Or Q->y :

C ) (Pass by reference .C++


C ,
C ) (C++.
init ) (Reference ,
, false
, sll

) , , (
:
0 Login randomCharacter
NULL ptrNext email ,
) (int, float, char, bool, .. ) (..,
memset ,email memset

,
.
true .

10 / 51

printf stdio.h NULL stdlib.h

memset

string.h .
NULL
.
, mySimpleList init
, false .
:


, :
.
.
.
11 / 51

C
, :

, false ,true .
, 3 , ) (Reference
. ,
.
, L login aplphabet
.randomCharacter , strcpy em
email
. : main

12 / 51

C
:

, .
, time.h rand .srand
mail , false
display ) (.
:

,

.

:

13 / 51

C
:

, while
. , :
.
.
.
.

,
. :
, :
NULL , .false
:
.
.
.
.

.

14 / 51

C
:

false true
.
, ,
while .

:

,
. (-:
15 / 51

,
. , .

, , .
, :

16 / 51

:
.
) (.
.NULL
.

:
.
.
.
:

17 / 51

. .

removeTheFirst

, .

while

, while ,
false , if ,

delNode
.


:
) (
) (.

18 / 51

C
:

, :


.

:

, .
.

: , . ! (-:

19 / 51

:
.1

.2

,
.

20 / 51




) (
.
.
.



,
.

, , ,
.

21 / 51

:
:
.
) (
.
.

,
) ( ..
,
, .int
:

, 3 : int
. .
:

22 / 51

int ,
.

) (
:

init ) (Reference ,
, false ,
argDbll 3
) , ( .
true .

:
.NULL

.NULL

.
) , , (.. ,
.

23 / 51

printf fprintf stdio.h

EXIT_FAILURE EXIT_SUCCESS

stdlib.h bool stdbool.h .


NULL
.
, myDoubleList init
, false .
:

,0
, .
) (
.

, .

24 / 51

NULL
0x00000000 Invalid Memory Address .
Null Pointer .

, :
.
.
.NULL
.
.
o
o last .
.
.
, :

, false ,true .
, , (-:
25 / 51

C
: main

,
, false display
) (.
:


.
,
,


.

26 / 51

:
.
NULL .
.
o
.
o first
.
.

27 / 51

,
. :
, :
NULL , .false
:
.
.
.
.
.
.
first .
.
last
.
:
28 / 51

false true
.
, ,
for .
addAfterACertainNode : main

29 / 51

addAfterACertainNode int
1 2
void .
, :

, currentPointer
, . i
.

, , .
, :

30 / 51

:
.
, false .
:
o .NULL
o .
o .
o

removeTheLast : main

31 / 51

, .
:

32 / 51

:
.
.
.
:

33 / 51

elem :

elem .
,
removeTheFisrst
removeTheLast .
while ,
elem , false , if
elem , tmpNode
.

34 / 51

, , lengthOfTheList
.

, .
.

:
) (NULL
.while
) NULL
(.

35 / 51


7 , .
, 10 5
)
( , 8 4 .
6.
.

36 / 51

)(Stacks




Stack
, LIFO
.Last In First Out
)
( ).(Trees

:
.
.
index .
:

37 / 51

C
:

top MAXSIZE
.
, top ,
top .

index decrement
.

(-:

38 / 51

top 0 top .
, ) . ,

-

:
Push .
Pop .

39 / 51

int ptrPrev .
top temp .

, top
value . ptrPrev NULL temp .top

, ptrPrev .

40 / 51

temp NULL .
temp top top
.

) ( :


, :

41 / 51

, newStack
.value
newStack NULL
NULL . newStack myStack
myStack newStack newStack NULL
.

42 / 51

C
.

,
.
, ,
NULL .

) ( :


infix postfix .Stacks

43 / 51

)(Queues




Queue ) (Stack
, ) (
.
Waiting List
FIFO .First In First Out
,
) ( ).(Trees


3 :
,:

44 / 51

, 20 Queue -1 front rear

.
:

rear SIZE-1
OverFlow .
, .

rear front , .
, rear front 1- 1- index
0 UnderFlow index
.
, )
(.

45 / 51

, rear front . ,
:

-
,
.
Queue Stack
) (.

int ptrNext
. front rear .

46 / 51

, q
value . front rear NULL
, rear

.rear

front rear NULL


.
front q q
.

) ( :
47 / 51

head tail length .

48 / 51

, ,
.
temp
value .NULL

NULL head .
) ( tail
tail .
.

49 / 51

length
.
,

) NULL (
.

) ( :


Palindrome .
: Stack Queue .

50 / 51

51 / 51

You might also like