Untitled

 avatar
unknown
plain_text
a year ago
555 B
8
Indexable
/*
data la struttua, fare una funzione che guarda se una strina è presente nell'alberto
se è presente, restituisce true, altrimenti false
se i nodi sx e dx sono nil allora non ci sono nodi figli.
*/

package main

type Node struct {
	x      string
	sx, dx *Node
}

func find(root *Node, s string) bool {
	if root == nil {
		return false
	}

	if root.x == s {
		return true
	}

	if find(root.sx, s) == true {
		return true
	} else if find(root.dx, s) == true {
		return true
	} else {
		return false
	}

	//return find(root.sx, s) || find(root.dx, s)

}
Editor is loading...
Leave a Comment