• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 15 pages
Exam (elaborations)

Data Structures and Algorithms

Document preview thumbnail
Preview 2 out of 15 pages

Data Structures and Algorithms

Content preview

CS2336 Midterm ReViEw

If the expression (n - 2)*(n - 4) describes the performance of an algorithm, which of the
following correctly states the algorithm's performance?

A. None of the other options correctly describes the algorithm's performance.
B. O(8)
C. O(1)
D. O(n)
E. O(log n) - Correct Answers-A.
None of the other options correctly describes the algorithm's performance.

What term is used to describe an O(n) algorithm?

A. Constant
B. Quadratic
C. Logarithmic
D. Linear - Correct Answers-D.
Linear

Which tool can help the programmer produce nicely formatted and professional quality
documentation?

A. sublime
B. Libre Office Write
C. pydoc and/or javadoc
D. vim and gvim - Correct Answers-C. pydoc and/or javadoc

Why is writing easily modifiable code important?

A. Easily modifiable code generally has a quicker run time.
B. Most real world programs require change at some time.
C. Several people may be writing the same function at the same time.
D. Most text editors make it easy to modify code. - Correct Answers-B. Most real world
programs require change at some time.

Which of the following formulas in big-O notation best match the expression n²+35n+6 that was
derived from an analysis of a code segment processing n items of data?

, A. O(n³)
B. O(n)
C. O(42)
D. O(n²) - Correct Answers-D. O(n²)

Given the following equivalent code snippets in Java and Python, what is the worst time
behavior expressed in big O notation, assuming n is an integer variable?

// Java
while ( n > 0 ) {
n = n / 10 //integer division
}

# Python
while n > 0:
n = n // 10 # integer division
#end while

A. O(n)
B. O(n²)
C. O(1)
D. O(log10 n) - Correct Answers-D. O(log10 n)

When a method is called, who is responsible for ensuring that the precondition is valid?

A. The person who is using the program.
B. The programmer who wrote the method.
C. The programmer who implemented the Java or Python Runtime System.
D. The programmer who called the method. - Correct Answers-D. The programmer who called
the method.

Which of these is the correct big-O expression for performing the operations 1+2+3+...+n?

A. O(n)
B. O(n²)
C. O(log n)
D. O(n log n) - Correct Answers-A. O(n)

What information do you need to know or read in order to make effective use of a method

Document information

Uploaded on
June 13, 2025
Number of pages
15
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$12.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
222
Last sold
-




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions