pseudocode

Pseudo Code and conditions for deleting a Node in Binary Search Tree

你。 提交于 2019-12-24 00:42:26
问题 I'm trying to write a function to remove a node from a binary tree. I haven't coded the function yet, and I am trying to think about the different conditions I should consider for removing a node. I am guessing that the possible conditions are: The node has no children The node has one child The node has 2 children In each of these cases what would be the algorithm to perform a delete function? 回答1: This is something you would find in any standard textbook about algorithms, but let's suppose

Calculating check digit for ISBN

偶尔善良 提交于 2019-12-23 12:59:39
问题 This isn't actually homework, I'm just looking through some questions in a discrete maths book before I start computer science next week. Anyway, one of the questions asks me to write a program to perform this algorithm (which it explains). The part I'm stuck with is how to take the 9 digit number and "split" it into single integers, so the calculations can be performed on each digit. I thought of dividing the number by 100,000,000 and then taking the integer value of this to get the first

Pseudocode: a clear definition?

大憨熊 提交于 2019-12-23 11:46:35
问题 The following code is an example of what I think would qualify as pseudocode, since it does not execute in any language but the logic is correct. string checkRubric(gpa, major) bool brake = false num lastRange num rangeCounter string assignment = "unassigned" array bus['business']= array('person a'=>array(0, 2.9), 'person b'=>array(3, 4)) array cis['computer science']= array('person c'=>array(0, 2.9), 'person d'=>array(3, 4)) array lib['english']= array('person e'=>array(0, 4)) array rubric =

Algorithm 3d orbiting camera control with mouse drag

谁说胖子不能爱 提交于 2019-12-23 04:01:49
问题 Please help, I couldn't find detailed explanation about this which is not language specific and not library dependent, because I want to control the math myself for some reason. How to create orbiting camera control with mouse, like middle-click drag in Google SketchUp ? * In Google SketchUp, the camera can move circularly orbiting imaginary object in the middle of the plane ( not always 0,0,0) by dragging the mouse. It can orbit horizontally, vertically, even diagonally, all directions. 回答1:

How does `Skipcond` work in the MARIE assembly language?

谁说我不能喝 提交于 2019-12-21 04:40:56
问题 I am trying to understand the MARIE assembly language. I don't quite understand skipcond for doing things like < , or > , or multiply or divide. I am taking this simple program: x = 1 while x < 10 do x = x +1 endwhile; What I don't understand is how to use certain skip conditions: Skipcond 800 if AC > 0, Skipcond 400 if AC = 0, Skipcond 000 if AC < 0 Now, I know I would subtract x from 10 and test using skipcond. I am not sure which one and why. I guess if I knew how they really work maybe it

Path finding in a Java 2d Game?

ぐ巨炮叔叔 提交于 2019-12-20 14:26:42
问题 Essentially its a pacman clone game I'm working on. I have an Enemy class, and 4 instances of this class created which all represent 4 ghosts of the game. All ghosts start up in random areas of the screen and then they have to work their way towards the pacman character. As the player controls the pacman, moving it around, they should follow it and take the nearest possible way towards him. There is no maze/obstacles (yet) so the entire map (400x400 pixels) is open ground to them. For the

Path finding in a Java 2d Game?

喜你入骨 提交于 2019-12-20 14:26:33
问题 Essentially its a pacman clone game I'm working on. I have an Enemy class, and 4 instances of this class created which all represent 4 ghosts of the game. All ghosts start up in random areas of the screen and then they have to work their way towards the pacman character. As the player controls the pacman, moving it around, they should follow it and take the nearest possible way towards him. There is no maze/obstacles (yet) so the entire map (400x400 pixels) is open ground to them. For the

Translating a mips pseudo instruction 'rol'

删除回忆录丶 提交于 2019-12-20 07:19:13
问题 I'm trying to translate the mips pseudo instruction rol (rotate left). I need to translate it before I can submit an assignment, which is unfortunate because the pseudo instruction worked quite well for me. The instruction was, rol $s4,$s4, 1 #goes to the left most bit (which as it says, gets the left most bit) the way I translated it was, lui $s4, 0x8001 ori $t0, $s4, 0x0004 srl $s4, $t0, 31 sll $s5, $t0, 1 or $s5, $s5, $s3 but it completely messes up my code, can someone please help me

PHP time intervals

亡梦爱人 提交于 2019-12-20 05:58:21
问题 I'm looking for a solution to something which seems like it should be pretty simple, but it doesn't seem that I can find any good answers on here, and I can't seem to get it to work myself. What I'm looking for is to set a start time, an end time, and then iterate through a set of times between given a time interval. Say, for example, 9:00 AM - 5:00 PM are the start times, and the values returned between these times at half hour intervals are 9:30, 10:00, 10:30, 11:00, etc. Here's some pseudo

Nested loops result

被刻印的时光 ゝ 提交于 2019-12-20 04:25:08
问题 I really don't know how to find out the result of nested loops. For example in the following pseudo-code, I can't sort out what will be given at the end of execution. I'll be so glad if anyone gives me a simple solution. r <- 0 for i <- 1 to n do for j <- 1 to i do for k <- j to i+j do r <- r + 1 return r Question is: What is the result of the code and give the result r in terms of n ? I write it but every time I get confused. 回答1: In your pseudo-code, Inner most loop, k <- j to i+j can be