I need help with my exam data structure class through Java. It will be 7 questions and 1 hour time. The exam info paper is attached. The exam will be Friday around 7 pm in eastern time.
CSIT 254 – Midterm Exam Info
Approx. 5-7 questions
Topics:
Big-O( )
i.
Given an algebraic formula for the number of steps (loose. and precise), determine the
Big-O()
[ for examples see Homework 1 and Data Structure Lab 01-#1 ]
ii.
Given an algorithm, determine the algebraic formula for the number of steps (loose and
precise), determine the Big-O()
(algorithm will be based on an array of ints – there will be two questions like this)
(Similar to Data Structure Lab 01-#2 )
Example: Given a fully populated array of n integers called data, (data.length is n) also
also an array of n integers called count (already initialized to 0), for data[i] , the number
of elements in data from data[0] to data[n-1] that are equal to data[i] is stored in
count[i], consider this algorithm:
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
if (data[j] == data[i])
count[i]++;
}
}
For the above method, determine:
a. Describe the situation for the worst case. This is an English description similar
to the homework. This is not code.
b. Describe what happens in the code in the worst case.
c. formula for the # of steps in the worst case, when n is very large: loose and
precise (15 points)
d. big-O notation for the worst case, when n is very large: loose and precise (5
points)
Collection Classes
i.
ii.
What are collection classes.
What kinds of operations do they perform.
Linked Lists
1
CSIT 254 – Midterm Exam Info
iii.
Given a problem description based on a populated linked list of int nodes(data is int,
link points to int node), write the contents of a method in a javaesque fashion that
solves the problem. Then determine the algebraic formula for the number of steps,
determine the Big-O()
Example:
Given a linked list of n int nodes with pointer to first node called head, calculate
the average of the numbers in the linked list, then calculate the number of
nodes that are above the average. The UML for IntNode would be provided for
the exam
partial hint: for (cursor = head; cursor!= null; cursor = cursor.getLink())
IV.
Given a picture of a linked list of StringNode (UML provided for exam) with some
pointers pointing to some nodes ( head to first, cursor pointing to a node, previous
pointing to the node before cursor ), write the line(s) of code to add a new node before
cursor.
Example: (like Data Structure Lab 03) add newElement before cursor where
newElement is “Mango”
2