Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9188949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:08:06+00:00 2026-06-17T20:08:06+00:00

For the below code, I’m getting the following error: SearchTree.java:19: error: ‘void’ type not

  • 0

For the below code, I’m getting the following error:

SearchTree.java:19: error: 'void' type not allowed here
  this.setRoot(this.insertgt(this.insertionSort(value)));

What’s the problem?

Code:

import java.util.Arrays;

public class SearchTree {
    private TreeNode root;
    private static int sum = 0;
    public void setRoot(TreeNode n){
        this.root = n;  
    }

    public TreeNode getRoot(){
        return this.root;   
    }

    // returns a SearchTree
    public void insert(int[] value) {
        System.out.println(value == null);
        this.setRoot(this.insertgt(this.insertionSort(value)));
    }

    public void insertgt(int[] value) {
        if (value.length == 0) return;
        TreeNode currentNode;
        currentNode.left = new TreeNode(ArrayMinimum.minimum(value));
        if (value.length > 0) {
            currentNode = new TreeNode(insertgt(value));
            currentNode.right = new TreeNode(insertgt(value));
        }
        return currentNode;
    }

    // returns sum of node.values
    public int sum() {
        if (this.left == null && this.right == null) return sum;
        sum = this.value + sum;
        if (this.left != null && this.right != null) {
            sum = this.left.sum();
            sum = this.right.sum();
        }
    }

    // returns number of nodes
    public int numberOfLeafs() {
        if (this.left == null && this.right == null)
            return(1 + this.left.numberOfLeafs() + this.right.numberOfLeafs());
        return(1 + this.left.numberOfLeafs() + this.right.numberOfLeafs() );
    }   

    // returns zahl if searchTree contains zahl
    public int search(int zahl) {
        if (this.value == zahl) return null;
        return(1 + this.left.search(zahl) + this.right.search(zahl));
    }   

    public int[] insertionSort(int[] data) {
        for(int i = 1; i < data.length; i++) {
            int t = data[i];
            int j = i - 1;
            while(j >= 0 && data[j] > t) {
                data[j + 1] = data[j];
                j--;
            }
            data[j + 1] = t;
        }
        return data;
    }   
}

class ArrayMinimum {
    // removes and returns the minimum element
    static int minimum(int [] v) {
        int min = v[0]; 
        for (int i = 0; i < v.length; i++) {
            if (v[i] < min) {
                min = v[i];
            }
        }
        ArrayUtils.remove(value, min);
        return min;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:08:08+00:00Added an answer on June 17, 2026 at 8:08 pm

    The method setRoot expects to receive a TreeNode as a parameter, and the problem is that you are passing as a parameter the result of the method insertgt that is void, you would have to return a TreeNode object from the insertgt method

    this.setRoot(this.insertgt(this.insertionSort(value)));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below code gives this error message Specified method is not supported. But here is
Below code is not working in IE but working in Chrome... $(this).css(border,solid 1px green)
Below code is dealing with a TYPE* const pointer. struct D { void Check
Below code not work, but it's work fine for jsf1.2. Now the framework is
Below code saying error incorreect syntax near Main INSERT INTO tbl ( 'Week', Main,
The below code give me a foreach error. What appears to be the issue
The below code uses this.value to get the value of a forms dropdowns. I
Below code displays filterable textboxes, but when I type abc into 'Sid textbox', the
Below code gives Too much recursion error in Jquery ui dialog $( #dialog-confirm ).dialog({
Below code is validating properly.When i first submit the form,it shows the error message,second

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.