Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
College aantekeningen

CP264 FINAL REVIEW

Beoordeling
-
Verkocht
-
Pagina's
20
Geüpload op
05-05-2024
Geschreven in
2023/2024

Cp264 final review notes

Instelling
Vak

Voorbeeld van de inhoud

lOMoARcPSD|33062721




CP264 Final Review


Data Structures II (Wilfrid Laurier University)




Scan to open on Studocu




Studocu is not sponsored or endorsed by any college or university
Downloaded by Bal Boi ()

, lOMoARcPSD|33062721




CP264 Final Review
Queue
 Abstract Queue: Linearly ordered collection of data elements with enqueue, dequeue, and peek operations
o Enqueue operation inserts element into collection
 Linearly order of elements determined by time they're inserted
 Front element is earliest inserted element; Rear is last inserted element
o Dequeue operation removes/deletes front element
o Peek operation gets front element
 Queue Data Structure: Implementation of abstract queue
 Queue Characteristic → First-In-First-Out (FIFO): Deletes first inserted element
 Time and space complexities for queue operations → time O(1), space O(1)

Array Queue
 Simple Array Queue: Queue implementation with array representation, where front and rear
variable represent index positions that deletions and insertions are done respectively
Drawbacks:
o Length of queue is bound by length of its array
o Wastes space if length of queue is shorter than length of array
Linked List Queue
 Fixes drawbacks of array queues → length is dynamic + doesn’t waste space
 Linked List Queue: Uses singly linked list to store queue data values; uses two pointers front and
rear to represent front and rear positions

Deques (Double-ended Queue)
 Dequeue (Double-ended Queue): Queue where elements can be inserted/deleted at either end

Priority Queue
 Priority Queue: Queue where each element is assigned a priority; priority of element used to
determine order in which elements are processed
 Rule of processing elements of priority queue:
1. Element with higher priority is processed before element with lower priority
2. Two elements of same priority processed by first come first serve order
Applications of Queues
Whenever an algorithm needs to remember data items and a FIFIO is required for item processing,
queue data structure can be an option
1. Used to store intermediate data within algorithm for FIFO retrieval (e.g. Breadth-first search)
2. Used as waiting lists for single shared resource (e.g. printer, disk, CPU, network device)
3. Used in OS for handling interrupts; If interrupts must be handled in order of arrival, FIFO queue
is appropriate data structure
4. Used to transfer data asynchronously (e.g. Pipes, file I/O, sockets)
5. Used in simulations for services
6. Used for play lists, adding songs to the end, playing from the front of the list.
7. Priority queues are in OS for processes execution management.
8. Used to remember the path of explorations if FIFO retrieval is needed.

1


Downloaded by Bal Boi ()

, lOMoARcPSD|33062721




Stack
 Abstract Stack: Linearly ordered collections of data elements with push, pop, and peek operations
 Stack Characteristic → Last-In-First-Out (LIFO): Pops the most recently pushed element
 Stack Data Structure: Implementation of abstract stack
 Stack: Linear data structure with push and pop operations satisfying LIFO property
 Why is only one variable needed for accessing a stack data structure?
1. Stack operations only work on one side of the stack list, one variable does the jobs.
2. It’s more time efficient to maintain one variable than more variables.
3. It’s more space efficient to use one variable than more stack data structure.
2. Time and space complexities for stack operations -> time O(1), space O(1)

Array Stack
 Array Stack: Stack representation by an array, top variable represents index position where
push, pop, and peek operations are done
Linked List Stack
 Linked List Stack: Use singly linked list to implement stack, pointer top points to first node
 Array vs. Linked List Stack

Array Stack Linked List Stack
Pros: Pros:
 Easy to implement  No size constraint
 More time efficient in operation  More space efficient with
dynamic memory allocation
Cons: Cons:
 Limitation on maximum size  Use more time on operations
 Less space efficient when stack
size is less than array size
 When is it better to an array stack or a linked list stack?
o Applying stacks in an application, if the maximum size of a stack is known and not big,
then an array stack is a better choice, otherwise a linked list stack is preferred.
Applications of Stacks
1. Back tracking
2. Reversing a list
3. Parentheses checking
4. Infix/Prefix/Postfix expressions and evaluation
5. Conversion from infix to postfix expressions
6. Function call stack and recursion functions




2


Downloaded by Bal Boi ()

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
5 mei 2024
Aantal pagina's
20
Geschreven in
2023/2024
Type
College aantekeningen
Docent(en)
Abdul
Bevat
Alle colleges

Onderwerpen

$10.99
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
aryanjain7

Maak kennis met de verkoper

Seller avatar
aryanjain7 w
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
-
Lid sinds
2 jaar
Aantal volgers
0
Documenten
1
Laatst verkocht
-

0.0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen