1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
fomenos
3 years ago
12

We can sort a given set of n numbers by first building a binary search tree containing these numbers (using Tree-Insert repeated

ly to insert the numbers one by one) and then printing the numbers by an inorder tree walk. What are the worst-case and best-case running times for this sorting algorithm?

Computers and Technology
1 answer:
OLga [1]3 years ago
5 0

Worst case for binary search tree -O(n)

Best case for binary search tree -O(1)

<u>Explanation:</u>

The Binary search tree is the special type of binary tree. There are two child node

  1. Left child node
  2. Right child node  
  • In that, the right child node has a value greater than it’s the parent node. The left child node has value less than it’s the parent node.
  • In the below fig. for inserting element 0, it must be inserted as the left child of 1. Therefore, for sorting we have traveled in reverse order from (3,2,1) this is the worst-case complexity O(n).

You might be interested in
Write a program that inputs two characters first and second, and then prints all non-alphabetic characters starting from second
baherus [9]

Answer:

fbtcft gdfgfffff tvfft gxf

8 0
3 years ago
Problem 6. (Fibonacci Number) Write a program fibonacci.py that accepts n (int) as command-line argument, and writes to standard
77julia77 [94]

Answer:

  1. import sys
  2. def fibonacci(n):
  3.    if(n == 0 or n == 1):
  4.        return n  
  5.    else:
  6.        return fibonacci(n - 2) + fibonacci(n-1)
  7. num = int(sys.argv)  
  8. output = ""
  9. for i in range(1, num+1):
  10.    output += str(fibonacci(i)) + " "  
  11. print(output)

Explanation:

Firstly, we import sys module as we need to accepts n as command line argument (Line 1).

Next, create a function fibonacci takes take one input n (Line 3). If the n is zero or one, return the n itself (Line 4-5). Otherwise, the program shall run the recursive call to the fibonacci function itself by putting n-2 and n-1 as function argument, respectively (Line 6-7).

After that, use the sys.argv to get the command line argument and assign the value to num (Line 9).

Use a for loop to generate the output string by progressively calling the fibonacci function and join the return result to the output string (Line 12-13).

At last print the output string (Line 15).

7 0
3 years ago
Write a program that reads in 10 numbers and displays the number of distinct numbers and the distinct numbers in their input ord
Alla [95]

Answer:

Explanation:

The following code is written in Python. It creates a for loop that iterates 10 times, asking the user for a number every time. It then checks if the number is inside the numArray. If it is not, then it adds it to the array, if it is then it skips to the next iteration. Finally, it prints the number of distinct numbers and the list of numbers.

numArray = []

for x in range(10):

   num = input("Enter a number")

   if int(num) not in numArray:

       numArray.append(int(num))

print("Number of Distince: " + str(len(numArray)))

for num in numArray:

   print(str(num), end = " ")

8 0
3 years ago
Suppose one hundred stores participated in the
Sindrei [870]
I think the answer is A
7 0
4 years ago
How does Digest Authentication (also know as Challenge-based Authentication) prevent replay attacks?
Karo-lina-s [1.5K]

Answer and Explanation:

Digest authentication :

Digest authentication is a technique of authentication in which a request from potential client is received by a system server and after that sent to a space controller.

How it is work :

Digest authentication averts replay assaults by utilizing a server-indicated nonce. The server produces an irregular nonce when the customer endeavors to make an unauthenticated demand, customer needs to join the nonce into its reaction. It's dependent upon the server to oversee substantial nonces, and nullify them when they've been utilized, to anticipate replays

8 0
4 years ago
Other questions:
  • True or false? The largest component of a database is a field.
    12·2 answers
  • Qual foi o primeiro computador no mundo a ser criado e qual é a hitória por trás?
    8·1 answer
  • How is a computer and a iphone different
    9·1 answer
  • The interactive process through which people learn the basic skills, values, beliefs, and behavior patterns of a society.
    6·1 answer
  • DNA structure can be described as a twisted ladder. Imagine you are climbing a model of DNA, just as if you were climbing a ladd
    10·2 answers
  • Discuss briefly four types of websites and the criteria you will use to evaluate the content of a website
    8·1 answer
  • Three advantages to the company of using robots rather than human to manufacture company​
    13·1 answer
  • RIGHT ANSWER GETS BRAINLEST
    5·1 answer
  • Compare and contrast the various write strategy used in cache technologies<br>​
    13·1 answer
  • When you type information into a document property field on the cover page, Word does not automatically add this information to
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!