

Hi.. im new here...
Im a BSCS freshman and im studying in a couple of weeks.. i just have a little problem... i am having trouble translating this flowchart into an algorithm pseudocode... i dont know how to end the program in the middle of DOWHILE and REPEATUNTIL, it just makes me write endless DOWHILEs... can someone help me?
here is the link of my flowchart..
untitled — Postimage.org[^]
thanks for helping me..
modified 27Aug16 9:00am.





Please use "code" tags to modify your question so the flowchart is readable. That will give you a fixed width font, and you can see the preview to get it right. You won't get any answers to the current mess.
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012





ive edited my post.. hope you can now understand it..





Crikey! If that's the 'fixed' version, the other one probably killed dolphins, fairies and little babies.
As suggested, rather than trying to hack it together using . characters for spacing, why dont you wrap it in <pre> </pre> blocks? (select it then hit the 'code' button)
You could end up with something as legible as this (even with it's incorrect decision boxes):
++
 START 
++
<+
+v+ 
X = X+1 
+++  YES
 
+v+ 
 X < 3?+
++

 NO

v
Failing that, upload an image to an imagehosting site and then post a link. That's the less preferred option, text is perfectly adequate.





omg thank you... now its better..
modified 27Aug16 8:21am.





You're welcome. That image is much more legible.






OMG now i get it.. thank you so much for the info ;D ;D
modified 27Aug16 21:01pm.





Please Need Urgent Code suggestions for this:
There is a 2D matrix which has 0s and 1s . Your main aim is to tell maximum number of rows that are max amplified . A row is max amplified if all the columns in a row are 1. You have been given K which tells the number of column inversions you HAVE to do . Column inversion means that the whole column of that 2D matrix is inverted . 0 is replaced by 1 and 1 is replaced by 0 . You have to tell that after K inversions how many rows of max amplification will be present . K inversions gave to take place . Not less than that not more . One column can be inverted more than once .





Your homework is set to test what you know, not how good you are at convincing strangers on the Internet to do your work for you.
Try doing it yourself, and you'll probably find it's not as difficult as you think. After all, it should be based on concepts that you've recently covered in your course.
If you really don't know where to start, then talk to your teacher.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
 Homer





This a test about your math knowledge and convert to code. Computer graphic you has do it or you will never get it






Am I reading this right if I say that you want to select the edge if the distance between your vector (the ray) is shorter than the distance epsilon (or some other defined minimal distance) from the line?
If we move to 2d a Voronoi diagram would suffice? Or some version of this:
Add a point to a polyline[^]





I'm not sure I understand the ray part, but since you're talking 3D, I'd look for the intersection of the mesh parts with a sphere centered on the mouse click location  point (vertex) contained in sphere, line segment (edge) fully or partially contained in sphere, etc. This means you'll need to keep track of the cursor location in three dimensions and map the actual mouse gestures on the screen to somehow moving that 3D cursor.
This is pretty standard math for any 3D rendering or 3D game, so you might see if you can find a library that already implements the heavy lifting for you. If you roll your own, there's tons of resources for this sort of math, but I often found myself at the Wolfram reference site.
If your mesh is big, performance will be pretty slow. I think a lot of the 3D editors do the voxel thing so they can check only a subset for each event.
We can program with only 1's, but if all you've got are zeros, you've got nothing.





Ah.. I see you are suggesting me to go for SphereLine intersect instead of RayLine. Am I right? Although currently, I'm not concern about the vertex part since I already did it somehow..
But I think I should really check out if I can implement the SphereLine intersect idea to pick triangle's edge.
And yes, many thanks for the suggestion about performance





Actually, now that I've thought about it, sphere math is overkill, and probably not what you're wanting anyway. It'll work, but it's be simpler to just calculate nearest point on a line to a 3D point, and then decide if A) that falls within the endpoints of the line segment, and B) the distance between the two are close enough.
However, if you're using your "ray" to describe corner points of a 3D prism that's the selection bounding volume, then its just point inside a volume, and 3D plane/linesegment intersection math.
We can program with only 1's, but if all you've got are zeros, you've got nothing.





I'm in the process of writing my 4th generation package calculator. Over the years, UPS and FedEx require that you enter package dimensions and weight to get a quote.
Before I was able to create a clump, which I call a unit of mass, based off the cart database which contains each products dimensions, then cube that clump into a cube shape. But times have changed.
My 3rd generation package calculator was a complete failure overall, in which I tried using SQL Linq to calculate from the database
So here is my 4th generation attempt.
I get all the items from the database, and throw the items into 1 of 4 categories  List(Of
These will always be separate packages
Isolated Items  Case Quantities, you just slap a label on them and ship
Long Items, like sticks, long levels over 6ft
These can be combined into a single package, if under the max parameters
Thin Items like pancakes, AAA batteries less than 1/2" height
Common Items  you can throw them in a box, slap a label and ship
Then I wrote 4 functions that calculate the length, width, height, dimensional weight, gravity weight.
Within each function, a loop runs.
Each function is slightly different, ...
1. lines up the items by length, then loops down the lengths going wider, then taller
2. stacks them up like a tower, largest on the bottom
3. Isolate  its just a package, get the length, width, height, weight and go
4. Common  I'm in doubt on this one, needs improvement
If the limit is reached, the Create_Package fires and makes a Package.
So now I have these packages, and run Package_Combine, in which I see if I can throw a THIN package into the common box, to reduce the number of packages, because each package has a base cost of $7.00, and shoppers freak out.
The packages are a class of package_types, that are sent off to UPS or Fedex for a Quote, in which those programs I wrote loop and submit each package as a single shipment.
My code is too large to post. So I will post a snippet of 2 functions to start with.
So my question is, do you think I'm on the right track. Does a better more efficient way pop into your head. Did I make it way too complicated?
Think I get can further refine the 4 functions into 1 function by using more Linq?
I have to get this right this time, I'm tired of being poor and need to raise my income. I don't have the funds to just pay someone to write this, and how would I validate that person before hire.
Oh and I expect to hear crickets on this post, sit here forever with no reply.
Here are some known values
Private Const MAX_DIMENSIONAL_LENGTH As Decimal = 108.0
Private Const MAX_DIMENSIONAL_WEIGHT As Decimal = 165.0
Private Const MAX_GRAVITY_WEIGHT As Decimal = 150.0
Private Const MAX_TYPICAL_BOXLENGTH As Decimal = 37.0
Private Const MIN_TYPICAL_LONG_ITEM As Decimal = 72.0
Common Items  I'm in doubt about this one.
Private Shared Function Package_C1( _
ByVal pItems As List(Of model_rateItems),
ByRef packages() As package_type) As Integer
Dim pValue As Integer = 0
Dim pdx As Integer = 0
Dim item As New model_rateItems()
Dim gWeight As Decimal = 0
Dim dWeight As Decimal = 0
Dim dPackage As Decimal = 0
Dim oFlag As Boolean = True
For Each p As model_rateItems In pItems _
.OrderByDescending(Function(m) m.Length) _
.OrderByDescending(Function(m) m.Width) _
.OrderByDescending(Function(m) m.Height)
pdx += 1
If (p.Qty = 1) Then
gWeight += p.Weight
item.Cost += p.Cost
item.Price += p.Price
item.Weight += p.Weight
item.Description = If(item.Description Is String.Empty, p.Description, item.Description & ", " & p.Description)
item.Hazmat = If(p.Hazmat = True, True, item.Hazmat)
item.DryIce = If(p.DryIce = True, True, item.DryIce)
item.Origin = If(item.Origin Is String.Empty, p.Origin, item.Origin)
item.Length = If(p.Length > item.Length, p.Length, item.Length)
item.Width = If(p.Width > item.Width, p.Width, item.Width)
item.Height = If(item.Height = 0, p.Height, (item.Height + p.Height))
dWeight = Calc_DWeight(item)
If (dWeight > MAX_DIMENSIONAL_WEIGHT Or item.Weight > MAX_GRAVITY_WEIGHT) Then
pValue += Package_Create("COMMON", dWeight, item, packages)
End If
Else
item.Cost += p.Cost * p.Qty
item.Price += p.Price * p.Qty
item.Weight += p.Weight * p.Qty
item.Description = If(item.Description Is String.Empty, p.Description, item.Description & ", " & p.Description)
item.Hazmat = If(p.Hazmat = True, True, item.Hazmat)
item.DryIce = If(p.DryIce = True, True, item.DryIce)
item.Origin = If(item.Origin Is String.Empty, p.Origin, item.Origin)
item.Length = If(p.Length > item.Length, p.Length, item.Length)
item.Width = If(p.Width > item.Width, p.Width, item.Width)
item.Height = If(item.Height = 0, p.Height, (item.Height + (p.Height * p.Qty)))
dWeight = Calc_DWeight(item)
If (dWeight > MAX_DIMENSIONAL_WEIGHT Or item.Weight > MAX_GRAVITY_WEIGHT) Then
pValue += Package_Create("COMMON", dWeight, item, packages)
End If
End If
Next
dWeight = Calc_DWeight(item)
pValue += Package_Create("COMMON", dWeight, item, packages)
Return pValue
End Function
Long Items  It's seems to work well. but I think maybe there's a more efficient way to do it.
Private Shared Function Package_L1( _
ByVal pItems As List(Of model_rateItems),
ByRef packages() As package_type) As Integer
Dim pValue As Integer = 0
Dim pdx As Integer = 0
Dim item As New model_rateItems()
Dim dWeight As Decimal = 0
Dim oFlag As Boolean = True
For Each p As model_rateItems In pItems.OrderByDescending(Function(m) m.Length)
pdx += 1
If (p.Qty = 1) Then
item.Cost += p.Cost
item.Price += p.Price
item.Weight += p.Weight
item.Description = If(pdx = 1, p.Description, ", " & p.Description)
item.Hazmat = If(p.Hazmat = True, True, item.Hazmat)
item.DryIce = If(p.DryIce = True, True, item.DryIce)
item.Origin = If(item.Origin Is String.Empty, p.Origin, item.Origin)
If (p.Length > item.Length) Then
item.Length = p.Length
item.Width = If(item.Width = 0, p.Width, item.Width)
item.Height = If(item.Height = 0, p.Height, item.Height)
Else
If (p.Width > item.Width) Then
item.Length = item.Length
item.Width = p.Width
item.Height = item.Height + p.Height
Else
item.Length = item.Length
item.Width = item.Width
item.Height = item.Height + p.Height
End If
End If
dWeight = Calc_DWeight(item)
If (dWeight > MAX_DIMENSIONAL_LENGTH Or item.Weight > MAX_GRAVITY_WEIGHT) Then
pValue += Package_Create("LONG", dWeight, item, packages)
dWeight = 0
item = New model_rateItems()
ElseIf (pdx = pItems.Count()) Then
pValue += Package_Create("LONG", dWeight, item, packages)
Exit For
End If
Else
item.Description = If(pdx = 1, p.Description, item.Description & "," & p.Description)
item.Hazmat = If(p.Hazmat = True, True, item.Hazmat)
item.DryIce = If(p.DryIce = True, True, item.DryIce)
item.Origin = If(item.Origin Is String.Empty, p.Origin, item.Origin)
item.Width = If(item.Width = 0, p.Width, item.Width)
item.Height = If(item.Height = 0, p.Height, item.Height)
For idx As Integer = 0 To p.Qty  1
item.Length = item.Length + p.Length
item.Weight += p.Weight
item.Cost += p.Cost
item.Price += p.Price
If (item.Length > MAX_DIMENSIONAL_LENGTH And item.Weight < MAX_GRAVITY_WEIGHT) Then
If (p.Length > item.Length) Then
item.Length = p.Length
item.Width += p.Width
item.Height = If(p.Height > item.Height, p.Height, item.Height)
Else
item.Length = item.Length  p.Length
item.Width += p.Width
item.Height = If(p.Height > item.Height, p.Height, item.Height)
End If
ElseIf (item.Length < MAX_DIMENSIONAL_LENGTH And item.Weight < MAX_GRAVITY_WEIGHT) Then
If (p.Length > item.Length) Then
item.Length = p.Length
item.Width += p.Width
item.Height = If(p.Height > item.Height, p.Height, item.Height)
Else
item.Length = item.Length
item.Width += p.Width
item.Height = If(p.Height > item.Height, p.Height, item.Height)
End If
End If
dWeight = Calc_DWeight(item)
If (dWeight > MAX_DIMENSIONAL_WEIGHT Or item.Weight > MAX_GRAVITY_WEIGHT) Then
pValue += Package_Create("LONG", dWeight, item, packages)
dWeight = 0
idx = idx  1
item = New model_rateItems()
End If
Next End If
Next
If (pValue = 0) Then
dWeight = Calc_DWeight(item)
pValue += Package_Create("LONG", dWeight, item, packages)
End If
Return pValue
End Function





I've not had a chance to give your question the attention it deserves, but one obvious issue sticks out:
jkirkerx wrote: For Each p As model_rateItems In pItems _
.OrderByDescending(Function(m) m.Length) _
.OrderByDescending(Function(m) m.Width) _
.OrderByDescending(Function(m) m.Height)
That's only going to sort by the height; each OrderBy method discards any previous ordering.
To sort by all three, you need to use ThenBy on the subsequent sortings:
For Each p As model_rateItems In pItems _
.OrderByDescending(Function(m) m.Length) _
.ThenByDescending(Function(m) m.Width) _
.ThenByDescending(Function(m) m.Height)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
 Homer





Oh I didn't know that, will make the change now.
I'm starting to use Linq more now, since you helped me with my MVC project.






One throws the items into a box, specifies the dimensions of the box (customer packaging  if one want any applicable discount), weighs the box, selects a shipping option (ground; 2day; etc.) and prints and attaches a label. Note that many carriers supply "standard size boxes" that are priced based on size, not weight (up to say a 70 lb max).
Seems the challenge is to have all items to be shipped to a given customer collected ("picked") at the same time for shipping; not what box it may fit in (which may need extra "packing" for fragile items). The shipped boxes I receive tend to be much larger than their actually contents.
(I currently program selfservice shipping kiosks).





I under stand that. But I can't customers to standardize on boxes. I've been trying for 7 years now.
It would be easier to get the customer to commit to purchasing boxes in certain sizes, and then I just calculate which boxes I need.
Now this is a calculator for determining the ship rate before the customer makes a purchase.
I'm going to take the code and turn it into a console app, with some fake data, so folks that are interested can play with it.





I created a console app if you want to play with it, it's a VS2015 project with all the code that I wrote for it.
it has data or shopping cart items that you can load, and will output the results to the screen
So this is for my old program Internet Commerce Engine 5 written in VB
I have a new program called project Indigo written in MVC C# that I will port this over in Sept 2016
So sorry about it being in VB. But the concept should be the same.
DropBox that you can download the project, now its the folder.
I fixed the console output and worked on Package_C1
Dropbox  Code Project[^]
Preview of Project Indigo Shopping, not much there yet
Project Indigo!  Home Page[^]
Project Indigo!  Browse[^]
I could use help with the Navigation Bar in the shopping section, much harder than I thought to construct using Bootstrap.
modified 5Aug16 17:04pm.





Thanks! I was looking this info





Well I'm still working on it!, but taking a break on it today.
It needs improvement on the Common items, and a better way to arrange the items.
I'm thinking aspect ratios today, to treat each item by aspect ratio or shape, to determine how to stack them, then take a measurement of the dimensional weight.





Hello.
I'm making a racing game. I've messing around with numbers and stuff to make a script for simulating car engine temp which weather temperature, weather humidity, the power of radiator, Engine output and engine oil play a role in increasing/decreasing the temp.
For the wheels, only weather temp and humidity, Wheel air pressure and engine power is needed (I guess).
I just can't make an accurate one. Would be happy if someone suggests an algorithm to simulate car heat temperature.
Remember that it is only a game, not a militarygrade advanced simulation software .
modified 22Jul16 7:41am.





Apparently using Nitrogen in the tires is a factor...
Engine temp increases with loss of oil pressure / oil volume
Engine temp increases with engine RPM
Ambient temp increases engine temp
Humidity affects air density which decreases combustibility which affects engine power causing more work and more heat (?)
Bigger / better radiators allow for running at (what would be) a higher temperature





Not any help here
But turning raises tire heat.
Radius of the turn, plus speed increases heat. Steering wheel marked in degrees, say 270 indicates a sharp left turn.
Front or rear wheel drive? A sharp left turn on front wheel drive will raise the right front tire temp, then the left rear tire temp. vice versus for rear wheel drive.
Track temp, asphalt gets very hot and tacky in the sun, cold and slippery in the rain or ice.
Tire type, summer tire vs winter tire. Summer tires run hotter.
Tire pressure, more is cooler, less is hotter. Just like water which boils at 212F at sea level, you can increase the pressure and raise the boil point like the coolant system of a car.





Am currently working on a project relating to quantum cryptography






I don't think that you could find a source code for QKD.. There is only some general info and schemes..Well it seems to me so.





Hi,
I tried your code to protect PDF file.
I registered the DLL : ProtectPDF and added it's reference to Excel VBA.
But when I am trying to run the code I am getting the error 'ActiveX component can't create object'
Please help!
Thank you!





Member 12611971 wrote: I tried your code Presumably you are talking about some article here on CodeProject. If so, then you need to post your question in the forum at the end of the article.





I would also like to point out that we are volunteers; it is not urgent here.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]





Is there any algorithm to map these two fields
if n = 5
field 1 Field 2
1 (1)
2 (1,2)
3 (1,2,3)
4 (1,2,3,4)
5 (1,2,3,4,5)
6 (2)
7 (2,3)
8 (2,3,4)
9 (2,3,4,5)
10 (3)
11 (3,4)
12 (3,4,5)
13 (4)
14 (4,5)
15 (5)
I want a function which can give the second field as output for input of first field .
Expect to have a simple mathematical algorithm.
Please help me with this problem.
hint: 1  2  3  4  5
* * * * *
* * * *
* * *
* *
*





Probably homework, solvable with a couple of loops.





Thank you. Looking forward to have the answer..





We look forward to you coming up with the answer. You've had the hint on how to solve it. Think about how loops work and you should get the solution.
This space for rent





I'm trying figure out the best way to distort given image on chessboarded mask.
http://i.stack.imgur.com/NRoWt.jpg[^]
Both have the same aspect ratio. Theoretically, I could calculate square edges and build a grid of points. And after, extrapolate each pattern pixel to approximate destination on mask based on parent square edges.
But maybe there is more elegant way to do it? With openCV or anything of computer vision algorithms?





I have n points in the plane and I need to find a pair of concentric circles such that all the points lie between the cicels and the area between the cicels is minimal.
I have an O(n^2) algorithm but it seems that it's possible to improve.





If you would share your algorithms, someone may have an opinion/idea about it...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.





How did you even do it? The best I could do so far is using this QCQP
minimize 2 d r + d^2
s.t.
d >= 0
r >= 0
for each point x,y:
(xcx)^2 + (ycy)^2 >= r
(xcx)^2 + (ycy)^2 <= r+d
The point constraints work out to something like cx^2 + cy^2  2xcx  2ycy  r + x^2 + y^2 >= 0 (with all the squared terms on the left, linear variables in the middle and finally some constants). The square terms are all nonnegative so the matrixes that define them are positive semidefinite, so it can be solved with SDP.





Hey im having trouble in finishing this algo:
A robot engine warms up with his trip and cooled down by a fan.
The robot required to ensure that the engine is not overheating.
Given that the temperature versus time engine is
1.2t=Tm
Temperature of the enviroment is 15=Te
Constant k=0.8
It i1s known that the rate of the cooling is define by
dT/dt = k(TTe)+Tm
Also known that the speed of the robot is 25m/s And the starting temparture of the engine is 35.
We need to find the Differential Equations for the road founded in the last question for Each Δt=0.1
This is the answers that i dont know how to get to.
temp is:
Time Temp[degC]
0.0 35.00
0.0 33.40
0.1 31.94
0.2 30.61
0.3 29.40
0.4 28.29
0.5 27.29
0.6 26.38
0.7 25.55
0.8 24.80
0.9 24.13
1.0 23.52
And when its getting warmer:
2.7 19.44
2.8 19.42
2.9 19.42
3.0 19.42
3.1 19.44
3.2 19.47
3.3 19.51
3.4 19.56
3.5 19.61
3.6 19.68
3.7 19.75
And the Path from the last question:
0 0
24 11
7 34
78 196
218 308
289 461
344 412
380 451
516 451
543 554
605 591
600 600
Thank you alot in advence!






============ REPEAT QUESTION FROM C# FORUM
Hello there. We take the example of Bubble Sort Algo.
Time Complexity
Best O(n)
Worst O(n^2)
Space Complexity
Worst O(1)
Let us suppose a simple array contains 25 elements. What does above information mean and how should I visualize it?? Thanks for clearing some basics.





An algorithm presents a method to do something which ideally works for all manner of inputs. As you know, there are lots of different sorting algorithms, but bearing in mind they are all meant to do the same thing, why so many?
It's to do with the starting condition. If a list is sorted already when you give it to a sorting algorithm, it doesn't have to do any sorting but merely determine that it is already sorted and nothing needs to be done. You can do this by making sure each item is bigger (or equal) to the last. This would be a best case scenario, but each of your N items in the list need to be checked so you end up with O(n)  this means linear performance. A list twice as long takes twice as long.
The worst possible case is when the list is sorted the wrong way around. In this case there are more items, and each item has to bubble up further so you end up with something like n * (n/2) required ops which becomes O(n*n). Each operation takes time so number of ops/time are the same thing here. Double the size and it takes 4 times as long.
In the space complexity O(1) means constant. No new space is required as the sort is contained within the datastructure.
In your case with 25 elements, best case means checking those 25 elements are in order. Worse case is bubbling each the furthest possible distance. A randomized list will be somewhere in between the extremes.
Regards,
Rob Philpott.






Just look up the definition.
f(n) ∈ O(g(n)) iff there exists an n_{0} and c such that for all n > n_{0}, f(n) < c g(n)
This quite technical definition means the whole big O deal is really a statement about membership of a function in some set of functions that, informally, all "grow about the same". But they only have to start growing about the same after some point n_{0} (which you don't know) and an arbitrary constant is hidden.
For time complexity that function we make statements about is the function that counts how many "elementary operations" some algorithm takes a function of the size of its input. In order to do that, one must agree about what kind of operations are elementary. There are several models for that, the "usual one" has the at first sight odd property that mathematical operations on integers of size O(log n) run in constant time. This is necessary to prevent the following problem: suppose you could only do operations on constantlength integers in constant time, and you want to manipulate an index into an array. That array has length n, so the index must have size (you guessed it) log n. It would therefore take nonconstant space to even just have an index, and nonconstant time to do anything with an index, which usually no one wants.
It should be clear from the n_{0} that big O notation explicitly says nothing about the behaviour of the function at any particular constant. It also says nothing about what happens when you double that constant, a mistake that is commonly made, leading to questions such as "it took x milliseconds for an input of size 10, how long will it take for an input of size 20"  you cannot know based on some big O.
Django_Untaken wrote: Let us suppose a simple array contains 25 elements So it should be clear by now that you can't say much about that situation. Bubble sort (and literally anything else) is going to take some constant number of elementary operations (aka "time") on that input, because there is no variable to vary. You cannot compute the number of operations based on the big O (but based on detailed knowledge of the algorithm, you can).





Django_Untaken wrote: Let us suppose a simple array contains 25 elements. What does above information mean and how should I visualize it?? Nothing ! it don't work that way.
Say that you just measured runtime it takes for 25 elements for best case and worst case.
The Big O notation allow you to evaluate what it takes for 250 elements or 2500 elements.
Best case is O(n) means that 10 times the data will take 10 time the runtime and 100 times the data will take 100 time the runtime.
Worst case is O(n^2) means that 10 times the data will take 100 time the runtime and 100 times the data will take 10000 time the runtime.
See these links:
Big O notation  Wikipedia, the free encyclopedia[^]
Analysis of algorithms  Wikipedia, the free encyclopedia[^]
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein





ppolymorphe wrote: Best case is O(n)
Surely the best case would be O(1) ?
And both O(log n) and O(log log n) would be better than O(n) .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
 Homer




