Reference no: EM13163654
Use recursion to write a Python function depth(LL), where LL is a nested list of lists of lists etc. of numbers (i.e., oat and int) and strings. We want to return the depth of nesting, i.e., how often, maximally, there is a list in a list etc. in LL. You may use the function type(..).
Examples for testing: Single integers, oats and strings have depth 0. In ['a',9] and in [ ] the depth of nesting is 1, since there is no list in a list. In [2,[1],1,[3,2],[5,-1,0.1],1] and in [[ ]] the depth is 2, since there is a list within the list (but no list in a list in a list). In [2,[1,-1,[3,2],[ ],3],1,4,['ab']] and in [[[ ],[ ]],[ ]] the depth is 3; there is a list in a list in a list. In [2,[2,[3],[1,[2]]],1,[2,2]] the depth is 4. Similarly, one could give examples of depth could be 5, 6, etc.
The following auxiliary function create a sample list:
def listsample():
L = []
for i in range(10):
L = L + [L[len(L)//2:]+[i,[i-1]]]
return L[:]
How do you use your depth function to nd the depth of this sample list? Give the calls and their output (as comments).
Write a function trans(m) which returns the transpose
: Write a function trans(M) which returns the transpose of an n-by-n matrix M. The matrix M is represented by a list of n lists, each of length n. Transposing M means that each M[i][j] is swapped (once!) with M[j][i].
|
True or false about networking
: 2- A print queue must be set up for every printer on the network served by a print server. True False
|
Permutation ciphers
: Permutation Ciphers (a.k.a. Transposition Ciphers) are another class of simple cryptosystems. For this we use the functions apply(.,.) and inv(.) from Homework 4; copy these two functions into your le as auxiliary functions.
|
Function should return a dictionary
: Write a function numOccur(s), where s is a string; the function should return a dictionary whose keys are the 26 ascii letters abcdefghijklmnopqrstuvwxyz
|
Recursion to write a python function
: Use recursion to write a Python function depth(LL), where LL is a nested list of lists of lists etc. of numbers (i.e., oat and int) and strings. We want to return the depth of nesting, i.e., how often, maximally, there is a list in a list etc
|
Determine the values for m and l for the b+ tree
: A B+-tree is to be stored on disk whose block size is 2048 bytes. The data records to be stored are 50 bytes, and their key is 4 bytes. Determine the values for M and L for the B+-tree. Assume pointers are 4 bytes each.
|
Let ll be a list of integers
: Let LL be a list of integers. Use list comprehension to produce teh following lists. Each one should just take onel line. Anser questions as two comments.
|
Write a select statement that returns these columns
: Write a SELECT statement that returns these columns from the Products table: The date_added column A column that uses the CAST function to return the date_added column with its date only (year, month, and day)
|
You will write a program that reads a text file
: You will write a program that reads a text file, counts the number of words in the file, and the number of occurrences of each character. It will print to a file the number of words, and the number of occurrences of each character, as well as the ..
|