iDev: Statistical Formulas For Programmers

Advertisements
Standard

Linked List, Queue, and Stack Implementations in Python

Graham's Code

Screen Shot 2013-05-23 at 3.37.05 PM
# Programmer: Graham Nedelka
# Linked List, Queue, and Stack Implementations

import random

class Node(object):

def __init__(self, other = None):
self.other = other
self.next = None
self.previous = None

def __str__(self):
return str(self.other)

class List(object):
def __init__(self):
self.head = None
self.tail = None

def append(self, value):

newNode = Node(value)
if self.head == None:
self.head = newNode
self.tail = newNode

else:
self.tail.next = newNode
newNode.previous = self.tail
self.tail = newNode

def __str__(self):
someString = “”
current = self.head
while current != None:
someString = someString + current.other
current = current.next
return someString

class Queue(List):
def enqueue(self, value):
self.append(value)

def dequeue(self):
self.temp = self.head
self.head = self.head.next
return self.temp

class Stack(List):
def push(self, value):
self.append(value)

def pop(self):
self.temp = self.tail
self.tail = self.tail.previous
return self.temp

def main():
list1 = List()
for i in xrange(0, 100):
list1.append(str(random.randrange(0,100)))
print list1
queue = Queue()
for i in xrange(0,100):
queue.enqueue(str(random.randrange(0,100)))
for i in xrange(0,100):
print queue.dequeue()

View original post 26 more words

Standard

My brain hurts…and it’s because of Memory

The Cosmopolitan Geek

This is because of 1 part headache brought on by two parts ‘staying up till 6am to get this weeks project done’.  Don’t worry, an Ibuprofen and a good mug of cold-brewed coffee will clear that up in about 30mins 🙂

The idea of programming is to learn something, then build some code, learn something more, add it to previous knowledge, build better/more elabourate code and so on.  This is something I think is a good process.  And a course that can coax it’s students along with the right methods is one you will never forget.  On the flip side, one that does this but kinda skips over various things with the idea of ‘you can find it online’ really irks me.  I really feel that the progression of learning is NOT linear with the Coursea/RICE University course.  There are major gaps in my understanding of what is happening within…

View original post 989 more words

Standard

A different way to start understanding sequential logic

A Bloggin' Education

Recently I have spent some time thinking about how I can implement some computer programming at current school (trying to lead into the new UK Computing Curriculum) and have had many different ideas. My main interest here is, as with other IT educators, how can we start this and make it both interesting and not explicitly driven by the coding aspect of Computer Science.

This little website and app (Isle of Tune) instantly intrigued me as it seemed to conquer two of the key concepts I wanted to teach. First, it is just simply fun and very addictive. Secondly, the whole concept is based in the same sequential logic as the basic principles and control structures of computer programming, albeit in a visual and musically oriented form.

I am now trying to work out how I can include this as an introduction to a programming unit…

View original post 20 more words

Standard