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
2 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]2 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
Which diagram is NOT a good model of 3÷14?
swat32
I need a pic for this
7 0
2 years ago
Read 2 more answers
During boom times, which of the
pashok25 [27]
I think the answer is D.
3 0
2 years ago
The LList class is (mostly) the same one discussed in lecture, but you must write a sort() function that uses one of the three i
Vladimir79 [104]

Answer:

see explaination

Explanation:

#include <iostream>

#include <string>

using namespace std;

class LinkedList{

class Node{

public :

int data;

Node* next;

Node(int data){

this->data = data;

next = NULL;

}

};

public :

Node *head;

LinkedList(){

this->head = NULL;

}

void insert(int d){

Node* new_node = new Node(d);

new_node->next = head;

head = new_node;

}

// sort the list with selection sort algorithm.

// Pick the smallest element in the unsorted array and place in the first element in the unsorted.

void sort_list(){

if (head == NULL){

return;

}

Node* current = head;

while (current->next != NULL){

Node* min_node = current;

Node* traverse = current->next;

while(traverse != NULL){

if(traverse->data < min_node->data){

min_node = traverse;

}

traverse = traverse->next;

}

int temp = current->data;

current->data = min_node->data;

min_node->data = temp;

current = current->next;

}

}

void print_list(){

Node* current = head;

while(current !=NULL){

cout<<current->data<<" ";

current = current->next;

}

cout<<"\n";

}

};

int main(){

LinkedList ll;

for(int i=0;i<10;i++){

ll.insert(i);

}

ll.print_list();

cout<<"*******************************************\n";

ll.sort_list();

ll.print_list();

cout<<"*******************************************\n";

}

8 0
3 years ago
Consider two different implementations, M1 and M2, of the same instruction set. There are three classes of instructions (A, B, a
Margaret [11]

Explanation:

A.)

we have two machines M1 and M2

cpi stands for clocks per instruction.

to get cpi for machine 1:

= we multiply frequencies with their corresponding M1 cycles and add everything up

50/100 x 1 = 0.5

20/100 x 2 = 0.4

30/100 x 3 = 0.9

CPI for M1 = 0.5 + 0.4 + 0.9 = 1.8

We find CPI for machine 2

we use the same formula we used for 1 above

50/100 x 2 = 1

20/100 x 3 = 0.6

30/100 x 4 = 1.2

CPI for m2 =  1 + 0.6 + 1.2 = 2.8

B.)

CPU execution time for m1 and m2

this is calculated by using the formula;

I * CPI/clock cycle time

execution time for A:

= I * 1.8/60X10⁶

= I x 30 nsec

execution time b:

I x 2.8/80x10⁶

= I x 35 nsec

6 0
2 years ago
To reduce chances of system failure, engineers may use _____ .
Nataliya [291]
<span>To reduce chances of system failure, engineers may use process control. This is a system which involves activities that ensures the whole process variables can be predicted and controlled to prevent failure. This involves the use of safety valves and sensors.</span>
5 0
3 years ago
Read 2 more answers
Other questions:
  • When considering changing the content of a cell which button should you press to leave the cell as it originally was? 
    5·1 answer
  • What type of machine is a hand drill?<br><br> A. Simple machine <br> B. Compound machine
    8·2 answers
  • How should work be allocated to the team in a Scrum project?
    13·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    13·1 answer
  • I need help about computer program. Solve C language code...... please​
    7·1 answer
  • What is cache memory?Mention its importance. ​
    12·1 answer
  • what is the arrangement of various flash elements, such as the tools panel, control panel, property inspector and stage
    12·1 answer
  • Which tool in Access will give you a detailed report showing the most accurate and complete picture of
    7·1 answer
  • Ryan would like to copy a list of contacts from a colleague into his personal address book. The list of contacts is contained in
    11·1 answer
  • ___________ is some danger that can exploit a vulnerability.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!