Monday, September 23, 2013

Data Structures Revisited - Moving back to basics - Traversing a graph

The crux of writing this post was that I was posed a question recently which made me go to my books and re-read, re-work, re-learn or whatever you name it. The question was how would you traverse a graph with cyclic nodes to it, basically a cyclic graph, for which I did a quick visio and I have posted below.


The answer was depth first search and breadth first search, above are the results with the graph.

Depth First Search - Stack
Traverse through all the connected nodes, add to stack. Revisit node in stack when no more unvisited nodes
Result: ABEGFCHD

Breadth First Search - Queue
Traverse all the nodes attached to a vertex, add to the queue and then follow the next item in queue and make it as the vertex and reprocess
Result: ABDGEFCH

No comments:

Post a Comment

Please add your valuable comments and also questions that would make me write a post for you.

Search This Blog

Labels

oracle oracle applications 11i 12.1 PLSQL SQL database index r12 12 API HRMS PL application r12.1.3 table whitepaper AR DOCUMENT_CATEGORY Database Options Oracle Application Setup Packages Sequences Stand-alone System Profile Options Tables Tuning User-defined types Views autoinvoice compatibility concurrent developer document documents of record download impact import increase issue lookup manager master object names oracle workflow performance receivables script technology windows workflow APP-PAY-06841 ATG BI BLOB DBMS_LOB DFF DIRECTORY Dynamic FND FNDLOAD HR_CHANGE_START_DATE_API IN IN OUT Jdeveloper 11g KFF MIME Materialized views OA Framework OAF ORACLE_LOADER OUT Private synonyms Problem Problem Statement SQL*LOADER SSHR Starters Tutorial WebService XP ad_dd administrator all all workflows amateur architecture assi assignment attachments breadth first search builder category change client column columns compression consideration create create_shared_type custom flexfield cyclic graph data flow data structure data structures depth first search employee external tables field file flex flex field flexfield fnd_irep_classes fnd_irep_function_flavors fnd_lookup_types_pkg fnd_lookup_values_pkg functionality graph image infrastructure insert_row integrated SOA gateway invisible indexes irep jdev jdeveloper key key flexfield keywords latest start date list list of APIs load logging mandatory metalink node noob operating system operational BI package package maximum length parameters patch per_shared_types_api person procedures query queue quick start record registering registration reserved results solution stack standalone start date subcategory technical traverse traversing a graph type update_start_date upload values vertex view vista wf wf_local_roles windows 7

Total Pageviews