[Java] Question regarding the use of a priority queue in algorithms such as dijkstra’s algorithm and finding minimum-cost spanning tree using Prim’s algorithm. via /r/learnprogramming


[Java] Question regarding the use of a priority queue in algorithms such as dijkstra’s algorithm and finding minimum-cost spanning tree using Prim’s algorithm.

So right now I'm learning about graph algorithms such as single source shortest path and all-pairs shortest path algorithms, as well as algorithms to find the minimum cost spanning tree of a particular graph.

These graphing algorithms sometimes can employ the use of a priority queue to store vertices that need to be visited.

These algorithms set the source to be 0 and every other vertex in the graph to be infinity. Then it will pull the vertex with the minimum cost and update the values of each vertex.

My two questions are:

(1) how do I represent the vertexes in the queue as infinity if they are integers and not doubles?

(2)Also how is it possible to remove something from a queue that isn't in front? For example a vertex in the back of a Queue could have a value of 2 and the vertex in front can have a value of infinity, so you are supposed to remove that smaller vertex first but I thought Queue's only allow first in first out.

Submitted August 31, 2016 at 07:00PM by lyigester
via reddit http://ift.tt/2bDSxnm

I’m having trouble writing a simple program in Python via /r/learnprogramming


I’m having trouble writing a simple program in Python

I started learning it the other day, and I'm trying to do a specific action. I have a few variables defined and I want them to display during a print sequence but can't figure out how.

This is what I have right now:

r = 5

pi = 3.1415

V = (4/3) * pi * r**3

V

523.5833333333333

And I want to add:

Print ("The volume of a sphere with a radius of r is V") where both r and V are displayed as their numbers. Sorry if this is really simple, but I've tried a few things and am getting a bit frustrated. Thanks for the help.

Submitted August 31, 2016 at 07:07PM by Rodundra
via reddit http://ift.tt/2bIuRva

I hope I’m making this out in the right place but, how do I get started with programming? via /r/learnprogramming


I hope I’m making this out in the right place but, how do I get started with programming?

Okay, so I've always wanted to get into making games. I've always thought I'd make a good designer of a game since I like to analyse these sorts of things and see how a player thinks or acts in situations and etc.

I was intimidated by learning programming since, I thought I'd be getting into a lot of math. I got Smile Basic on my 3DS [a programme that allows you to play other people's indie games and make your own using BASIC language coding.] and I know BASIC isn't really that great, since it's not used and it's slow and etc.

But is it good to learn? And if not, what should I learn?

I've been trying to use these tutorials: https://www.youtube.com/watch?v=C9kwwUlycRY [I got to tutorial 7 I believe, but I haven't really gone back.]

but these videos don't make complete sense to me. I understand what its saying kind of. But I want to know if I should keep practising at this type of coding. And if not, what should I do?

Thank you. c:

Submitted August 31, 2016 at 07:14PM by TheMidnightKrow
via reddit http://ift.tt/2bDSQi1

Need help with conditionals and loops C# via /r/learnprogramming


Need help with conditionals and loops C#

Hello I started learning programming a few days ago and started with C#. It started out fine I learned variables, constants and such. When I came to the conditionals and loops I couldnt understand the most of the stuff like the switch and while.

So I am trying to get some help learning these basic concepts if any of you guys help out it will be appriciated.

Thank you.

Submitted August 31, 2016 at 07:28PM by fakeytr
via reddit http://ift.tt/2bIuWz1

[C#] Argument Exception when trying to set the ValueMember Property to a Combo Box via /r/learnprogramming


[C#] Argument Exception when trying to set the ValueMember Property to a Combo Box

I've been trying to fix this all day and I'm completely stumped. So I've been teaching myself C# using a variety of websites and guides and what not and recently I've been trying to make a text based RPG to put it all together. I've been using this tutorial as a guide if that is helpful, but I wanted to go a bit off of the beaten track and add some features not in the tutorial itself which is where I am now facing some issues.

I wanted to add a spell mechanic into the game so I made a spell class with "ID" and "Name" properties (among others.) Similar to how the items are dealt with in the tutorial, I made a "PlayerSpell" class that would be used to populate a list of PlayerSpells associated with the Player class itself. The only property of the PlayerSpell class is called "Details" which just specifies the spell that is in the PlayerSpells List.

The issue that I'm having is that when I want to fill a combo box with the spells that are in the PlayerSpell list I'm getting an Argument exception when I try to set the Value Member = "ID"

Here is the exact formatting of the method that is meant to fill the combo box:

 private void UpdateSpellListInUI() { List<Spell> spells = new List<Spell>(); foreach(PlayerSpell playerSpell in User.PlayerSpells) { Spell SpellToAdd = playerSpell.Details; spells.Add(SpellToAdd); } if (spells.Count != 0) { cboSpells.DataSource = spells; cboSpells.DisplayMember = "Name"; cboSpells.ValueMember = "ID"; cboSpells.SelectedIndex = 0; } else { cboSpells.Visible = false; BtnUseSpell.Visible = false; } } 

When I run the program it gets as far as line 15 then the exception happens.

Hopefully that's enough info for someone to help. I'm stumped.

Submitted August 31, 2016 at 07:35PM by MCMorgan521
via reddit http://ift.tt/2bDSyYk

Tips on trimming fat on a fork? via /r/learnprogramming


Tips on trimming fat on a fork?

So there is a project I would like to fork and use as a base, however, it offers many features that I do not feel are right for my vision of the program. Does anyone have an suggestions on a systematic way to remove classes and functions that I deem unnecessary?

Submitted August 31, 2016 at 05:52PM by primus454
via reddit http://ift.tt/2bKfNii

Are there some videos where you can watch people literally just programme as they normally do for work? via /r/learnprogramming


Are there some videos where you can watch people literally just programme as they normally do for work?

I know only about https://www.youtube.com/user/obercrash which is for javascript.

C# and .NET for win apps would be awesome.

Submitted August 31, 2016 at 06:20PM by RimanX
via reddit http://ift.tt/2bSIsVQ