Digital dictonary problem

https://ide.geeksforgeeks.org/5OULBUMCIO---- the output of the code is not correct, i thing there is error in display fuction to display the queries of dictionary , can u please make corrections in it and indicate the errors.

hey @AbhishekAhlawat1102
try for this input
4
pet
peter
rat
rack
1
r
correct output : rat rack
your code gives :
peter
rack
rat

yes i know that there is error in the code but i m not able to find it now can u please help in finding and rectifying it

public void display(String st) {
this.display(this.root, “”, st);
}

public void display(Node node, String osf, String st) {
	if (st.length() == 0) {
		osf = osf + node.data;
		if (node.isTerminal) {
			System.out.println(osf.substring(1));
		}
		Set<Map.Entry<Character, Node>> entries = node.children.entrySet();
		for (Map.Entry<Character, Node> entry : entries) {
			display(entry.getValue(), osf, st);
		}
		return;
	}
	char cc = st.charAt(0);
	String ros = st.substring(1);
	Node child = node.children.get(cc);
	if (child == null) {
		System.out.println("No suggestions");
		return;
	} else {
		display(child, osf + node.data, ros);
	}
}

and you need to design the search functionality. And if no such words are available for a given search word, add this word to your dictionary.
ispe work kro