तो, मेरे डॉक्टर ने मुझे पूछ treeSort लागू करने के लिए () और फिर पूर्णांक [1000000] पर उसकी जांच और समय की गणना।
मैं कक्षा है BSTree<E>जो निम्न विधियों में शामिल हैं:
public void treeSort(E[] data)
{
inorder(data, new Process<E>(), root);
}
public static <E> void inorder(E[] list, Process<E> proc, BTNode<E> p)
{
if (p != null)
{
inorder(list, proc, p.getLeft( )); // Traverse its left subtree
proc.append(list, p.getElement( )); // Process the node
inorder(list, proc, p.getRight( )); // Traverse its right subtree
}
}
और मैं Process<E>वर्ग:
public class Process<E>
{
private int counter = 0;
public void append(E[] list, E element)
{
list[counter] = element;
counter++;
}
}
और मैं निम्नलिखित है Mainवर्ग:
public class Main
{
public static void main(String[] args)
{
int[] temp = {4,2,6,4,5,2,9,7,11,0,-1,4,-5};
treeSort(temp);
for(int s : temp) System.out.println(s);
}
public static void treeSort(int[] data)
{
BSTree<Integer> tree = new BSTree<Integer>();
for(int i: data) tree.insert(i);
tree.inorder(data, new Process<Integer>(), tree.getRoot()); // I get an error here!
}
}
त्रुटि है:
cannot find symbol - method inorder(int[], Process<java.lang.Integer>, BTNode<java.lang.Integer>); maybe you meant: inorder(E[], Process<E>, BTNode<E>);
मैं बदलकर कि तय treeSort(int[] data)करने के लिए treeSort(Integer[] data)। लेकिन मैं पर मुख्य विधि में एक त्रुटि मिलीtreeSort(temp);
और त्रुटि है:
treeSort(java.lang.Integer) in Main cannot be applied to (int[])
तो, मैं कैसे ध्यान में रखते हुए जटिलता समय जहां मैं 1 लाख आदानों पर इस विधि की कोशिश करनी चाहिए बढ़ती नहीं के साथ इस मुद्दे से निपटने के कर सकते हैं?













