Tag Archives: coding

Java: JDBC Basics

Running through this tutorail: http://docs.oracle.com/javase/tutorial/jdbc/basics/index.html Used JDBC before at Northrop figuring it out with working knowledge but never really went through a tutorial for it. Nice thing about the tutorial is that it populates a DB with data for you … Continue reading

Posted in Coding, Java | Tagged , | Leave a comment

Java: Reading/Writing File

Wrote a program that read a file for a company evaluation. I hastily put it together without looking too much at resources so it wasn’t the prettiest of things. Probably should’ve taken my time, so I will now and make … Continue reading

Posted in Coding | Tagged , , | Leave a comment

Add Two Numbers (C++) refactored

Realized I could make it even cleaner. Changed the while loop condition which makes the code much cleaner gets rid of some unnecessary code. ListNode *addTwoNumbers(ListNode *l1, ListNode *l2) { // Start typing your C/C++ solution below // DO NOT write … Continue reading

Posted in Coding | Tagged , , | Leave a comment

Add Two Numbers (C++)

This is from the http://www.ihas1337code.com/onlinejudge website.  His onlinejudge testing is really neat. I’d like to setup something like that. // Definition for singly-linked list. // DO NOT modify this. struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) … Continue reading

Posted in Coding | Tagged , | Leave a comment

Iterative InOrder Tree Traversal 2 (C++)

Found this from another website, http://www.ihas1337code.com. It’s so much cleaner. void iterativeInOrderTraverse2(Node *root) { stack<Node *> nodes; Node *currNode = root; while(!nodes.empty() || currNode) { if (currNode) { nodes.push(currNode); currNode = currNode->left; } else { currNode = nodes.top(); nodes.pop(); printf(“%c … Continue reading

Posted in Coding | Tagged , , | 2 Comments

Iterative PreOrder Tree Traversal (C++)

PreOrder Traversal means displaying the root first, then traverse left subtree, and then traverse the right subtree. Because a stack is LIFO (last in first out), we need to be careful how we insert the nodes into the stack. We … Continue reading

Posted in Coding | Tagged , , | Leave a comment

Iterative InOrder Tree Traversal (C++)

InOrder Traversal: Left Root Right Stack Space: Proportional to the height of the tree void iterativeInOrderTraverse(Node *root) { stack<Node *> nodes; Node *currNode = root; while(true) { if (currNode) { Node *leftNode = currNode->left; nodes.push(currNode); currNode = leftNode; } else … Continue reading

Posted in Coding | Tagged , , | Leave a comment