What is time-complexity to insert item at end of linked list

Assignment Help Data Structure & Algorithms
Reference no: EM131325050

Data structures using JAVA mid term

Q1. Software engineers typically break the software development process into the following four phases: analysis, ____, implementation, testing and debugging.
a. design
b. requirements gathering
c. white box analysis
d. algorithm analysis

Q2. Which of the following functions g(n) has a constant growth rate?
a. n
b. n2
c. n log n
d. 1

Q3. A(n) ____ is a step-by-step problem-solving process in which a solution is arrived at in a finite amount of time.
a. design plan
b. algorithm
c. process plan
d. structured program

Q4. In the ____ process, the program is modified to fix the (identified) problems or to enhance it.
a. software life cycle
b. implementation
c. software maintenance
d. testing

Q5. In ____ copying, each reference variable refers to its own object.
a. shallow
b. deep
c. method
d. object

Q6. The three fundamental stages a program goes through are: implementation, use, and maintenance.
a. true
b. false

Q7. Encapsulation is the ability to handle data and operations as separate units.
a. true
b. false

Q8. Finalizers are value-returning methods that return the final value of a variable.
a. true
b. false

Q9. Software engineers typically break the software development process into the following four phases: analysis, design, implementation, testing, and debugging.
a. true
b. false

Q10. Polymorphism is the ability to use the same expression to denote different operations.
a. true
b. false

Q11. A checked exception is any exception checked for by the programmer.
a. true
b. false

Q12. If there are three classes, Shape, Circle and Square, what is the most likely relationship between them?
a. Square is a superclass, and shape and circle are subclasses of Square.
b. Shape is a superclass, and circle and square are subclasses of Shape.
c. Shape, circle and square are all sibling classes.
d. These three classes cannot be related.

Q13. Inheritance is an example of what type of relationship?
a. is-a
b. has-a
c. was-a
d. had-a

Q14. An abstract method ____.
a. is any method in the abstract class
b. cannot be inherited
c. has no body
d. is found in a subclass and overrides methods in a superclass using the reserved word abstract

Q15. If you have created an exception class, you can define other exception classes extending the definition of the exception class you created.
a. true
b. false

Q16. Any new class you create from an existing class is called a(n) ____.
a. base class
b. superclass
c. derived class
d. extended class

Q17. To determine whether a reference variable that points to an object is of a particular class type, Java provides the operator instanceof.
a. true
b. false

Q18. The class Throwable is derived from the class Exception.
a. true
b. false

Q19. An abstract class ____.
a. does not have any subclasses
b. is a superclass with many subclasses
c. cannot be instantiated
d. is the base class of all other classes

Q20. An abstract class can define ____.
a. only abstract methods
b. only non-abstract methods
c. abstract and non-abstract methods
d. only abstract instance variables

Q21. What does the following statement do: Vector thisVector = new Vector();
a. Creates an empty vector
b. Creates a vector with 10 elements
c. This statement does not do anything
d. Creates an array

Q22. A list is a collection of elements of the same type.
a. true
b. false

Q23. The method remove for unordered lists uses which combination of methods to remove an item from the list?
a. seqSearch and removeAt
b. removeAt and replaceAt
c. retrieveAt and removeAt
d. seqSearch and replaceAt

Q24. The elements of an object of the class UnorderedArrayList are always sorted.
a. true
b. false

Q25. Which method would you most likely use to add an element to an end of a vector?
a. insertElementAt
b. addElement
c. copyInto
d. lastElement

Q26. The method clone in the class Vector returns a copy of the vector.
a. true
b. false

Q27. A list is full if length is equal to maxSize.
a. true
b. false

Q28. The method ____ removes the elements from the list, leaving it empty.
a. deleteElements
b. removeAt
c. clearList
d. deleteList

Q29. The class ArrayListClass is the subclass of the classes that implement a list.
a. true
b. false

Q30. Which of the following methods requires the shifting of elements?
a. replaceAt
b. retrieveAt
c. insertEnd
d. insertAt

Q31. In an ordered list, we need to modify the algorithms (from a normal linked list) to implement the search, insert, and delete operations.
a. true
b. false

Q32. Searching, inserting, and deleting require traversal of the linked list.
a. true
b. false

Q33. What is the time-complexity to insert an item at the end of a linked list?
a. O(1)
b. O(n)
c. O(n2)
d. O(log n)

Q34. What is the time-complexity of the LinkedListClass copy constructor?
a. O(1)
b. O(n)
c. O(n2)
d. O(log n)

Q35. Building a linked list forward places the new item to be added at the beginning of the linked list.
a. true
b. false

Q36. To delete a given item from an ordered linked list, there is no need to search the list to see whether the item to be deleted is in the list.
a. true
b. false

Q37. In the class LinkedListClass, the search method is declared as ____.
a. public
b. private
c. abstract
d. protected

Q38. By using one reference variable to insert an item into a linked list, the order of the sequence of events is irrelevant.
a. true
b. false

Q39. In an ordered linked list the search algorithm is somewhat improved because the list is ____.
a. larger
b. smaller
c. higher
d. sorted

Q40. In a doubly linked list, some of the operations require modification from how they were implemented for a regular linked list, because of the ____ reference variable(s) in each node.
a. null
b. two
c. three
d. four

Q41. public static int rFibNum(int a, int b, int n)
{
if(n == 1)
return a;
else if(n == 2)
return b;
else
return rFibNum(a, b, n - 1) + rFibNum(a, b, n - 2);
}

What is the limiting condition of the code above?
a. n >= 0
b. a >= 1
c. b >= 1
d. n >= 1

Q42. The body of a recursive method contains a statement that causes the same method to execute before completing the current call.
a. true
b. false

Q43. The overhead associated with iterative methods is greater in terms of both memory space and computer time, when compared to the overhead associated with executing recursive methods.
a. true
b. false

Q44. public static int exampleRecursion (int n)
{
if (n==0)
return 0;
else
return exampleRecursion(n-1) + n*n*n;
}

How many base cases are in the code above?
a. 0
b. 1
c. 2
d. 3

Q45. The general case is the case for which the solution is obtained directly.
a. true
b. false

Q46. A recursive method in which the first statement executed is a recursive call is called a tail recursive method.
a. true
b. false

Q47. Recursive algorithms are implemented using while loops.
a. true
b. false

Q48. private int func1(int m, int n) {
if (m==n || n==1)
return 1;
else
return func1(m-1,n-1) + n*func1(m-1,n);
}

Which of the following would be an invalid call to the method above?
a. func1(0, 1)
b. func1(1, 0)
c. func1(4, 9)
d. func1(99999, 99999)

Q49. There are two base cases in the recursive implementation of generating a Fibonacci sequence.
a. true
b. false

Q50. private int func2(int m, int n) {
if (n == 0)
return 0;
else
return m + func2(m, n-1);
}

What is the limiting condition of the code above?
a. n >= 0
b. m > n
c. m >= 0
d. n > m

Reference no: EM131325050

Questions Cloud

How did they express this opinion through style : Start a discussion about how the visual appearance of this work reflects its culture/society. (E.g. Many art movements emerged in response to WWI, and the styles and subject matter of the art they created reflect their various opinions of war--did..
Prepare journal entry to establish the fund on january : Prepare journal entry to establish the fund on January 1, reimburse it on January 8, and reimburse the fund and increase it to $270 on January 8, assuming no entry in part 2. (Hint: Make two separate entries for part 3.)
What is the total return of the stock over the past year : One year ago, the stock price was $245.Today, the stock price is $257.Over the year, the firm distributed Dividends of $1.25 per share. What is the total return of the stock over the past year?
Determine the marginal revenue product function : Suppose that output can be sold for $10 per unit. Also assume that the firm can obtain as much of the variable input (L) as it needs at $20 per unit.
What is time-complexity to insert item at end of linked list : CST 227- What is the time-complexity to insert an item at the end of a linked list? In an ordered list, we need to modify the algorithms (from a normal linked list) to implement the search, insert, and delete operations.
Why do companies across the world turn to petipa : Marius Petipa is arguably the most significant ballet choreographer prior to the 20th century. His works still offer the magic and majesty that has captured audiences since their premieres. What is the relevance of these works as we move into the ..
Prepare a bank reconciliation for del gato clinic : Prepare a bank reconciliation for Del Gato Clinic using the information - The June 30 cash receipts of $2,939 were placed in the bank's night depository after banking hours and were not recorded on the June 30 bank statement.
Organize a plan of action to get the project back on track : Suggest three (3) ways to improve an underperforming team member. Organize a plan of action to get the project back on track. Develop a new critical path
Mechanism as a form of photosynthesis : Make a brief argument for or against the described mechanism as a form of photosynthesis.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Creating villian

Announce a new Villian called sharpay who has a wit of 24, a stealth of sixteen, and who has currently claimed three victims: Chad, Troy, and Gabriella.

  Create a default and parameterized constructor

Create a default and parameterized constructor. Create sets/gets for all instance variables. Create a get method to calculate and return the profit or loss. This would be calculated as Number of shares * (current price - purchase price).

  Write algorithm so that it only works with primitive data

Your algorithm must use Comparable objects. Do not write the algorithm so that it only works with primitive data values such as int or double.

  What is global or per process page replacement algorithms

What is better global or per process page replacement algorithms?

  Data structures and algorithms

Provides learners with an understanding of how data structures are used in algorithms and enables them to design and implement data structures

  What is the minimum number of attendants

A nursing home employs attendants who are needed around the clock. Each attendant is paid the same, regardless of when his or her shift begins. Each shift is 8 consecutive hours.

  What items do we require for a small business wlan what

imagine that you work at a small company with 75 employees in a modern office building. some of the employees are eager

  Initialize accumulator variable for total rainfall to zero

Set a constant named SIZE to 12. This represents the total number of elements in the array. Initialize an accumulator variable for the total rainfall to 0.

  Flow chart of converting for hex

Flow chart of converting for Hex

  What do you mean by query evaluation plan what are its

question 1 what is a query evaluation plan? what are its advantages and disadvantages?question 2 discuss the different

  Can you draw the given tree if not explain

A binary tree has seven nodes. The preorder and post order traversals of the tree are given below. Can you draw the tree? If not, explain. Preorder: GFDABEC, Post order: ABDCEFG.

  Find the longest monotonically

Describe an O(n) time algorithm that, given a set S of n distinct numbers and a positive integer k ≤ n, determines the k numbers in S that are closest to the median of S.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd