0% found this document useful (0 votes)
6 views2 pages

Quiz 1

Uploaded by

Athir Tarraz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Quiz 1

Uploaded by

Athir Tarraz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Quiz

CS341: Data structures and Algorithms


Full Name:

1. What is a data structure:



A way of arranging data in the memory
□ A way of keeping data with an order
□ A way of analyzing data
□ There is no formal definition for data structure
2. Which of the following functions has the largest growth rate :
□ n1/2
□ n100
□ 2n
√ n!/2
2
3. What is the disadvantage of an array data structure:

The amount of memory allocated should be known beforehands
□ Elements of an array can be accessed in constant time
□ Elements are stored in contiguous memory blocks
□ Multiple other data structures can be implemented using arrays
4. A sorted list of 10 items, how many comparisons will a linear search need before it knows
that a value is NOT in the list :
□ 9
□ 5

10
□ 12
5. What is the time complexity to insert an element to the front of an array of n elements :

O(n)
□ O(1)
□ O(logn)
□ O(nlogn)
6. Given a sorted list of n elements, how many comparisons will a binary search need before
it knows that a value is NOT in the list:
□ O(n)
□ O(1)

O(logn)
□ O(nlogn)
7. Ordered arrays, compared with unordered arrays, are
□ much quicker at deletion.
□ quicker at insertion.
□ quicker to create.

quicker at searching
8. Algorithm A and B have a worst case running time of O(n) and O(logn) respectively. So
algorithm B always runs faster than A.
□ True

False. Only when n gets larger B is faster than A. For example: A =
n/100 is faster than B= 1000*log(n) for small n.
What will be the output of the following code snippet:

□ 5
□ 15
□ 9

6
9. A binary search is to be performed on the list: [1, 5, 10, 13, 48, 68, 100, 101]. How many
comparisons would it take to find number 101?
□ 1
□ 2
□ 3

4 (101 > 13, 101 > 68, 101 > 100, 101 = 101 : number found)
What is the time complexity to insert an element at the end of an array of n elements :
□ O(n)

O(1)
□ O(logn)
□ O(nlogn)
10. In an unsorted array, it’s generally faster to find out an item is not in the array than to find
out it is.
□ True

False

Page 2

You might also like