














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!















Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Unit 19: Data Structures and Algorithms Submission date Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Mai Tran Tuan Anh Student ID GCD Class GCD0904 Assessor name Pham Thanh Son Student declaration I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that making a false declaration is a form of malpractice. Student’s signature Grading grid P1 P2 P3 M1 M2 M3 D1 D
Grade: Assessor Signature: Date: Internal Verifier’s Comments: IV Signature:
Figure 1: ADT model.................................................................................................................................................... 5 Figure 2: How queue works......................................................................................................................................... 6 Figure 3: Queue properties.......................................................................................................................................... 8 Figure 4: isFull function............................................................................................................................................... 8 Figure 5: isEmpty function........................................................................................................................................... 8 Figure 6: How enqueue works....................................................................................... Error! Bookmark not defined. Figure 7: Enqueue code................................................................................................. Error! Bookmark not defined. Figure 8: How dequeue work......................................................................................... Error! Bookmark not defined. Figure 9: Dequeue code................................................................................................. Error! Bookmark not defined. Figure 10: Front and rear pointer.................................................................................. Error! Bookmark not defined. Figure 11: Test queue.................................................................................................... Error! Bookmark not defined. Figure 12: Result............................................................................................................ Error! Bookmark not defined. Figure 13: How Stack work........................................................................................................................................ 13 Figure 14: Stack properties............................................................................................ Error! Bookmark not defined. Figure 15: Function check index and size....................................................................... Error! Bookmark not defined. Figure 16: Function push............................................................................................... Error! Bookmark not defined. Figure 17: Function pop................................................................................................. Error! Bookmark not defined. Figure 18: Function peek............................................................................................... Error! Bookmark not defined. Figure 19: Test Stack...................................................................................................... Error! Bookmark not defined. Figure 20: Result............................................................................................................ Error! Bookmark not defined. Figure 21: Define properties.......................................................................................... Error! Bookmark not defined. Figure 22: Function isEmpty.......................................................................................... Error! Bookmark not defined. Figure 23: Function offer............................................................................................... Error! Bookmark not defined. Figure 24: Function poll................................................................................................. Error! Bookmark not defined. Figure 25: Function peek............................................................................................... Error! Bookmark not defined. Figure 26: Test Queue.................................................................................................... Error! Bookmark not defined. Figure 27: Result of testing............................................................................................ Error! Bookmark not defined.
2.2 Operations
Figure 3 : Queue properties
Figure 8 : Add function
- The remove function has the similar flow to the add. It will check the index, then it will get the element out of the array list. New index will be assigned for all elements and then the function is ended Figure 9 : Function remove
Figure 13 : How Stack work
Experience the corresponding Java. lang. error. JVM's StackOverFlowError if all available memory on the stack is used. Because the data saved can only be accessed by the owner thread, stack memory allocation is regarded as being safer than heap memory allocation. Heap-memory allocation is slower than memory allocation and de-allocation. Stack memory is less capacious than heap memory in terms of storage.
Figure 15 : How function is called in stack
Figure 16 : Code snippet
Figure 19 : Double Linked List