Big O Notation Homework: Identifying Complexity of Functions and Algorithms, Assignments of Data Structures and Algorithms

A homework assignment focused on identifying the big o notation for various functions and algorithms. Students are required to determine the big o notation for given definitions, such as constant, logarithmic, linear time, poly-logarithmic, and polynomial. Additionally, they must analyze the worst-case running time of specific algorithms using big o notation, including a sorted list search, creating a spreadsheet, and loops with different structures. Essential for students studying computer science, algorithms, and data structures.

Typology: Assignments

Pre 2010

Uploaded on 02/25/2010

koofers-user-lfq
koofers-user-lfq 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Big O homework
Big O homework
1. Choose the Big O for the following definitions
1. Choose the Big O for the following definitions
Constant,
Constant, Logarithmic(lg2 of N): Linear Time( n): Poly-logarithmic (n log n): Polynomial(n
Logarithmic(lg2 of N): Linear Time( n): Poly-logarithmic (n log n): Polynomial(n^2)
^2):
:
________ Very fast. Include no loops
________ Very fast. Include no loops
__________Also very fast. Typical of many algorithms where the size of the input is halved
__________Also very fast. Typical of many algorithms where the size of the input is halved
each iteration of a loop.
each iteration of a loop.
_______Typical of fast algorithms on a single-processor computer, if all the input of size n
_______Typical of fast algorithms on a single-processor computer, if all the input of size n
has to be read.
has to be read.
_________Typical of the best sorting algorithms. The outer loop processes all N, the inner
_________Typical of the best sorting algorithms. The outer loop processes all N, the inner
loop halves the size of items to be processed each iteration
loop halves the size of items to be processed each iteration
____When a problem of size n can be solved in time n^k where k is a constant. Small n's (n
____When a problem of size n can be solved in time n^k where k is a constant. Small n's (n
<= 3) is OK.
<= 3) is OK.
2. What is the Big of the following function
2. What is the Big of the following function
f(N) = N4 +
f(N) = N4 + 100
100N2 +
N2 + 10
10N +
N + 50
50
3. Characterize, using big-Oh notation, the worst-case running time of the following algorithms:
a) A loop that searches a sorted list of numbers using the most efficient algorithm for such an
operation __________________________
b) Creating a spreadsheet ____________
c) Loops like the following:
for(int i = 0; i < N; i = i + 2){} ________
for (int x = N; x > 0; x = x/2)
for(int i = 1; i < N i = i * 2){} __________
d) The add method for the ArrayList(unsorted) ___________________

Partial preview of the text

Download Big O Notation Homework: Identifying Complexity of Functions and Algorithms and more Assignments Data Structures and Algorithms in PDF only on Docsity!

Big O homeworkBig O homework

  1. Choose the Big O for the following definitions 1. Choose the Big O for the following definitions Constant, Constant, Logarithmic(lg2 of N): Linear Time( n): Poly-logarithmic (n log n): Polynomial(nLogarithmic(lg2 of N): Linear Time( n): Poly-logarithmic (n log n): Polynomial(n^2)^2)::   ________ Very fast. Include no loops________ Very fast. Include no loops   __________Also very fast. Typical of many algorithms where the size of the input is halved__________Also very fast. Typical of many algorithms where the size of the input is halved each iteration of a loop. each iteration of a loop.   _______Typical of fast algorithms on a single-processor computer, if all the input of size n_______Typical of fast algorithms on a single-processor computer, if all the input of size n has to be read. has to be read.   _________Typical of the best sorting algorithms. The outer loop processes all N, the inner_________Typical of the best sorting algorithms. The outer loop processes all N, the inner loop halves the size of items to be processed each iteration loop halves the size of items to be processed each iteration   ____When a problem of size n can be solved in time n^k where k is a constant. Small n's (n____When a problem of size n can be solved in time n^k where k is a constant. Small n's (n <= 3) is OK. <= 3) is OK. 2. What is the Big of the following function 2. What is the Big of the following function f(N) = N4 + f(N) = N4 + 100100 N2 +N2 + 1010 N +N + 5050
  2. Characterize, using big-Oh notation, the worst-case running time of the following algorithms: a) A loop that searches a sorted list of numbers using the most efficient algorithm for such an operation __________________________ b) Creating a spreadsheet ____________ c) Loops like the following: for(int i = 0; i < N; i = i + 2){} ________ for (int x = N; x > 0; x = x/2) for(int i = 1; i < N i = i * 2){} __________ d) The add method for the ArrayList(unsorted) ___________________