












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 10/10/2023 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Than Thi Bich Hang Student ID BH Class IT0503 Assessor name Ta Quang Hieu 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 Hang Grading grid P1 P2 P3 M1 M2 M3 D1 D
Grade: Assessor Signature: Date: Internal Verifier’s Comments: IV Signature:
I am an in-house software developer for Softnet Development Ltd, a software company providing network provisioning solutions. My team was given a special role: designing and implementing abstract data types. I was asked to create a presentation for all collaborating partners on how ADT could be used to improve software design, development, and testing. Furthermore, I was asked to write an introductory report to distribute to all partners on how to specify data types and abstract algorithms in a formal notation. Below is my report
An Abstract Data Type (ADT) is a programming concept that defines a high-level view of a data structure, without specifying the implementation details. In other words, it is a blueprint for creating a data structure that defines the behavior and interface of the structure, without specifying how it is implemented. An ADT in the data structure can be thought of as a set of operations that can be performed on a set of values. This set of operations actually defines the behavior of the data structure, and they are used to manipulate the data in a way that suits the needs of the program. ADTs are often used to abstract away the complexity of a data structure and to provide a simple and intuitive interface for accessing and manipulating the data. This makes it easier for programmers to reason about the data structure, and to use it correctly in their programs. (Prepbytes, 2023)
A stack is an ordered collection of items where the addition of new items and the removal of existing items always occur at the same end. This end is commonly called the “top”, and the opposite is known as the “base”. Items closer to the base have been in the stack the longest. The most recently added item is always on the top of the stack and thus will be removed first. The stack provides an ordering based on the length of time in the collection; the “age” of any given item increases as you move from top to base.
An abstract data type, sometimes abbreviated ADT, is a logical description of how we view the data and the allowed operations without regard to how they’ll be implemented. This means that we’re only concerned with what the data represents and not with how it’ll be constructed. This level of abstraction encapsulates the data and hides implementation details from the user's view, a technique called information hiding. A data structure is an implementation of an abstract data type and requires a physical view of the data using some collection of primitive data types and other programming constructs. The separation of these two perspectives allows us to define complex data models for our problems without giving any details about how the model will actually be built. This provides an implementation- independent view of the data. Since there are usually many ways to implement an abstract data type, this independence allows the programmer to change implementation details without changing how the user interacts with it. Instead, the user can remain focused on the process of problem-solving. The stack abstract data type is an ordered collection of items where items are added to and removed from the top. The interface for a stack is:
Below is an example of the stack: 2.4 Standard Stack Operations The following are some common operations implemented on the stack:
FIFO, which stands for "First In, First Out," is a fundamental requirement for certain data structures and operations. FIFO defines a specific order of processing or accessing elements, where the first element that is added or enqueued is the first one to be removed or dequeued. This concept is akin to standing in a line or queue in the real world, where the person who arrives first is the one to be served first. (SEAN HANLY, CEO, n.d.) FIFO is particularly important in computer science and various applications for the following reasons: Order Preservation : FIFO ensures that the original order of elements is maintained. This is crucial in scenarios where the temporal sequence or chronological order of data matters. For example, in a print queue, the order in which print jobs are submitted should be preserved to ensure fairness. Fairness: FIFO provides a fair and predictable way to handle competing requests or tasks. When multiple processes or entities are waiting for access to a resource, using a FIFO approach ensures that each entity gets its turn in the order it arrived. Real-World Analogies: FIFO closely resembles many real-world scenarios. People waiting in line at a grocery store, vehicles in a traffic jam, and packets in a network queue all follow the FIFO principle. By mimicking these real-world behaviors, FIFO queues model real-world processes effectively. Buffering and Queuing: FIFO is commonly used in buffering and queuing applications. For instance, in computer networking, data packets are typically processed in the order they were received to maintain proper sequencing and avoid data corruption. Synchronization: FIFO can be used for synchronization in concurrent programming. It helps coordinate and schedule tasks in a way that avoids race conditions and ensures that tasks are executed in the order they were initiated. Task Scheduling: In operating systems, FIFO scheduling algorithms are used to allocate CPU time to different processes. The process that arrives first is given CPU time before others, ensuring a fair distribution of computing resources. Data Structures: FIFO is a fundamental requirement for certain data structures, such as queues. Queues are used to implement FIFO behavior, where elements are added at one end (enqueue) and removed from the other end (dequeue).
These are the operations performed by a queue. Enqueue - The element to add to a queue. Dequeue - The element to delete in a queue. Peek - Retrieve the element from the front end of the queue without removing it from the queue. (Anjali, Queue Data Structure ) Below is an example of the Queue:
4. Key Features of Java Heap Memory Some other features of heap space include: It’s accessed via complex memory management techniques that include the Young Generation, Old or Tenured Generation, and Permanent Generation. If heap space is full, Java throws java. lang.OutOfMemoryError. Access to this memory is comparatively slower than stack memory This memory, in contrast to stack, isn’t automatically deallocated. It needs a Garbage Collector to free up unused objects so as to keep the efficiency of the memory usage. Unlike stack, a heap isn’t threadsafe and needs to be guarded by properly synchronizing the code. 5. Example Random-Access Memory (RAM) is a type of memory in a computer used to temporarily store data and running programs. RAM provides a fast storage space for the data the computer needs to perform real- time tasks. Memory, particularly RAM (Random Access Memory), is used to implement function calls in a computer's memory hierarchy. When a program or software function is called in a computer, it involves several steps that make use of memory, including RAM: - Function Call: When a function is called within a program, the CPU needs to remember the state of the program at that point, including the location it should return to after the function call. This information is stored on the call stack, which is typically located in RAM. - Stack Memory: The call stack, often simply referred to as the "stack," is a specific portion of RAM used for managing function calls. It keeps track of function call information, including the return address (where the program should continue executing after the function call), function parameters, and local variables. - Local Variables: RAM is also used to store the local variables and temporary data that are specific to a particular function call. These variables are stored on the stack, ensuring that they are accessible and isolated for each function call. - Execution Flow: As functions are called and returned, the stack is constantly updated. When a function returns, it is removed from the stack, and the program continues execution at the return address stored on the stack. - Recursion: In cases of recursive function calls, each recursive call creates a new stack frame in RAM, allowing the program to maintain separate instances of local variables and function parameters for each level of recursion. - Memory Management: RAM plays a crucial role in memory management during function calls. It ensures that the program can allocate and deallocate memory for function-related data dynamically, based on the call stack's structure.
In Python programming, stack memory is often not accessed directly as in some other languages, and it is often managed by the language and the Python virtual machine. In Python, you do not need to specifically manage stack memory like in C++ because Python has an automatic memory management model (garbage collection) and hides the process performed on the stack. However, you can see the stack effect in Python when you call the function. Consider the following example:
In this example, we have the functions function1, function2, and main. When you call functions in Python, a stack frame corresponding to that function is created and traversed. The local variables and parameters of that function are stored in the stack frame. The results when running the program will display the values of variables x and y in each function.
2. Parts of a software stack Applications have four tiers, three of which are on the server side. We will break down each of the four tiers and what they include. - The client tier. This is the only component in the browser. - The web tier. The web tier consists of the web server or the HTTP server. - The business tier. The business tier comprises the application server, including the development platform, frameworks, and server-side programming languages. - The database tier. The database tier comprises the database server you choose. This tier is often dependent on the business tier you choose. The tiers each include several components. We will explore each of them. - Operating system. The operating system manages the memory and processes within your computer. The majority of the time, computers will use one of five main systems: macOS, Microsoft Windows, Linux, Apple iOS, and Android OS. - Server. Servers can be hardware or software and help with tasks like sharing data between different clients. You might have database servers, file servers, and web servers, for example. Depending upon the type of server you need, you will encounter a variety of popular options. InMotion works well for dedicated server hosting, for example, while Apache is a popular web server. - Database. Your databases let you create and maintain all the records used in your system. Popular databases used in stacks include MySQL, Oracle Database, and SQL Server. - Server-side scripting language. A server-side scripting language is often used to produce a customized interface for clients. This is opposed to client-side scripting, which has embedded scripts run in a web browser. The most popular server-side scripting languages include Node.js, Python, C#, PHP, and Java. You’re not limited by the components in a stack—they’re interchangeable based on your needs and customizable for your project.
3. Examples of Popular Software Stacks Many software stack components are chosen frequently enough that their names or an acronym describing their core components have become well-known. Listed below are a few examples of typical enterprise software stacks. (Janani, 2022) - The MEAN Stack The MEAN stack (MongoDB, Express.js, AngularJS, and Node.js) is a JavaScript-based stack that includes the MongoDB database, the Express.js backend framework built on top of Node.js, and the AngularJS frontend framework. The MEAN stack's software is all free and open-source, making it simple to understand and utilize. Developers may share and optimize code between the frontend and backend components because it's a front-to-back Javascript stack. - The MERN Stack
The MERN stack (MongoDB, Express.js, React.js, and Node.js) is a popular variation of the MEAN stack that substitutes Angular.js with React.js, a Facebook-developed open-source Javascript library. Since React is a library, it comes with fewer features out of the box than other frontend frameworks, but it has a significant number of third-party libraries to supplement it. The MERN stack, like the core MEAN stack, is a front-to-back Javascript stack that allows developers to reuse and optimize code across the frontend and backend.
My above article has answered questions about the issues raised, I have taken examples for each section, I have designed the data structure explaining the valid operations that can be performed. appear on the structure. Identify the operations of the memory stack and how it is used to make function calls in the computer. Using an imperative definition, specify an abstract data type for the software stack. These are the parts I reported above, the language used for this report is Java.
Prepbytes (2023) Abstract data type (ADT) in Data Structure , PrepBytes Blog. Available at: https://www.prepbytes.com/blog/data-structure/abstract-data-type-adt-in-data-structure/ (Accessed: 09 October 2023). (No date) Introduction to stacks. Available at: https://bradfieldcs.com/algos/stacks/introduction/ (Accessed: 09 October 2023). Queue Data Structure (2023) GeeksforGeeks. Available at: https://www.geeksforgeeks.org/queue-data- structure/ (Accessed: 09 October 2023). What is stack in data structure? - javatpoint (no date) www.javatpoint.com. Available at: https://www.javatpoint.com/data-structure-stack (Accessed: 09 October 2023). Anjali, K. (no date) Queue Data Structure , etutorialspoint. Available at: https://www.etutorialspoint.com/index.php/data-structure/queue-introduction (Accessed: 09 October 2023). Stack memory (no date) Stack Memory - an overview | ScienceDirect Topics. Available at: https://www.sciencedirect.com/topics/engineering/stack-memory (Accessed: 09 October 2023). baeldung, W. by: (2023) Stack memory and heap space in Java , Baeldung. Available at: https://www.baeldung.com/java-stack-heapn (Accessed: 09 October 2023). Semilof, M. and Montgomery, J. (2020) What is a software stack? , App Architecture. Available at: https://www.techtarget.com/searchapparchitecture/definition/software-stack (Accessed: 10 October 2023). What is a software stack?: Upwork (no date) RSS. Available at: https://www.upwork.com/resources/what- is-a-software-stack (Accessed: 10 October 2023). Janani (2022) Software stack: Definition, few common stacks, and more , Atatus. Available at: https://www.atatus.com/glossary/software-stack/#examples-of-popular-software-stacks (Accessed: 10 October 2023).