Upload
others
View
12
Download
0
Embed Size (px)
Citation preview
Strukture te Dhenash
Seminar 12
ELISA RECI Universiteti Luigj Gurakuqi
Fakulteti i Shkencave te Natyres
Departamenti i Matematikes dhe Informatikes
SHKODER
1 MSc. Elisa Reci Semestri II/2013
Stiva
• Nje liste lineare nje-drejtimore , ne te cilen operacionet e heqjes dhe te shtimit te nje elementi behen vetem tek koka e listes.
• Koka ne kete rast quhet kulm i kokes.
• LIFO(Last In First Out)
MSc. Elisa Reci 2 Semestri II/2013
Deklarimi i Stives
typedef struct element {
int vlere;
struct element *pas;
} stive;
• Tipi i te dhenes qe mban element (vlere) eshte INT kurse elementi adresa e elemenetit pasardhes eshte PAS i tipit liste.
MSc. Elisa Reci 3 Semestri II/2013
Ushtrimi 1
• Krijoni nje stive dhe pastaj krijoni nje stive boshe
MSc. Elisa Reci 4 Semestri II/2013
Stive * stiveboshe(){
Return NULL;
}
MSc. Elisa Reci 5 Semestri II/2013
Ushtrimi 2
• Ndertoni nje funksion qe kontrollon nese nje stive eshte boshe. Kthen 1 nqs eshte boshe dhe 0 nqs jo
MSc. Elisa Reci 6 Semestri II/2013
Ushtrimi 3
• Ndertoni nje funksion qe shton nje element te ri ne stive.
MSc. Elisa Reci 7 Semestri II/2013
Ushtrimi 4
• Ndertoni nje funksion qe hec nje element nga stiva
MSc. Elisa Reci 8 Semestri II/2013
Ushtrimi 5
• The insertion and deletion are done at _______ of the stack.
• _______ and _______ are the operations of stack.
• _______ is an application of stack.
• When rear= =size of stack then stack is _______.
• The postfix evaluation is done based on _______.
MSc. Elisa Reci 9 Semestri II/2013
• The stack is a _______ data structure.
– FIFO
– LIFO
– Both a and b
– FILO
MSc. Elisa Reci 10 Semestri II/2013
• The pointer Top increases when an _______
– Element is inserted
– Element is deleted
– Element is displayed
– None
MSc. Elisa Reci 11 Semestri II/2013
• Which of the following is not stack application?
– Recursion
– Templates
– String reversion
– Process scheduling
MSc. Elisa Reci 12 Semestri II/2013
• Stacks are dynamically represented using _______.
– Pointers
– Structures
– Linked lists
– None
MSc. Elisa Reci 13 Semestri II/2013
• When is a stack said to be empty?
– top==n
– top==0
– front==0
– front=rear=0
http://my.safaribooksonline.com/book/programming/cplusplus/9788131755679/chapter-6dot-
stacks/navpoint-157#X2ludGVybmFsX0h0bWxWaWV3P3htbGlkPTk3ODgxMzE3NTU2NzklMkZuYXZwb2ludC0xNDMmcXVlcnk9
MSc. Elisa Reci 14 Semestri II/2013
Rradha
• Rradha eshte nje liste e vecante ne te cilen shtimi i elementit behet nga bishti, kurse heqja nga koka.
• FIFO (First In First Out)
MSc. Elisa Reci 15 Semestri II/2013
Rradha
• Ka dy shenjuesa: kreu dhe fundi
• Elementi i fundit i rradhes do trajtohet vetem kur ai te behet element i pare (kreu)
MSc. Elisa Reci 16 Semestri II/2013
Deklarimi i rradhes
typedef struct element {
int vlere;
struct element *pas;
} rradhe;
typedef struct {
rradhe *kreu, *fundi;
} rradhesh;
MSc. Elisa Reci 17 Semestri II/2013
Ushtrim 6
• Krijoni nje rradhe boshe
MSc. Elisa Reci 18 Semestri II/2013
Ushtrimi 7
• Ndertoni nje funksion qe kontrollon nese rradha eshte boshe apo jo
MSc. Elisa Reci 19 Semestri II/2013
Ushtrimi 8
• Ndertoni nje funksion qe fut nje element ne rradhe
MSc. Elisa Reci 20 Semestri II/2013
Ushtrimi 9
• Ndertoni nje funksion qe heq nje element nga rradha
MSc. Elisa Reci 21 Semestri II/2013
• Queues are also knows as _______ structures.
• _______ are dynamic queues.
• _______ are the types of queues.
• Queue is said to be full when _______.
• _______ is the drawback of linear queues.
• _______ are knows as deques.
• The advantage of circular queue _______.
MSc. Elisa Reci 22 Semestri II/2013
• The data structure that allows deleting data elements from front and inserting at rear is _______.
– Stacks
– Queues
– Deques
– Binary search tree
MSc. Elisa Reci 23 Semestri II/2013
• Identify the data structure that allows deletions at both ends of the list but insertion at only one end.
– Input-restricted deque
– Output-restricted deque
– Priority queues
– None of the above
MSc. Elisa Reci 24 Semestri II/2013
• A difference between a queue and a stack is
– Queues require dynamic memory, but stacks do not.
– Stacks require dynamic memory, but queues do not.
– Queues use two ends of the structure, stacks use only one.
– Stacks use two ends of the structure, queues use only one.
MSc. Elisa Reci 25 Semestri II/2013
• http://my.safaribooksonline.com/9788131755679/navpoint-158#X2ludGVybmFsX0h0bWxWaWV3P3htbGlkPTk3ODgxMzE3NTU2NzklMkZuYXZwb2ludC0xNzQmcXVlcnk9
MSc. Elisa Reci 26 Semestri II/2013
MSc. Elisa Reci 27 Semestri II/2013