• T4CH
  • NEWS
  • VIDEO
Forum > Software

Ricerca dicotomica in visual basic.net

Discussione inserita in 'Software' da v3n392, 30 Marzo 2009.

  1. v3n392 techNewbie

    Ricerca dicotomica in visual basic.net

    salve ,

    potete controllarmi questo algoritmo : RICERCA DICOTOMICA



    num = InputBox(" Inserisci numero da ricercare ")

    inizio = 0

    fine = n - 1

    trovato = False

    Do



    centro = (inizio + fine) 2



    If codice(inizio) = num Or codice(fine) = num Or codice(centro) Then

    trovato = True

    Else

    If codice(centro) < num Then

    inizio = centro - 1

    Else

    fine = centro + 1

    End If

    End If

    Loop Until inizio > fine Or trovato = True



    If trovato = True Then

    MessageBox.Show(" ELEMENTO PRESENTE NELL'ARRAY ")

    Else

    MsgBox(" ELEMENTO NON PRESENTE NELL'ARRAY ")

    End If



    N.B testato con precedente oridnamento BUBBLE SORT

    IL PROBLEMA STA CHE mi dice che l'elemento è stato trovato anche quando non è in lista...
    v3n392, 30 Marzo 2009
    #1
Password dimenticata?
SU TERMINI DI SERVIZIO CONTATTACI