Programming

Binary Search Tree with strings

Learn Programming - Thu, 09/20/2018 - 18:40

I don't have any conception of how to use a binary search tree to store and search for strings. I brought it up to my professor, but she said it was based on their length. Which feels like maybe she misunderstood my question because "cat", "bat", and "dog" all have the same length, but are different strings. I know about Trie data structures, but the project I'm working on requires a slightly more efficient Trie called a Burst Trie. Basically, at each node, their is something called a "container" (a binary search tree). When the container fills up it "bursts" and the node becomes a regular node. The node will now have a single child which is a container. So on and so forth as long as you have data to insert, containers will continue to "burst" and nodes will be left in their place. I think the basic premise is: binary search trees are faster with smaller quantities of data. So you use the Trie data structure to traverse to the lowest node which ultimately is just a container and you use that BST to find the suffix.

But I don't understand the BST portion. Lets say you have "cat", "bat", and "dog". Is "bat" < "cat" lexicographically? Would our BST store suffixes like "at", or "og"? Or would it only store characters? How do normal BST string-based data structures handle it?

submitted by /u/thisisyournamenow
[link] [comments]

Navigating a Large Codebase

Programming - Thu, 09/20/2018 - 18:39
Categories: Programming

Want to learn (overwhelmed)

Learn Programming - Thu, 09/20/2018 - 18:32

I want to learn to program but there are so many choices in terms of courses. Any links to an up to date course that starts from scratch?

submitted by /u/ArthurEli
[link] [comments]

Creative applications of coding

Learn Programming - Thu, 09/20/2018 - 18:30

To give a little bit of background I have tried learning python and C in the past and have also taken some courses on java. I would say that I had the most experience in Java, enough to make a simple tower defense game from scratch but it's been quite a while since I've coded and I've forgotten a lot of the specific syntax and "functions" associated with each language. I'm currently in high school and I'm trying to search for possible career paths. I think I'm more of a creative person than a logistical one, if that makes sense. The most obvious creative application of coding may be in creating video games, but I'm wondering if there's others. My dad actually works on Microsoft Excel but I don't think I want to pursue something like that as a career. I've also considered bio engineering, but I'm not sure how much of that field actually involves coding. Even if it doesn't develop into an actual career, I'm interested in exploring creative applications of programming in my free time.

submitted by /u/Current_News
[link] [comments]

Are you a self-taught and employed machine learning engineer? If yes, how did you do it, and how long did it take?

Learn Programming - Thu, 09/20/2018 - 18:28

I am learning Javascript at the moment since there seems to be a bigger market for it and I've noticed more inexpensive resources for it vs Python. However, I am really interested in machine learning and if anyone has been able to secure a job as a machine learning engineer, I would like to hear from them. Thank you in advance.

submitted by /u/schumannop44
[link] [comments]

[JS] Recursion Example Confusing Me

Learn Programming - Thu, 09/20/2018 - 18:11

Hey guys, I've been re-attacking JS lately and I have gotten a bit stuck on recursion. I understand the general concept, however I have a problem understanding a specific example that I found. The problem I was working on asked me to create a recursive function that could find the greatest common divisor of two numbers. I got stuck and peeked at the solution which follows

var gcd = function(a, b) { if ( ! b) { return a; } return gcd(b, a % b); }; console.log(gcd(2154, 458));

The if statement in the second line is what I am not understanding. '!' is the not logical operator as far as I know, but I'm not seeing what purpose that if statement has in this function. Anyone who could deconstruct what this function and that one statement in particular are doing would be a great help.

submitted by /u/popp91
[link] [comments]

Help on a program, truncating a list of items.

Learn Programming - Thu, 09/20/2018 - 18:06

Hi, just some background. I do not work as a programmer, however, making simple programs to help me do daily tasks has been very helpful for my work. I use python because that's the only language I'm really comfortable with.

I work for a steel fabrication company, and every now and again I need to help out estimating jobs. We own a program that allows us to form an itemized list of all steel beams on the job. Part of the issue is that this program exports out a text-file, and it's really unorganized. Here is a sample of what one line in the text file looks like.

"w 16x31" "5" "#FF0000" "" "14.7598"

The first item is the type of beam, the next item is the page I found it on, the next two items are unimportant, and the last item is the length.

So I read the file, and put all these items into a list, and then put all those lists into one big list. So eventually I'll have something that looks like this and I'll call it the variable mylist,

mylist = [... , ["w 16x31", "5", "#FF0000", "", "14.7598"] , ...]

Now one of my goals is to truncate these lists. Since right now there's no way of saying 2 of the same items. So my solution is to loop through mylist, take the first item in the list, then create another loop inside the first loop, comparing the first term to every other term. If the item type and the page number are the same, and also if the length is within a certain threshold, I want to count them as "the same". Here's what my code looks like right now.

def get_lines(lines): mylist = [] #list of items in take-off found = [] #list of items already combined newlist = [] #Condensed list of take-off where last item in list is quantity counter = 0 #Create mylist for line in lines: cell = line.split(" ") if cell[0] == 'Subject' or cell[0] == '': continue mylist.append(cell) #Create newlist for i in mylist: #If condensed item is found, continue to next item if i in found: continue #Exception for 'countable' items if i[4] == "": i[4] = 0 #Compare one term i, to the other terms j for j in mylist: if j[4] == "": j[4] = 0 ilength = float(i[4]) - (float(i[4])%1) #Rounding down to the nearest 1 jlength = float(j[4]) - (float(j[4])%1) if (i[0] == j[0]) and (i[1] == j[1]) and (ilength == jlength): counter += 1 #Counter always goes to 1 as i gets compared to itself found.append(j) i.append(counter) i[4] = (float(i[4]) - (float(i[4])%1)) + 1 #Rounding up to the nearest 1 newlist.append(i) counter = 0 return newlist

Basically what I'm doing is starting with the first item, "i", and counting how many objects match i. i always matches itself, so the counter should always go up from 0 to 1, and then if the program finds any other matching item "j", it will increase the counter by 1, and put j in a list of "found" items, where my original loop will skip over any item in that list. At the end, it will take i, and append the quantity of like items. So if two items are similar, it will put a 2 at the end of list i. Then I will create a newlist with all my i's. That newlist should contain a truncated list of mylist.

For the most part this works perfectly fine. But for some reason, and honestly, somewhat randomly, the counter function adds in an extra quantity. I'll end up with a new list of items, where every new piece of information is correct, but there are like 2 instances where the quantity is increased by 1. Instead of getting,

["w 16x31", "5", "#FF0000", "", "16", 3]

I'm getting

["w 16x31", "5", "#FF0000", "", "16", 4]

And I have no explanation for it, there's quite literally only 3 items, and I checked multiple times, but I keep getting 4.

Here is my textfile if anyone actually feels like copy-pasting it and trying to help me out.

C 8x13.75 4 #FF0000 4.8339

C 8x13.75 4 #FF0000 4.8339

Bearing Plates 5 #00FF00 4.5051 in 6

w 16x31 5 #FF0000 7.8288

L 4x4x3/8 5 #FF0000 3.4984

L 4x4x3/8 5 #FF0000 10.3711

w 16x26 5 #FF0000 5.9912

w 8x10 5 #FF0000 6.9873

w 8x10 5 #FF0000 7.6144

L 4x4x3/8 5 #FF0000 6.5421

w 16x26 5 #FF0000 23.0337

C 8x13.75 5 #FF0000 5.239

w 8x10 5 #FF0000 7.3666

w 18x46 5 #FF0000 9.1585

w 16x26 5 #FF0000 23.1809

w 16x26 5 #FF0000 23.1809

w 16x26 5 #FF0000 23.181

w 16x31 5 #FF0000 14.7598

w 16x31 5 #FF0000 15.2691

w 16x26 5 #FF0000 12.4897

w 16x26 5 #FF0000 22.8339

w 16x26 5 #FF0000 18.8278

w 16x26 5 #FF0000 23.181

w 16x26 5 #FF0000 6.4802

w 16x26 5 #FF0000 11.9911

w 16x26 5 #FF0000 23.181

C 8x13.75 5 #FF0000 5.239

w 16x31 5 #FF0000 15.0089

w 18x60 5 #FF0000 23.6268

w 16x31 5 #FF0000 15.0109

w 16x31 5 #FF0000 14.7617

L 4x4x3/8 5 #FF0000 10.3711

w 16x26 5 #FF0000 23.181

L 4x4x3/8 5 #FF0000 10.3711

w 16x26 5 #FF0000 23.181

w 16x31 6 #FF0000 7.8288

w 16x26 6 #FF0000 22.8339

L 4x4x3/8 6 #FF0000 10.3711

L 4x4x3/8 6 #FF0000 0.9436

L 4x4x3/8 6 #FF0000 10.3711

L 4x4x3/8 6 #FF0000 1.2146

w 12x26 6 #FF0000 6.4203

w 16x26 6 #FF0000 11.9911

w 16x26 6 #FF0000 18.8278

w 16x26 6 #FF0000 23.181

w 16x26 6 #FF0000 23.1809

w 16x26 6 #FF0000 12.4897

L 4x4x3/8 6 #FF0000 10.3711

w 18x46 6 #FF0000 9.8243

w 16x26 6 #FF0000 23.1809

w 18x60 6 #FF0000 23.6268

w 8x10 6 #FF0000 6.7316

HSS 7x7x3/8 6 #FF0000 10.6388

w 16x26 6 #FF0000 23.181

w 16x31 6 #FF0000 15.0109

w 16x26 6 #FF0000 23.0337

w 16x26 6 #FF0000 6.4802

w 16x31 6 #FF0000 15.0089

L 4x4x3/8 6 #FF0000 6.5421

w 16x26 6 #FF0000 23.181

w 8x24 6 #FF0000 9.0006

L 4x4x3/8 6 #FF0000 3.4984

w 16x26 6 #FF0000 23.1809

w 16x31 6 #FF0000 14.7617

w 8x10 6 #FF0000 7.6724

w 16x31 6 #FF0000 14.7598

w 8x10 6 #FF0000 7.0525

w 16x26 6 #FF0000 23.181

w 16x31 6 #FF0000 15.2691

submitted by /u/anooblol
[link] [comments]

[Question] How to store data locally in C#?

Learn Programming - Thu, 09/20/2018 - 18:01

Can anyone explain how you can store data locally in C sharp?

Basically, I'm just trying to store simple things like strings, class data, and variables that can be loaded up upon the start of the program.

If anyone could help me out with that, that would be awesome!

submitted by /u/JonathanTCrane
[link] [comments]

[Networking] Interframe gaps in full-duplex store-and-forward Ethernet switches.

Learn Programming - Thu, 09/20/2018 - 17:31

This is a simple question, but I'm having trouble finding a definitive answer:

When the switch gets a frame from one of the nodes/stations, is there an interframe gap between the receiving of that frame and sending it out or does it get sent out immediately?

I have a feeling that a gap is needed, but I'm not 100% sure.

submitted by /u/ShadowJak
[link] [comments]

Bachelor's vs. Udacity vs. edX Microsoft Professional Program in Entry-Level Software Development, etc. - any advice?

Learn Programming - Thu, 09/20/2018 - 17:09

Dear enlightened and ever-so-helpful Reddit professionals,

Thank you in advance for reading. Using a throwaway due to lots of personal information.

I am trying to decide what to do with my life and how to move forward with my career. I appreciate any and all input.

I am a 30-year-old woman. I have a BA in Political Science and Spanish and a Master of Public Administration degree. I have been with the same company for over six years and got promoted in 2016.

I wear a lot of different hats at my job. My title is Team Leader, so I handle escalations from my team and help plan their workloads. Since we’re talking about tech, I’m sort of like a part-time Blackboard/Moodle administrator. I mess with a lot of Blackboard and Moodle settings, troubleshoot issues, look at the data in SQL to troubleshoot student enrollment issues, things backed up on the portals, etc. (I also use a lot of soft skills – writing good emails, prioritizing tasks, managing lots of different kinds of tasks, helping team members communicate effectively with clients and other departments, client onboarding, and direct support to university faculty for their online courses, among many other things.)

I love my job, but it just doesn’t pay enough ($46k). There is also not a lot of room for growth. The next step would be for me to become a manager, and I just don’t think I would be super thrilled with that job, either. My job also just isn’t that challenging. I am looking to learn something new and implement new skills in a different job. Also, even if I don't end up getting a different job, increasing my skill set helps me sleep better at night.

I considered moving into our IT department, but the level I would be entering at would pay less (more like $40k), I would have to drive into the office (I currently work from home), and I would have to stay up all night one Sunday a month AND work the entire following Monday. I have sleep issues anyway and am simply not willing to do this on a regular basis. (I realize that many IT professionals sometimes have to work late nights and be on call, but it seems to me that they aren’t always regular like this.) I am also not willing to come into the office for $40k because of the increased costs that would entail in both money and time.

I have, in the past, taken a front-end web design course through Treehouse; I didn’t love the process of making a website, but I learned how to use Git and other important skills. I use HTML and CSS a tiny bit in my job.

I am currently enrolled in the Data Fundamentals nanodegree from Udacity (now called Business Analytics). I’m almost finished and trying to decide what to do next. This nanodegree covered basic statistics, Excel, basic SQL and now I’m in the last section which is about Tableau. I’ve really enjoyed all the content, but it’s pretty easy to me. One option is to keep going in this direction and complete the Data Analytics nanodegree and then the Data Science one. I am not sure any employers would take these seriously.

I have the option of getting another bachelor’s in Computer Science through my job for about $5600, which is a great deal. However, there are various reasons why I’d rather not. It’s an increased cost vs non-degree options, it’s synchronous which would interfere with any trips I want to take, and it’s also a religiously-affiliated school so I’m not too thrilled about that.

I am trying to find something similarly comprehensive that’s self-paced online, but the issue is that I’m not sure whether any non-degree program really cover theoretical and other concepts enough. For example, let’s look at what the bachelor’s would cover:

Bachelor’s in CS ($5600)

Prerequisite

MAT 110 Introduction to Probability and Statistics (3)

Required

CSC 115 Introduction to Computer Science

CSC 175 Math for Computer Science

CSC 222 Introductory Programming with Java

CSC 135 Modern Web Design

MAT 220 Discrete Mathematics

CSC 230 Database Design

CSC 322 Object Oriented Programming in Java

CSC 235 Server-Side Development

CSC 310 Computer Architecture and Operating Systems

CSC 330 Language Design and Implementation

CSC 422 Software Engineering

CSC 420 Data Structures and Algorithms

CSC 450 Computer Science Capstone

Electives

Choose one of the following

CSC 315 Mobile App Development

CSC 435 Advanced Web Application Development

...and here's one comprehensive non-degree set of online courses in this area from edX:

edX Microsoft Professional Program in Entry-Level Software Development ($1300)

Course 1: Introduction to Python: Absolute Beginner

Course 2: Introduction to Design Thinking

Course 3: Logic and Computational Thinking

Course 4: Introduction to Python: Fundamentals

Course 5: Writing Professional Code

Course 6: Learn to Program in Java

Course 7: Object Orientated Programming in Java

Course 8: Building Interactive Prototypes using JavaScript

Course 9: Building Functional Prototypes using Node.js

Course 10: Designing a Technical Solution

Course 11: Algorithms and Data Structures

Course 12: Introduction to Developing International Software

Course 13: Microsoft Professional Capstone: Entry Level Software Development

Five of the courses are identical. It looks like for the remaining ones, the bachelor’s is heavier on theory and the edX one is heavier on programming. But I also looked up the theoretical/systems courses included in the BS and not in the edX program and all of them can be taken for free, many of them on MIT OCW.

There may be another comprehensive program aside from the edX one that I don’t know about. It seems more common that these materials are spread out rather than put together as one comprehensive package.

Important note: I honestly do not have enough experience in this area to know exactly what I want to do. I do know that I enjoy data stuff more than front-end web design, but that’s it. I feel like something comprehensive would give me a nice skill set and maybe point me in the right direction, so that’s why I’m looking at that, but focusing on data is also an option (but they all intertwine anyway, so I feel like I can't go wrong getting an overview).

Does anyone have an opinion on this? If I did the edX course plus the free math/theory courses (database design, server-side, etc.) and put together a portfolio, do you think any employers would take me seriously? Or should I just go for the bachelor’s? I really don’t want to but I will if I have to.

Thank you in advance for any responses. I know it takes time to respond to someone on Reddit and I appreciate it very much.

submitted by /u/throwawaycg1777
[link] [comments]

My javascript works only on the first click. After I click it again, nothing happens.

Learn Programming - Thu, 09/20/2018 - 16:44

https://gist.github.com/Jreye039/9b4dca722ed478a4adfe64b54e6bfaf4

So on first click, I will be able to edit the text. Then I click away and click back and it's not possible anymore. Any ideas as to why?

I know I have the editableContent commented out in the function but I shouldn't have to have because it's set in the div itself right? Also, I don't want to have to click twice to be able to edit. The user should just have to click once to be able to edit which is why I'm using onclick. I don't feel like there is too much to mess up here, I'm hoping it's a super simple mistake.

submitted by /u/Jesse4Lyfe
[link] [comments]

Managed VPS Hosting VS Unmanaged VPS Hosting

Learn Programming - Thu, 09/20/2018 - 16:39

I'm wondering if unmanaged VPS hosting is really a hard hell as the companies assume it is ? Managed VPS Hosting has the inconvenient to break the learning curve of a developer who want to improve its programming skill. In my case I plan to deploy relatively common small businesses's web application

submitted by /u/JoonDoe
[link] [comments]

Where Are Signed Integers Managed (I.e. Circuit or processor, etc)

Learn Programming - Thu, 09/20/2018 - 16:34

TL;DR where do we handle signed integers? Is it a circuit level problem or do we handle it in the processor?

Okay so I don't know if this is the right area or not. Anyways, in one of my classes (EE) we are going over logic circuits (so we are beyond the math if understanding basic components) and as such we have come across some very basic circuits (half adder, full adder, etc). Today in class we dissected the subtractor logic circuit and we looked at different cases (A>B, A=B, A<B) where f(A,B) = A-B

Specific to the third case where B is larger than A we get an integer overflow. For instance, on a 4 bit subtractor if you were to subtract 5 from 1 (A=1, B=5) it gives you 10.

So my question is, how do computers and calculators and such handle negative numbers? I mean I understand that we denote 1 bit to the sign (meaning a 32 bit signed Integer has 31 bits allocated to storing the number and 1 bit allocated for storing the sign) but like.

Maybe I am saying in a confused way but like, how do computers know to comprehend a number as negative and not as unsigned? For instance, 4 in binary (at 4 bits) is 0100 so -4 would be 1011 but how does the computer know to read 1011 as a negative value over reading it as 11?

submitted by /u/kryzsec
[link] [comments]

Access a content type and its data from Drupal 7 database

Drupal - Open Source Content Platform - Thu, 09/20/2018 - 16:28

I have this Drupal 7 site that had a form collecting data from unregistered users. All data collected belongs to a content type named "Registration" with 18 fields.

Now I was looking into the database and found that this data is stored in separate tables and not in one like I was hoping for.

I need to display this data (all from "Registration" content type) on an external PHP application. Is there an easy way to access this data?

submitted by /u/lolzyman
[link] [comments]

I LOVE learning how to code I HATE coding

Learn Programming - Thu, 09/20/2018 - 16:28

Hello people

I love programming more than anything in this life

I have failed two straight years in collage (Civil Engineering) because of that all was i thinking is programming and how to learn it.

At first i used to spend 3 hours a weak learning , wasn't really serious about that and didn't know the real way,

A year ago i started to learn seriously every day .

I have learned java , and some android.

My problem isn't that i love programming ..

My problem is I JUST ENJOY LEARNING I DON'T WANT TO CODE BY MYSELF

every time i want to code something i got lazy and leave it

i just keep learning and see whatever programming tutorial that i find

and that's so sad because i want to be a good programmer and work in that field :/

......
two weeks ago i have created a simple but helpful app for high school students in my country

and then i figured out that Google doesn't allow Iraq to upload apps to the play store

and that made me more frustrated :/
.....

I have an ambition

I have a big dream

I have time

What i don't have is a plan to follow

lead me

submitted by /u/zaid000111
[link] [comments]

Is there a way to hide comments on Github (website)?

Learn Programming - Thu, 09/20/2018 - 16:23

Not talking about minimizing them but to completely hide/replace them with a quick line (or something at least close to that) that warns me that there is a comment there to check later after reading related code to that section.

After all this time coding (close to 12 years with a few breaks here and there), this thing still bugs me everyday.

I work pretty much only with Github and Studio at the moment and this is bugging me a lot day by day because the number of comments is increasing in where I work... Sometimes I've a comment before EACH line of code for no apparent reason but to annoy me/make my work slower (this is not wrong, useful comments are always nice to check when you're a new coder that joined the scene and needs to understand everything quickly, but I would like to ignore if I'm aware of what we're doing and only check them later to be sure that I got it right) since it forces me to copy/paste code into notepad++ just to remove comments and understand everything in a blink of a second and then later give a ctrl+z to confirm if I was right or not...

I gave a quick search and found a few cool add-ons for firefox with a quick search but they still miss this little feature when I compare additions in Github.

I feel like not having (or knowing) a way to hide/show them is making me a slower coder because I understand what I check but waste a lot of time trying to do 1+1 it in the middle of tons of comments...

submitted by /u/Elvish_Champion
[link] [comments]

How do .pdf files work?

Learn Programming - Thu, 09/20/2018 - 16:16

From what I read in the last 15 minutes, pdf was an interchangeable document format (evolved from postscript) used specifically to view documents, and so only the visual appearance of the document is encoded into the file.

Im not sure how it has evolved since then, but I would assume there would be some way to preserve the structural integrity of the document.

Is it possible to search for and grab specific elements from a pdf file using some structural/container tags from the .pdf?

E.g if I have a series of invoices, could I grab the vendor, products, and prices from the pdf file?

P.S trying to avoid OCR and surface automation.

submitted by /u/throwawaysnwi71838
[link] [comments]

Can someone explain to me the difference between implicit and explicit casting, parsing and type conversion.

Learn Programming - Thu, 09/20/2018 - 15:54

I have recently been taught this stuff at college and its all just went over my head and every lesson i find on YouTube is bad quality.

Thanks in advance.

EDIT: Language is Java

submitted by /u/Unitedthe_gees
[link] [comments]

[Python/OpenCV]Drawing ellipse based on extreme points

Learn Programming - Thu, 09/20/2018 - 15:48

Hi,

I have scoured the internet but haven't found the solution. I'm trying to fit an ellipse based on the extreme points of a contour. The fit does not have to be perfect but should be the best possible (in a least square sense).

I only recently started to learn and program, so I might be overlooking things. I hope someone with more experience could help me out

#Determining the extreme points c = sorted( contours, key=cv2.contourArea, reverse = True)[:1] extLeft = tuple(c[c[:, :, 0].argmin()][0]) extRight = tuple(c[c[:, :, 0].argmax()][0]) extTop = tuple(c[c[:, :, 1].argmin()][0]) extBot = tuple(c[c[:, :, 1].argmax()][0])

This leaves me with 4 coordinates of the most extreme points in all directions. The ellipse should be drawn in the best possible way including those 4 coordinates. The most important point is extRight.

submitted by /u/TheCrafft
[link] [comments]

Pages