1. Explain the heap property of a tree 2. List and describe the 3 methods most o
ID: 3711058 • Letter: 1
Question
1. Explain the heap property of a tree
2. List and describe the 3 methods most often associated with a stack.
3. Identify 3 errors in the following code snippet:
num = input()
def factorial[n]:
if n == 0:
return 1;
else:
return n * factorial(n-1)
num(factorial)
4. Suppose there are 2 circles on a cartesian plane at (1,1) and (4,1), with a radius of m and n respectively. Write psuedocode that determines if the two circles overlap.
5. Use pseudocode to design a class that represents a car.
6. Explain the meaning and use of the global keyword in python
7. Draw a binary search tree containing the items added in order of [14, 5, 21, 3, 7, 8, 9, 1, 12]:
8. Give the Big-O runtime of the following code fragment:
9.Give the Big-O runtime of the following code snippet:
10. Write a python program that uses a dictionary to store the following states and capitals.
Des Moines, Iowa
Jefferson City, Missouri
Albany, New York
Sacramento, California
Austin, Texas
Lincoln, Nebraska
Finally, print the capital of california from your dictionary.
stateCapitals = {}
def addStates(num):
#your solution here
print() # modify this line as well
11.Define the following terms in the context of computer science:
a. Complexity
b. Heuristic
c. Linear
d. Tree
e. Stack
f. Node
g. Graph
h. Queue
i. Quadratic
j. Exception
k. Dictionary
tds = int (input ( "Number of TDs : " ) ) score0 pushups = 0 for i in range (tds): score-7 pushups+= sc re print sting did", pushups, "pushups. ")Explanation / Answer
If you post more than 1 question, as per chegg guidelines I have to solve only first question.
Ques 1. There are two types of heap:
Ques 2. The 3 methods of stack are:
Ques 3.
Correct Code
num = int(input())
def factorial(n):
if n == 0:
return 1;
else:
return n * factorial(n-1)
num(factorial)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.