, , ,

[SOLVED] Cs300 programming assignment 2

$25

File Name: Cs300_programming_assignment_2.zip
File Size: 282.6 KB

5/5 - (1 vote)

Task(s):
Question 1: For this task, you are required to take the name of the file as input from the user and
then read it (marks will be deducted if you don’t take the name of the file as input). (20 marks)• The txt file contains push & pop operations. You need to read the file line by line and identify
the given data structures i.e., Stack, Queue, Priority Queue (min & max) or you can identify
it as insufficient information or illegal action depending on the information in the file.• The first line of your txt file will always be an integer that shows how many lines you are
required to read from first line to that specific line in the file to determine the data-structure.
The sample txt file is attached for your help• For example, if there is a 6 in the first line, you must read the next 6 lines and based on that
you must identify the data structure. Please look at the examples given below
• If there is a non-digit character in it, you need to deal with its ASCII-value. For example, if
there is push(’A’), you need to check if there is pop(65) as ASCII-value of ’A is 65• If the line count is greater than number of remaining lines of code in the txt file then your
code must not crash in that case as well. Please look at the last example given below for this
taskQuestion 2: Write a O(n) boolean function named checkpalindrome that checks whether a given
singly linked-list is palindrome or not. The arguments of the function will be a linked-list of integers.
(4 marks)Question 3: Write a O(n) function named rotate that takes a number n and and a singly linked-list
in its arguments. Your function will rotate the given linked-list by n times and return it.
(6 marks)Question 4: Write a O(n) function named reverse that reverses a stack using recursion. The
arguments of the function will be a stack containing strings. Your function will return a reversed
stack (5 marks)Question 5: SWAPI: The Star Wars API. SWAPI is a data source which contains all the data
from the Star Wars canon universe! You can familiarise yourself with the API here. (20 marks)
Given 2 strings, the name, and the entity to which the name belongs, you are required to write
a program that uses the API and displays their complete information.For example: If the entity is a “film” and the name of the film is “A New Hope” then you need
to return the details of the film which has that specific name. You must also return the name of
the characters (along with their species), planets, vehicles, and starships involved in the movie.
Similarly, this needs to be done for other entities, which can be a starship, a person, a vehicle,
or any of the species.You’re required to use promises and your code must not crash in case of an input that is incorrect
(and if any of the API returns an error).
For calling the API’s, you will be using axios, which is a promise-based HTTP client for browsers
and node js. You can read further on axios here.Example:
Entity: film
Name: A New Hope
Output:
Title: A New Hope
Director: George Lucas
Producer: Gary Kurtz, Rick McCallum
Release-date: 1977-05-25
Characters: (only typing out the first 2, but there is a total of 18 )
1. Luke Skywalker
2. C-3PO
The following planets where the movie was shooted at:
1. Tatoonie
2. Alderaan
3. Yavin IV
The following starships were used in the movie:
1. CR90 corvette
2. Star Destroyer
3. Sentinel-class landing craft
4. Death Star
5. Millennium Falcon
6. Y-wing
7. X-wing
8. TIE Advanced x1
The following vehicles were used in the movie:
1. Sand Crawler
2. T-16 Skyhopper
3. X-34 Landspeeder
4. TIE/LN starfighter
Different species involved in the movie:
1. Human
2. Droid
3. Wookie
4. Rodian
5. HuttQuestion 6: Sameer and Ahmed want to hire a team of ”k” software engineers from ”n”
candidates such that the performance of the team is maximized.You are given two integers ”n” and ”k” and two integer arrays ”speed” and ”efficiency” both of
length ”n”. There are ”n” engineers numbered from ”1” to ”n”. speed[i] and efficiency[i] represent
the speed and efficiency of the ith engineer respectively. Write a function named maxPerformance
that chooses ”k” engineers from ”n” candidates to form a team with the maximum performance
and returns the maximum performance.The performance of a team is the sum of their engineers’ speeds multiplied by the minimum
efficiency among their engineers.
The function will take following parameters (k n speed effeciency) (10 marks)Question 7: Is Node really single-threaded? Through this question we will try to learn the
threading structure of Node. “pbkdf2” https://nodejs.org/api/crypto.html is a bult-in function that computes a hash, and it is a long running operation, which is expected of a hash function.
We are going to use this function and do some experiments. Import this function from the crypto
module, call it and measure the time it takes to complete the execution.a) Use the “pbkdf2” function and observe whether or not node is single threaded. Observe the
results and comment on what do you think about the default number of threads in Nodejs.
(5 Marks)b) Add “process.env.UV THREADPOOL SIZE = 8” at the start of your code and now repeat
the above experiment. Comment on your observations. (5 Marks)c) Add “process.env.UV THREADPOOL SIZE = 8” at the start of your code. Call the pbkdf2
and measure the time, keep on adding the function calls one by one and you will observe that the
average running time starts increasing, although that we have increased the thread pool size. What
do you think is the cause of this? Comment on your observations. (5 Marks)d) Explore the Node’s git repo https://github.com/nodejs/node. What is v8? What is
Libuv? And what is the role of these two in Node. (Hint: find the ”pbkdf2” function in the repo
and explore it) (5 Marks)
Code in separate files for each question and write the comments inside the file.Question 8: You’re working at a tech company, and you’ve been assigned a task to reduce the
storage costs on the servers by compressing the large codebase of their website without changing
the repository structure. (15 marks)You’re required to make function that essentially takes a source directory path and a target
directory path as arguments. The target folder will be empty initially. Your job is to compress
all the files in the source folder and store them in the target directory in a recursive fashion (the
target folder will have the same hierarchy of the subdirectories as in the source folder). You’re
only allowed to use the JavaScript’ ‘fs’ module (only the asynchronous functions of it) for all tasks
except compressing; you may use any library/module for it.You’re also required to make the promised versions of the read and write functions, and not use
them directly.

Shopping Cart

No products in the cart.

No products in the cart.

[SOLVED] Cs300 programming assignment 2[SOLVED] Cs300 programming assignment 2
$25