Jump to content

How to implement the Depth First Search algorithm in PHP MySqli


tastajg

Recommended Posts

Thank you justsomeguy for the correct response that you say, I explain a little bit, I have the table sebab(S) to save the causes of problems that are often faced by students according to the Counseling Guidance expert, table masalah (M) to save the problem data according to expert Counseling Guidance and table solusi (SL) for the solution of the problem according to expert Bimbinga Counseling.

 

When students consult, students are given a question of cause of the problem ie (S01..S65 = root) after which the student is notified of the problem (M01 ... M21 = node) and the solution (SL01 ... SL21) based on the student's problem.

 

Please help me, I am in a state of confusion should start from where, if there is a more practical idea I am very appreciative and grateful.

Link to comment
Share on other sites

Once again, thank you justsomeguy,

 

this structure for the user table in this case the student:

 

CREATE TABLE `siswa` (

  `id_siswa` int(5) NOT NULL,

  `nis` varchar(12) NOT NULL,

  `nama_siswa` varchar(20) NOT NULL,

  `tpt_lahir` varchar(150) DEFAULT NULL,

  `tgl_lahir` datetime DEFAULT NULL,

  `agama` varchar(20) DEFAULT NULL,

  `kelamin` enum('laki-laki','perempuan') NOT NULL,

  `kelas` varchar(20) DEFAULT NULL,

  `jurusan` varchar(20) DEFAULT NULL,

  `alamat_siswa` text NOT NULL,

  `telpon_siswa` varchar(12) NOT NULL,

  `email` varchar(100) NOT NULL,

  `username` varchar(20) NOT NULL,

  `password` varchar(100) NOT NULL,

  `photo` varchar(100) NOT NULL

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

 

this is the sutruktur admin table as well as counseling tutors:

CREATE TABLE `admin` (

  `id_admin` int(5) NOT NULL,

  `nama_lengkap` varchar(20) NOT NULL,

  `nip` varchar(12) NOT NULL,

  `kelamin` enum('laki-laki','perempuan') NOT NULL,

  `telpon` varchar(12) NOT NULL,

  `alamat` text NOT NULL,

  `gelar` varchar(100) NOT NULL,

  `tempat_lahir` varchar(100) NOT NULL,

  `tanggal_lahir` date NOT NULL,

  `agama` varchar(100) NOT NULL,

  `email` varchar(100) NOT NULL,

  `photo` longblob,

  `username` varchar(20) NOT NULL,

  `password` varchar(100) NOT NULL

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

 

this table structure causes (causes of student problems) :

CREATE TABLE `sebab` (

  `id_sebab` int(10) NOT NULL,

  `kode_sebab` varchar(10) NOT NULL,

  `kode_masalah` varchar(10) NOT NULL,

  `kode_solusi` varchar(10) NOT NULL,

  `sebab` varchar(500) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

 

this table structure problem (student problem):

CREATE TABLE `masalah` (

  `id_masalah` int(10) NOT NULL,

  `kode_masalah` varchar(10) NOT NULL,

  `masalah` varchar(500) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

 

 

these table structure solutions (solutions to problems that students face):

CREATE TABLE `solusi` (

  `id_solusi` int(10) NOT NULL,

  `kode_solusi` varchar(10) NOT NULL,

  `kode_masalah` varchar(10) NOT NULL,

  `solusi` varchar(500) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

 

this table structure counseling (save the results of student counseling):

CREATE TABLE `konseling` (

  `id_konseling` int(10) NOT NULL,

  `kode_konseling` varchar(10) NOT NULL,

  `kode_masalah` varchar(10) NOT NULL,

  `tgl_konselling` date NOT NULL,

  `id_siswa` varchar(10) NOT NULL

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Link to comment
Share on other sites

On 6/14/2018 at 12:30 AM, justsomeguy said:

I have no idea what that diagram is supposed to show, but if you're talking about recursion then depth-first means that you recurse before searching instead of after.

 

On 6/19/2018 at 7:49 AM, justsomeguy said:

That's in a database, right?  How do you have the database structured?

Please help justsomeguy, from my diagram it is to apply the Depth First Search algorithm, preferably starting from node (M01 ... M21) or from root (S01 ... S65)

Link to comment
Share on other sites

You already said that, but I don't know what you're looking for.  What are you searching for?  You want a depth-first search, great, what exactly are you searching for?  And why do you need recursion?  I don't see a recursive structure in your database design, so why do you think you need recursion generally, and depth-first specifically?  Is this a homework assignment?

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...