cari

Rumah  >  Soal Jawab  >  teks badan

javascript - Carta alir untuk mendapatkan kedalaman, sila bantu pakar algoritma

Masalah ini telah mengganggu saya sejak sekian lama baru-baru ini saya mempunyai data json berikut

[
    {"prev_node": "0000000000000005","next_node": "0000000000000006"},
    {"prev_node": "0000000000000006","next_node": "0000000000000007"},
    {"prev_node": "0000000000000006","next_node": "0000000000000008"},
    {"prev_node": "0000000000000008","next_node": "0000000000000012"},
    {"prev_node": "0000000000000009","next_node": "0000000000000010"},
    {"prev_node": "0000000000000010","next_node": "0000000000000011"},
    {"prev_node": "0000000000000014","next_node": "0000000000000015"},
    {"prev_node": "0000000000000015","next_node": "0000000000000016"},
    {"prev_node": "0000000000000016","next_node": "0000000000000017"},
    {"prev_node": "0000000000000018","next_node": "0000000000000019"},
    {"prev_node": "0000000000000020","next_node": "0000000000000021"},
    {"prev_node": "0000000000000019","next_node": "0000000000000020"},
    {"prev_node": "0000000000000012","next_node": "0000000000000022"},
    {"prev_node": "0000000000000022","next_node": "0000000000000023"},
    {"prev_node": "0000000000000023","next_node": "0000000000000009"},
    {"prev_node": "0000000000000011","next_node": "0000000000000024"},
    {"prev_node": "0000000000000024","next_node": "0000000000000014"},
    {"prev_node": "0000000000000017","next_node": "0000000000000025"},
    {"prev_node": "0000000000000025","next_node": "0000000000000018"},
    {"prev_node": "0000000000000007","next_node": "0000000000000021"},
    {"prev_node": null,"next_node": "0000000000000005"},
    {"prev_node": "0000000000000021","next_node": null}
]

Antaranya, prev_node mewakili nod sebelumnya dan next_node ialah nod seterusnya Jika prev_node ialah Nod, ia mewakili nod semasa Jika next_node adalah nod, ia mewakili nod terakhir, carta alir berikut diperolehi

Cari nod proses terdalam semasa dan berapa banyak cawangan yang ada

Nota: Nod hanya boleh pergi ke bawah

仅有的幸福仅有的幸福2808 hari yang lalu1142

membalas semua(2)saya akan balas

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-19 10:50:24

    Um, bukankah ini hanya pencarian mendalam

    balas
    0
  • 滿天的星座

    滿天的星座2017-05-19 10:50:24

    Struktur ini seperti graf terarah dalam struktur data

    balas
    0
  • Batalbalas