Docsity

Data Structures and Algorithms Assignment: A Comprehensive Guide for Students, Cheat Sheet of Data Structures and Algorithms

Partial preview of the text

Download Data Structures and Algorithms Assignment: A Comprehensive Guide for Students and more Cheat Sheet Data Structures and Algorithms in PDF only on Docsity!

Unit 19: Data Structures and Algorithms

ASSIGNMENT 1

Learner’s name: Nguyễn Xuân Nam

ID: GCS

Class: GCS0905A

Subject code: 1649

Assessor name: Lê Ngọc Thành

Assignment due: 14 /10/

Assignment submitted: 18 /10/

ASSIGNMENT 1 FRONT SHEET 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 Nguyễn Xuân Nam Student ID GCS Class GCS0905A Assessor name Lê Ngọc Thành 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

 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date: Lecturer Signature:

LO1 Demonstrate an understanding of the fundamentals of Cloud Computing and its architectures. LO2 Evaluate the deployment models, service models and technological drivers of Cloud Computing and validate their use. Assignment Brief and Guidance: Scenario ATN is a Vietnamese company which is selling toys to teenagers in many provinces all over Vietnam. The company has the revenue over 700.000 dollars/year. Currently each shop has its own database to store transactions for that shop only. Each shop has to send the sale data to the board director monthly and the board director need lots of time to summarize the data collected from all the shops. Besides the board can’t see the stock information update in real time. The table of contents in your technical report should be as follows:

  1. As a developer, explain to the board director the fundamentals of cloud computing and how it is popular nowadays(about 2500 words)
  2. Proposed solution (higher level solution description – around 700 words) and explain the appropriateness of the solution for the scenario (about 400 words with images and diagrams)which might include: a. Architectural design (architectural diagram and description). b. Detailed design: i. Deployment model (discussion on why that model was chosen). ii. Service model (discussion on why that model was chosen). iii. Programming language/ webserver/database server chosen.
  3. Summary. General guidelines:  Instead of providing definitions but also provide with examples.  Provide more own arguments instead of definitions  Making use of academic references instead of web tutorials  For a cloud architecture look at the bottom of this document

Learning Outcomes and Assessment Criteria Pass Merit Distinction LO1 Examine abstract data types, concrete data structures and algorithms D1 Analyse the operation, using illustrations, of two network shortest path algorithms, providing an example of each.solution. P1 Create a design specification for data structures explaining the valid operations that can be carried out on the structures. P2 Determine the operations of a memory stack and how it is used to implement function calls in a computer. M1 Illustrate, with an example, a concrete data structure for a First In First out (FIFO) queue. M2 Compare the performance of two sorting algorithms. LO2 Specify abstract data types and algorithms in a formal notation D2^ Discuss the view that imperative ADTs are a basis for object orientation and, with justification, state whether you agree.. P3 Using an imperative definition, specify the abstract data type for a software stack. M3 Examine the advantages of encapsulation and information hiding when using an ADT.

ASSIGNMENT 1 ANSWERS

Introduction In this assignment, I will create a design specification for a data structure that describes the legal operations that can be performed on that structure. Then I'll explain how the memory stack works and how it's used in computers to make function calls. Finally, I will use imperative descriptors to describe the abstract data types of the software stack.

1. Data Structures 1.1 Abstract data type

1.1.1 Definition

Abstract Data type (ADT) is a type (or class) for objects whose behavior is defined by a set of values and a set of operations. The definition of ADT only mentions what operations are to be performed but not how these operations will be implemented. It does not specify how data will be organized in memory and what algorithms will be used for implementing the operations. It is called “abstract” because it gives an implementation-independent view. The process of providing only the essentials and hiding the details is known as abstraction.

Queue ADT

 The queue abstract data type (ADT) follows the basic design of the stack abstract data type.  Each node contains a void pointer to the data and the link pointer to the next element in the queue. The program’s responsibility is to allocate memory for storing the data.  enqueue() – Insert an element at the end of the queue.  dequeue() – Remove and return the first element of the queue, if the queue is not empty.  peek() – Return the element of the queue without removing it, if the queue is not empty.  size() – Return the number of elements in the queue.  isEmpty() – Return true if the queue is empty, otherwise return false.  isFull() – Return true if the queue is full, otherwise return false.

Features of ADT:

 Abstraction: The user does not need to know the implementation of the data structure.  Better Conceptualization: ADT gives us a better conceptualization of the real world.  Robust: The program is robust and has the ability to catch errors.

Implementaion of an Abstract Data Type (ADT):

  • The user is completely ignorant of this.
  • Different languages may implement the same ADT in various ways.
  • Some programming languages have built-in ADTs and/or capabilities for creating ADTs (user- define types). Modular design, which is critical in software development, is supported by ADTs.

System design with ADTs:

1.1.2 Example

Generally data types define what kind of data can be stored in them. There are two types of data types, i.e primitive data types and the abstract data types. Primitive data types are those which are used generally like int,char, float,etc., wheres as the abstract data types are defined by using the primitive data types. For example, stack, list, queue, etc. They are called as abstract because they hide the implementation details, i.e, you will be knowing what are the functions that can be applied on these ADTs but you will not be knowing how the function operates. ADTs basically come from the C++ STL. 1.2 ADT usages

1.2.1 Application of Stack in memory

Definition

A stack is a special area of computer’s memory which stores temporary variables created by a function. In stack, variables are declared, stored and initialized during runtime.

Example code:

Program to calculate the sum of a sequence of numbers: If n is equal to the length of the array minus one, the above method will call itself and the value of n will be decremented by one on each call until the base case yields the first unit. Then the return values of each function call are advanced until the original function is reached and the result is provided. The base case ensures that the function does not make any subsequent recursive calls. If no base case is supplied, the function will continue to call itself until memory is exhausted, resulting in a stack overflow. As a result, a recursive function must have a base case in order to function.

  • The following image illustrates a memory stack implemented function call: +When a function call occurs, prior variables are saved in the stack. +Returning value from base case to caller function:

The calls in the example are 'stacked' on top of each other since they are dependent on the outcomes of the preceding functions, and this stacking also makes the base case manageable. Stop the program. This is known as the call stack.

1.2.2 Application of an ADT

I. Identify the problem

We need to create an array to hold the list of information. This list is sorted in such a way that we can quickly access each child element randomly. For example, if you want information about the 10th child, the system needs to show it immediately. Second, the list can be reorganized based on specific criteria, such as B. Filter out phrases based on the criteria of the top 10 students. After all, since we don't know how many elements there will be or if they will change, the size and elements of the array must be resizable.

II. Solution

Propose:

  • Based on the issues discussed above, I advocate utilizing Arraylist for the following reasons: +The Array List's size can be increased or lowered based on the amount of elements in it. +Quickly and effectively add and delete elements from any location in the array. +Many methods offer actions like remove All - delete all, searching - search, iterations - explore arrays,keep All - modify items, and so on. +An Array List can hold a variety of items, including integers, strings, scanners, and user-defined objects.

Result:

1.3 The Software Stack

I. Definition

A software stack is a collection of independent components that work together to support the execution of an application. The components, which may include an operating system, architectural layers, protocols, runtime environments, databases and function calls, are stacked one on top of each other in a hierarchy. Typically, the lower-level components in the hierarchy interact with hardware, while the higher-level components in the hierarchy perform specific tasks and services for the end user. Components communicate directly with the application through a series of complex instructions that traverse the stack. An application is made up of a collection of functions that operate together in a defined architecture to provide certain services to the user. The most basic application architecture is made up of three layers: