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
Lerok [7]
3 years ago
10

Draw the BST where the data value at each node is an integer and the values are entered in the following order 36,22,10,44,42,16

,25,3,23,24 solution

Computers and Technology
1 answer:
Tems11 [23]3 years ago
8 0

Answer and Explanation:

A BST is the short form for Binary Search Tree. It is a special type of binary tree data structure in which nodes are arranged in a particular order such that;

i. the left subtree of a particular node should always contain nodes whose key values are less than that of the key value of the node itself.

ii. the right subtree of a particular node should always contain nodes whose key values are greater than that of the key value of the node itself.

iii. the right and left subtrees should also be a binary search tree.

For the given set of data:

36,22,10,44,42,16,25,3,23,24;

The equivalent binary search tree is attached to this response.

<em>As shown in the attachment:</em>

i. the first data value (36) is the root node value.

ii. the second value (22) is less than the root node value (36), therefore, 22 goes to the left of the root node.

iii. the third value is 10. This is less than 36 and then also less than 22, so 10 goes to the left of 22.

iv. the fourth value is 44. This is greater than the root node value (36), therefore, 44 goes to the right of the root node.

v. the fifth value is 42. This is greater than the root value (36) so it is going to be positioned somewhere at the right of the root node. But it is less than the value (44) of the direct right node of the root node. Therefore, 42 goes to the left of the direct right (44) of the root node.

vi. the sixth value is 16. This is less than the root node value (36). So it is going to be positioned somewhere at the left of the root node. It is also less than the value (22) of the direct left node of the root node. So it is going to be positioned somewhere at the left of the node with 22. But it is greater than the node with 10. Therefore, 16 is going to be to the right of the node with 10.

This trend continues until all data values have been rightly positioned.

<em>PS: A binary tree is a data structure in which each node cannot have more than two nodes directly attached to it.</em>

<em />

You might be interested in
A typical setup for a ____ network would include computer users sharing a single internet connection.
konstantin123 [22]
Could be 'home or work' or intranet. Not enough context to answer any better.
3 0
4 years ago
What is the task included in the information systems manager?​
kobusy [5.1K]

Answer:

research and install new systems and networks. implement technology, directing the work of systems and business analysts, developers, support specialists and other computer-related workers. evaluate user needs and system functionality, ensuring that IT facilities meet these needs.

Explanation:

5 0
3 years ago
What are the objects in object-oriented programming language?
VMariaS [17]

Answer:

An object is an abstract data type with the addition of polymorphism and inheritance. Rather than structure programs as code and data, an object-oriented system integrates the two using the concept of an "object". An object has state (data) and behavior (code). Objects can correspond to things found in the real world.

hope it helps ya mate.

5 0
3 years ago
Many networks are set up using a hierarchical architecture to create a "backbone" network. In this system, several connected rou
34kurt

Answer:

Explanation:

For example with the hierarchical network design of Cisco (three-layer) it is worth mentioning the following benefits:

- This type of infrastructure is highly reliable

- The complex problem regarding network design is broken into smaller and manageable areas.

- Improved access, access, core layers and distribution

-  The hierarchy provides specific functions important in defining its role within the whole network.

Regarding the access layers in the hierarchy the following are core benefits:

- Layer 2 switching

- Virtual access control lists (VACLs)

- Power over Ethernet (PoE) and auxiliary VLANs for VoIP

- Spanning tree

- High availability

- Port security

- Address Resolution Protocol (ARP) inspection

5 0
4 years ago
1. Atestharnessprogramfortestingsortingmethodsisprovidedwiththeprogram iles.ItisintheileSorts.javainthech11.sortspackage.Theprog
tiny-mole [99]

Answer:

Following are the code to this question:

//import package

import java.util.*;

import java.text.*;

public class Main//defining a class

{

static final int t = 50;//defining an integer constant variable

static int[] ele = new int[t];//defining an array

static int tS = 0;//defining integer variable

static void initelements()//defining a static method

{

Random r= new Random();//creating Random class Object

for (int i = 0; i < t; i++)//use loop to add value in array

ele[i] = Math.abs(r.nextInt()) % 100;//add value in array

}

static public boolean isSorted()//defining a method isSorted

{

boolean x = true;//defining boolean variable

for (int i = 0; i < (t - 1); i++)//use for loop to count array values

if (ele[i] > ele[i + 1])//use if to compare array values

x = false;//use boolean variable to hold false value

return x;//return boolean value

}

static public void swap(int x1, int x2)//defining swap method

{

tS++;//increment variable value by 1

//performing swapping

int te = ele[x1];//defining te variable that holds array values

ele[x1] = ele[x2];//exchanging array values

ele[x2] = te;//holding te values

}

static public void disp()//defining a method disp

{

int v1;

DecimalFormat f = new DecimalFormat("00");//creating DecimalFormat class Object

System.out.println("The elements array is:");//print message

for (int i = 0; i <t; i++)//defining for loop  

{

v1 = ele[i];//holding array value in v1 variable

if (((i + 1) % 10) == 0)//use if to check i value

System.out.println(f.format(v1));//print value

else//else block

System.out.print(f.format(v1) + " ");//print value

}

System.out.println();//print space

}

static int getMinimum(int st, int en)//defining a method getMinimum

{

int iMi = st;//defining variable that holds parameter value

for (int i = st + 1; i <= en; i++)//use for loop compare array value

if (ele[i] < ele[iMi])//compare array value

iMi = i;//use iMi to hold loop value

return iMi;//return iMi value

}

static void selectionSort()//defining a selectionSort method

{

int e = t - 1;//defining e variable that holds total array count value

for (int i = 0; i < e; i++)//use for loop to call swap method  

swap(i, getMinimum(i, e));//calling the swap method

}

public static void main(String[] args)//defining main method  

{

initelements();//calling initelements method

disp();//calling disp method

System.out.println("elements is sorted: " + isSorted());//calling is isSorted method with the message

System.out.println();//for space

selectionSort();//calling selectionSort method

System.out.println("No of swaps :" + tS);//print totalswap value with the message

disp();//calling disp method

System.out.println("elements is sorted: " + isSorted());//calling is isSorted method with the message

System.out.println();//for space

}

}

Output:

Please find the attached file.

Explanation:

In this code inside the Main class, 5 static methods "initelements, isSorted, swap, disp, getMinimum and selectionSort" is declared, in which the first method holds random values in arrays, in second array it sorts its values, in the third method it swap the array, in the disp method it shows array values.

In the "getMinimum and selectionSort"  it sorts array values and inside the main method, it calls all methods and prints their values.

3 0
3 years ago
Other questions:
  • Write a program LotheryPrinter that picks a combination in a lottery. In this lottery, players can choose 6 numbers ( possibly r
    9·1 answer
  • Visual images taken directly from a source, such as pictures, charts, and graphs do not need a citation. true or false.
    8·1 answer
  • Jenny needs to record the names of 30 students, write down the subjects they studied, and note grades in each subject after the
    13·2 answers
  • The purpose of the align phase is to align your team with ______.
    9·1 answer
  • Hello I'm new to coding and in my class, we have jumped straight into coding with zero experience and or lessons, this is my fir
    14·1 answer
  • Package hw1;
    10·1 answer
  • The smallest unit of storage is​
    15·1 answer
  • How do news organizations primarily create revenue?
    12·2 answers
  • HELP ASAP!!<br> What is the difference between an internal event and an external event?
    10·1 answer
  • UCLA Extension's marketing department wants
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!