Algorithmic Problem Solving Final Exam
Point out the correct statement: a) NumPy main object is the homogeneous multidimensional array b) In Numpy, dimensions are called axes c) Numpy array class is called ndarray d) All of the Mentioned
All of the Mentioned
Which of the following library is similar to Pandas? a) NumPy b) RPy c) OutPy d) None of the Mentioned
NumPy
Consider the usual algorithm for determining whether a sequence of parentheses is balanced.The maximum number of parentheses that appear on the stack AT ANY ONE TIME when the algorithm analyzes: (()(())(())) are:
3
The given array is arr = {1,2,4,3}. Bubble sort is used to sort the array elements. How many iterations will be done to sort the array with improvised version?
4
Suppose the first fibonnaci number is 0 and the second is 1. What is the sixth fibonnaci number?
5
Which of the following input can be accepted by DataFrame ? a) Structured ndarray b) Series c) DataFrame d) All of the Mentioned
All of the mentioned
What best describes an array?
Container of objects of similar types
Is Quick Sort a stable algorithm?
No
Pandas vs NumPy
NumPy: Low-level data structure (np.array). Support for large multi-dimensional arrays and matrices. A wide range of mathematical array operations Pandas: High-level data structures (data frames). More streamline handling of tabular data, and rich time series functionality. Data alignment, missing-data friendly statistics, groupby, merge and join methods. You can use Pandas data structures, and freely draw on NumPy and SciPy functions to manipulate them.
What is the time complexity of the above recursive implementation to find the nth fibonacci number?
O(2^n)
What is the best case efficiency of bubble sort in the improvised version?
O(n)
What is the average case complexity of bubble sort?
O(n^2)
What is the worst case complexity of bubble sort?
O(n^2)
What are the advantages of an array?
a) Easier to store elements of same data type b) Used to implement other data structures like stack and queue c) Convenient way to represent matrices as a 2D array
What are the disadvantages of arrays?
a) We must know before hand how many elements will be there in the array b) There are chances of wastage of memory space if elements inserted in an array are lesser than than the allocated size c) Insertion and deletion becomes tedious
Which of the following is contained in NumPy library?
a) n-dimensional array object b) tools for integrating C/C++ and Fortran code c) fourier transform
print the version of pandas that has been imported
pd._version_
Which of the following object you get after reading CSV file?
DataFrame
What is the advantage of bubble sort over other sorting techniques?
Detects whether the input is already sorted
Which of the following recurrence relations can be used to find the nth fibonacci number?
F(n) = F(n - 1) + F(n - 2)
print out all the version information of the libraries that are required by the pandas library
pd.show_version()
Create a DataFrame df from the dictionary data which has the index labels
df = pd.DataFrame(data, index = 'labels')
Display a summary of the basic information about this DataFrame and its data
df.info() df.describe()
return the first 3 rows of the DataFrame df
df.loc[:3]
Select just the animal and age columns from the DataFrame df
df['animal','age']
Select the rows the age is between 2 and 4
df[df['age'.inBetween(2,4)]
Select the rows where the age is missing
df[df['age'].isnull()]
Select the rows where the animal is at and the age is less than 3
df[df['animal' == 'cat', ['age' < 3]]]
Import pandas
import pandas as pd
Which of the following statement will import pandas?
import pandas as pd
Process of inserting an element in stack is called
push
Point out the wrong statement: a) ipython is an enhanced interactive Python shell b) matplotlib will enable you to plot graphics c) rPy provides a lot of scientific routines that work on top of NumPy d) all of the Mentioned
rPy provides a lot of scientific routines that work on top of NumPy
What arithmetic operators cannot be used with strings?
-
print(0xA + 0xB + 0xC)
33
How does Matrix addition work?
X = [[12,7,3], [4 ,5,6], [7 ,8,9]] Y = [[5,8,1], [6,7,3], [4,5,9]] result = [[0,0,0],[0,0,0],[0,0,0]] # iterate through rowsfor i in range(len(X)): # iterate through columns for j in range(len(X[0])): result[i][j] = X[i][j] + Y[i][j] for r in result: print(r)
