Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

On an overnight camping trip in the Forbidden Forest near the Hogwarts School of

ID: 3813859 • Letter: O

Question

On an overnight camping trip in the Forbidden Forest near the Hogwarts School of Witchcraft and Wizardry, you and your wizard friends Ron and Hermione are woken from a restless sleep by a scream. Crawling out of your tent to investigate, you see a terrified young wizard stumble out of the woods, covered in blood and clutching a crumpled piece of paper to her chest. Reaching your tent, she gasps "Get out... while... you...", thrusts the paper into your hands and falls to the ground, dead. Looking at the crumpled paper, you recognize a map of the forest, drawn as an undirected graph, where vertices represent landmarks in the forest, and edges represent trails between those landmarks. (Trails start and end at landmarks and do not cross.) Coincidentally, you recognize one of the vertices as your current location; several vertices on the boundary of the map are labeled EXIT. On closer examination, you notice that someone (perhaps the dead wizard) has written a real number between 0 and 1 next to each vertex and each edge. A scrawled note on map's reverse side indicates that these numbers give the probability of encountering a deadly Dementor along the corresponding trail or at the corresponding landmark. The note warns that stepping off the marked trails will surely result in death. You glance down at the corpse at your feet. Her death certainly looked painful. On closer examination, you realize that the wizard is not dead at all, or rather, is turning into a Dementor who will surely devour you. After burning the wizard's body, you wisely decide to leave the forest immediately. (a) Give a (small!) example G such that the path from your current location to the EXIT node that minimizes the expected number of encountered Dementors is different from the path that minimizes the probability of encountering any Dementors at all. Explain why, in general, these two criteria lead to different answers. (b) Describe and analyze an efficient algorithm to find a path from your current location to an arbitrary EXIT node, such that the total expected number of Dementors encountered along the path is as small as possible. Be sure to account for both the vertex probabilities and the edge probabilities. Dumbledore's hint: This is clearly an SSSP problem, but you must identify how to reduce the input G to a form that can be solved by SSSP. Remember to include the cost of this transformation in your running-time analysis. (c) Describe and analyze an efficient algorithm to find a path from your current location to an arbitrary EXIT node, such that the probability of encountering any Dementors at all is minimized.

Explanation / Answer

sbit DB7 = P1^7;
sbit DB6 = P1^6;
sbit DB5 = P1^5;
sbit DB4 = P1^4;
sbit RS = P1^3;
sbit E = P1^2;

sbit clear = P2^4;
sbit souse = P2^5;              
sbit left = P2^6;
sbit right = P2^7;

void returnHome(void);
void entryModeSet(bit id, bit s);
void showOnOffControl(bit display, bit cursor, bit blinking);
void cursorOrDisplayShift(bit sc, bit rl);
void functionSet(void);
void setDdRamAddress(char address);

void sendChar(char c);
void sendString(char* str);
bit getBit(char c, char bitNumber);
void delay(void);

void main(void) {

   functionSet();
   entryModeSet(1, 0); // increment and no shift
   displayOnOffControl(1, 1, 1); // show on, pointer on and blinking on
   sendString("EdSim51 LCD Module Simulation");
   setDdRamAddress(0x40); // set address to start out of second line
   sendString("Based on Hitachi HD44780");

   // The program will be controlled via a number of the switches on port a pair of.
   // If switch five is closed the pointer returns home (address 0).
   // Otherwise, switches six and seven ar scan - if each switches ar open or each switches
   // ar closed, the show doesn't shift.
   // If switch seven is closed, unceasingly shift left.
   // If switch six is closed, unceasingly shift right.
   whereas (1)
       else zero && right == 1) {
               cursorOrDisplayShift(1, 0); // shift show left
           }
           else if (left == one && right == 0) {
               cursorOrDisplayShift(1, 1); // shift show right
           }  
       }  
   }
}

// LCD Module directions -------------------------------------------
// to grasp why the pins ar being set to the actual values within the functions
// below, see the instruction set.
// A full rationalization of the LCD Module: HD44780.pdf

void returnHome(void)   

void entryModeSet(bit id, bit s)

void showOnOffControl(bit display, bit cursor, bit blinking)

void cursorOrDisplayShift(bit sc, bit rl)

void functionSet(void) operate set is really sent double. Why? See 4-bit operation
   // on pages thirty-nine and forty two of HD44780.pdf.
   DB7 = 0;
   DB6 = 0;
   DB5 = 1;
   DB4 = 0;
   RS = 0;
   E = 1;
   E = 0;
   delay();
   E = 1;
   E = 0;
   DB7 = 1;
   E = 1;
   E = 0;
   delay();
}

void setDdRamAddress(char address)

void sendChar(char c)

// -- finish of LCD Module directions
// --------------------------------------------------------------------

void sendString(char* str) {
   int index = 0;
   whereas (str[index] != 0)
}

bit getBit(char c, char bitNumber) come back (c >> bitNumber) & 1;
}

void delay(void)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote