Programming Course - Intermediate Level: Recursion, Backtracking, Pointers, Lists by Gabriel Braharu
Author:Gabriel Braharu
Language: eng
Format: azw3
Published: 2017-08-17T07:00:00+00:00
The solution vector has a number of fixed elements ka = 3 because tricolours flag.
WriteSolution()
i integer
For i<-1,ka do
Write m[v[i]]
Write „Enter”
Write the solution vector with ka elements
MainProgram()
i integer
Read n,ka
For i<-1,n do
Read m[i]
Backtracking()
It reads also a vector of natural numbers (or color names) m
C. Find out all the possibilities of arranging n persons on one side of a dining table with ka places with the restriction that two women cannot stand one near another.
Solution: in the main program, we will have read a vector with n elements (names of people-strings) and of course the vector m will be declared global. For the present problem, we note that it preserves all existing conditions of restriction of the permutations (distinct elements in vector), it adds a constraint so cannot sit two women one near another (it is assumed that we can identify the feminine or masculine through the sequence of characters "f" or "m", also it keeps conditions for continuity. In relation to the permutation algorithm, we modify the ValidElement(k), SolutionVector(k), WriteSolution () and main program.
ValidElement(k integer) boolean
i integer
For i<-1,k-1 do
If v[i]=v[k] Then
Return False
For i<-1,k-1 do
If m[v[i]]=m[v[i+1]] and
m[v[i]]=”-f-” Then
Return False
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Art of Coaching Workbook by Elena Aguilar(50039)
Trainspotting by Irvine Welsh(20944)
Twilight of the Idols With the Antichrist and Ecce Homo by Friedrich Nietzsche(18266)
Fangirl by Rainbow Rowell(8756)
Periodization Training for Sports by Tudor Bompa(7889)
Change Your Questions, Change Your Life by Marilee Adams(7321)
This Is How You Lose Her by Junot Diaz(6401)
Asking the Right Questions: A Guide to Critical Thinking by M. Neil Browne & Stuart M. Keeley(5320)
Grit by Angela Duckworth(5262)
Red Sparrow by Jason Matthews(5167)
Paper Towns by Green John(4753)
Room 212 by Kate Stewart(4703)
Ken Follett - World without end by Ken Follett(4411)
The Sports Rules Book by Human Kinetics(4045)
Housekeeping by Marilynne Robinson(4016)
Double Down (Diary of a Wimpy Kid Book 11) by Jeff Kinney(3874)
Papillon (English) by Henri Charrière(3870)
The Motorcycle Diaries by Ernesto Che Guevara(3754)
Exercise Technique Manual for Resistance Training by National Strength & Conditioning Association(3754)
