Uploaded by habib.m.a.n.2015

.archIT245 - Assignment 1

advertisement
College of Computing and Informatics
Assignment 1
Deadline: Tuesday 20/09/2022 @ 23:59
[Total Mark for this Assignment is 8]
Student Details:
Name:
ID:
CRN:
Instructions:










You must submit two separate copies (one Word file and one PDF file) using the Assignment Template on
Blackboard via the allocated folder. These files must not be in compressed format.
It is your responsibility to check and make sure that you have uploaded both the correct files.
Zero mark will be given if you try to bypass the SafeAssign (e.g. misspell words, remove spaces between
words, hide characters, use different character sets, convert text into image or languages other than English
or any kind of manipulation).
Email submission will not be accepted.
You are advised to make your work clear and well-presented. This includes filling your information on the cover
page.
You must use this template, failing which will result in zero mark.
You MUST show all your work, and text must not be converted into an image, unless specified otherwise by
the question.
Late submission will result in ZERO mark.
The work should be your own, copying from students or other resources will result in ZERO mark.
Use Times New Roman font for all your answers.
Pg. 01
Learning
Outcome: WK2LO4: Understand
the complexity of
an Algorithm
Ошибка! Используйте вкладку "Главная" для
применения Heading 1 к тексту, который должен
здесь отображаться.
Question One
3 Marks
A. Assume that each of the expressions in the following table has processing
time T(n) to solve a problem of size n. Identify the dominant term(s) having the
growing increase in n and specify the Big-Oh complexity.
Expression
A.1
A.2
8 + 0.081n2 + 0.040n
A.3
100n + 0.081 log3 n + n3
A.4
0.081 log4 n + 81n
Dominant
term(s)
100 + n log2 n
B. Find the Big-Oh for each of the following programs.
B.1
sum = 0;
for(i = 0; i < n; i++)
sum++;
B.2
sum = 0
for(i = 0; i < n; i++)
for( j = 0; j < n * n; j++)
sum++;
Big-Oh
Pg. 02
Learning
Outcome: WK3LO4: Understand
the efficiency of
Linked lists
Ошибка! Используйте вкладку "Главная" для
применения Heading 1 к тексту, который должен
здесь отображаться.
Question Two
1 Mark
Both ArrayList and LinkedList are inefficient for searches, take linear time.
Explain why this occurs in these data structures
Pg. 03
Learning
Outcome:
Ошибка! Используйте вкладку "Главная" для
применения Heading 1 к тексту, который должен
здесь отображаться.
Question Three
2.5 Marks
Write a Java program using Stack class to demonstrate the following activities:
CLO1:
1- Create three empty stacks named stack1, stack2 and stack3 respectively.
Describe basic
2- Push the numbers [6,4,9] into stack1 and [1,2,3] into stack2.
and advanced
3- Pop the top number of stack1 and top number of stack2 and multiply
data structures
such as linked
lists, stacks, and
them. Then, push the multiplication result into stack3.
4- Pop the top number of stack1 and top number of stack2 and divide them.
Push the result of division into stack3.
queues.
5- Print Stack1, stack2 and stack3.
CLO4:
6- Print the largest number in stack3
Demonstrate
[Note: Provide a screenshot of the code output].
implemented
solution with
appropriate data
structure and
algorithm for the
assigned
problem.
Pg. 04
Learning
Outcome:
CLO1:
Ошибка! Используйте вкладку "Главная" для
применения Heading 1 к тексту, который должен
здесь отображаться.
Question Four
1.5 Marks
Write a java program to create a linked list named "grades" with four elements:
"Second grade", "Third grade", "Fourth grade", and "Sixth grade".
Describe basic
and advanced
data structures
such as linked
lists, stacks, and
queues.
CLO4:
Demonstrate
implemented
solution with
appropriate data
structure and
algorithm for the
assigned
problem.
Then do the following activity and provide a screenshot of the code result.
1-
Add a new element "First grade" at the beginning of the linked list using
iterator.
2- Add a new element "Fifth grade" after the element "Fourth grade" using
iterator.
3- Print the LinkedList backward from the last element to the first element
using hasPrevious()
Download